Install mongodb3.6 in centos7
Update the system first
yum -y update
1. Install MongoDB
Edit the Mongodb installation source
vim /etc/yum.repos.d/mongodb-org-3.6.repo
Edited as follows:
[mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
Install
yum install -y mongodb-org
CentOS installation of Mongodb in detail (online and offline)
Reprinted 2017-01-12 Author: I want to comment
Let's talk about the recommended installation first: online installation, following the official can avoid some problems
I still recommend offline installation for new learning Mongodb
1. Offline installation: (in two batches, with and without Linux foundation)
Comrades with Linux foundation can see:
Installation package: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.1.tgz
Installation process
Install the pstree gadget, and its use
close mongodb
To set boot up:
Comrades without Linux foundation:
First go to the official download offline installation package: https://www.mongodb.com/
ftp to connect to the server and upload the offline package
XShell connect it:
Unzip the file (you can press the tab key if you type a little, it will automatically complete): tar -xzf mongo*
If the decompression command is unclear, you can go to the documentation library to see the basic command http://dnt.dkill.net/dnt
Switch to the root user, copy the folder to the /usr/local directory (general software is installed here), rename the folder
cp -r mongodb-..... /usr/local/ mv mongodb..../ mongodb
If you don't understand the command, please see:
Switch to the /usr/local/mongodb directory, create a database directory and journal file, and run mongod in the background (./ represents the current directory)
mkdir dbs touch logs ./mongod --dbpath=/usr/local/mongodb/dbs/ --logpath/usr/local/mongodb/logs --fork
View process, end process
pstree -p | grep mongod pkill mongod
If you are prompted that there is no pstree command, it means that you have also installed the minimum installation. Don't panic, just install it.
yum install -y psmisc (for safe applications, you can use -y, fully automatic installation, if you are worried, just read them one by one)
Is it too troublesome to start? It can be simplified ==" as shown in the figure
If it is the first time to use vi, first press i to enter the editing mode, after the input is completed, press ESC, enter: wq and press Enter. If you find that you can't quit no matter what you do, don't be afraid, force quit and use: q!
Enter ./mongod -f mongod.conf to start
Generally speaking, it is enough to add a startup item to do this. It is also done when playing kali against the sky. It is also done when the ssh sent last time cannot be started~~~ But. . . I don't know why, CentOS can't do this, so skip this step
Switch to this directory first: cd /lib/systemd/system
Create another service of mongodb: vi mongodb.service
Enter the following:
[Unit] Description=mongodb After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongod.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/bin/mongod.conf PrivateTmp=true [Install] WantedBy=multi-user.target
Start the service:
systemctl start mongodb.service
Out of service:
systemctl stop mongodb.service
boot:
systemctl enable mongodb.service
If you are unclear, you can see the common Linux documentation: http://dnt.dkill.net/dnt/linux/cmd.html
After restarting, I found that ~mongodb has been started automatically after booting!
Now you can delete the original file~
2. Online installation:
Online installation is basically not difficult, just follow the official documentation:
package information
Note that the installation only supports 64 systems
add files
The content is officially given:
Install it, it's extremely slow
It has been installed, and I'm not happy to continue to post it. It's boring, let's follow the official documentation~
Continue on another day, the following pictures prove that the database is no problem
The above is the whole content of this article, I hope it will be helpful to everyone's learning, and I hope everyone will support Scripting Home.
Update the system first
yum -y update
1. Install MongoDB
Edit the Mongodb installation source
vim /etc/yum.repos.d/mongodb-org-3.6.repo
Edited as follows:
[mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
Install
yum install -y mongodb-org
CentOS installation of Mongodb in detail (online and offline)
Reprinted 2017-01-12 Author: I want to comment
Let's talk about the recommended installation first: online installation, following the official can avoid some problems
I still recommend offline installation for new learning Mongodb
1. Offline installation: (in two batches, with and without Linux foundation)
Comrades with Linux foundation can see:
Installation package: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.1.tgz
Installation process
Install the pstree gadget, and its use
close mongodb
To set boot up:
Comrades without Linux foundation:
First go to the official download offline installation package: https://www.mongodb.com/
ftp to connect to the server and upload the offline package
XShell connect it:
Unzip the file (you can press the tab key if you type a little, it will automatically complete): tar -xzf mongo*
If the decompression command is unclear, you can go to the documentation library to see the basic command http://dnt.dkill.net/dnt
Switch to the root user, copy the folder to the /usr/local directory (general software is installed here), rename the folder
cp -r mongodb-..... /usr/local/ mv mongodb..../ mongodb
If you don't understand the command, please see:
Switch to the /usr/local/mongodb directory, create a database directory and journal file, and run mongod in the background (./ represents the current directory)
mkdir dbs touch logs ./mongod --dbpath=/usr/local/mongodb/dbs/ --logpath/usr/local/mongodb/logs --fork
View process, end process
pstree -p | grep mongod pkill mongod
If you are prompted that there is no pstree command, it means that you have also installed the minimum installation. Don't panic, just install it.
yum install -y psmisc (for safe applications, you can use -y, fully automatic installation, if you are worried, just read them one by one)
Is it too troublesome to start? It can be simplified ==" as shown in the figure
If it is the first time to use vi, first press i to enter the editing mode, after the input is completed, press ESC, enter: wq and press Enter. If you find that you can't quit no matter what you do, don't be afraid, force quit and use: q!
Enter ./mongod -f mongod.conf to start
Generally speaking, it is enough to add a startup item to do this. It is also done when playing kali against the sky. It is also done when the ssh sent last time cannot be started~~~ But. . . I don't know why, CentOS can't do this, so skip this step
Switch to this directory first: cd /lib/systemd/system
Create another service of mongodb: vi mongodb.service
Enter the following:
[Unit] Description=mongodb After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongod.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/bin/mongod.conf PrivateTmp=true [Install] WantedBy=multi-user.target
Start the service:
systemctl start mongodb.service
Out of service:
systemctl stop mongodb.service
boot:
systemctl enable mongodb.service
If you are unclear, you can see the common Linux documentation: http://dnt.dkill.net/dnt/linux/cmd.html
After restarting, I found that ~mongodb has been started automatically after booting!
Now you can delete the original file~
2. Online installation:
Online installation is basically not difficult, just follow the official documentation:
package information
Note that the installation only supports 64 systems
add files
The content is officially given:
Install it, it's extremely slow
It has been installed, and I'm not happy to continue to post it. It's boring, let's follow the official documentation~
Continue on another day, the following pictures prove that the database is no problem
The above is the whole content of this article, I hope it will be helpful to everyone's learning, and I hope everyone will support Scripting Home.