MongoDB3.4.10
Link: https://pan.baidu.com/s/1gitvv9I3f4f70o0QgSSY5Q
extraction code: txng
Read the catalog:
1. Turn off the firewall and Selinux
2. Download and install MongoDB 3.4.x version
3. Set up the MongoDB database
4. Configure the MongoDB database to start automatically
5. Precautions and instructions
1. Turn off the firewall and Selinux
Linux firewall is a nightmare for our novices. In many cases, it will be able to ping, but can not access Web pages. So kill it from the beginning!
1.1 Turn off the firewall
[root@localhost ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
1.2 Automatically turn off the firewall when booting
[root@localhost ~]# chkconfig iptables off
1.3 View Selinux status
[root@localhost ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
1.4 Close selinux
[root@localhost ~]# vi /etc/selinux/config
Modify SELINUX = disabled and restart the machine.
Note: Permanently open-> Change to: SELINUX = enforcing
2. Download and install MongoDB 3.4.x version
2.1 Download MongoDB
[root@localhost ~]# curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.10.tgz
2.2 Unzip MongoDB
[root@localhost ~]# tar -zxvf mongodb-linux-x86_64-3.4.10.tgz
2.3 Move the unzipped folder to the MongoDB installation directory
[root@localhost ~]# mv mongodb-linux-x86_64-3.4.10 /usr/local/mongodb
2.4 Create MongoDB database storage path
[root@localhost ~]# mkdir -p /data/mongodb/mongodb_data/
2.5 Create MongoDB database log storage path
[root@localhost ~]# mkdir -p /data/mongodb/mongodb_log/
3. Set up the MongoDB database
3.1 Start MongoDB
[root@localhost developer]# /usr/local/mongodb/bin/mongod --port 27017 --fork --dbpath=/data/mongodb/mongodb_data/ --logpath=/data/mongodb/mongodb_log/mongodb.log --logappend
Note: developer is a folder added at will, does not affect the operation
3.2 Check whether MongoDB is started
[root@localhost developer]# netstat -lanp | grep "27017"
3.3 Enter the MongoDB folder
[root@localhost developer]# cd /usr/local/mongodb/bin
3.4 Enter MongoDB database console
[root@localhost bin]# ./mongo
3.5.1 Enter the admin database
> use admin
3.5.2 Shut down the MongoDB database
> db.shutdownServer()
3.5.3 Exit
> exit
3.6 Enter MongoDB installation directory
[root@localhost bin]# cd /usr/local/mongodb/
3.7 Create and edit mongodb.conf
[root@localhost mongodb]# vim /usr/local/mongodb/mongodb.conf
#PORT 号
port = 27017 #Database
path
dbpath = / data / mongodb / mongodb_data / #Log
output file path
logpath = / data / mongodb / mongodb_log / mongodb.logpidfilepath = / usr / local / mongodb / mongo.pid #Set
background running
fork = true #Log
output mode
logappend = trueshardsvr = true #Enable
authentication
# auth = true
Save and exit.
3.8 Start MongoDB
[root@localhost mongodb]# /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.conf
3.9 Close MongoDB
[root@localhost mongodb]# /usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()"
4. Configure the MongoDB database to start automatically
4.1 Set up and start MongoDB
[root@localhost mongodb]# vim /etc/rc.d/init.d/mongod
ulimit -SHn 655350
#!/bin/sh
# chkconfig: - 64 36
# description:mongod
case $1 in
start)
/usr/local/mongodb/bin/mongod --maxConns 20000 --config /usr/local/mongodb/mongodb.conf
;;
stop)
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()"
;;
status)
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin --eval "db.stats()"
;;
esac
4.2 Add script execution permission
[root@localhost mongodb]# chmod +x /etc/rc.d/init.d/mongod
4.3 Set boot
[root@localhost mongodb]# chkconfig mongod on
4.4 Start MongoDB
[root@localhost mongodb]# service mongod restart
4.5 Adding environment variables
[root@localhost mongodb]# vim /etc/profile
Add the following code to the last line of the text:
export PATH=$PATH:/usr/local/mongodb/bin
Save and exit.
4.6 Make configuration effective immediately
[root@localhost ~]# source /etc/profile
5. Matters needing attention and instructions
Precautions:
MongoDB download is slow, it is recommended that you can use the local download and then drag it to the virtual machine or server.
5.1 Introduction
Under the Linux system, you can upload local files to the Linux operating system through the rz command, and download server files to the local disk through the sz command. All files are transferred through the SSH protocol.
The general Linux minimum installation does not install this tool, we can install this tool directly using Yum source.
5.2 Installation
[root@localhost ~]# yum -y install lrzsz*
5.3 Upload local MongoDB files to Linux
[root@localhost ~]# rz
Description: This use
Operating system: CentOS 6.8 64-bit
MongoDB version: 3.4.10