centos安装mongodb单机
官网下载mongodb包、解压、配置环境变量
[root@localhost software]# cd mongodb/
[root@localhost mongodb]# ll
total 0
[root@localhost mongodb]# pwd
/software/mongodb
[root@localhost mongodb]# ll
total 0
[root@localhost mongodb]# rz -E
rz waiting to receive.
[root@localhost mongodb]# ll
total 71552
-rw-r--r--. 1 root root 73265692 Feb 5 13:32 mongodb-linux-x86_64-4.0.6.tgz
[root@localhost mongodb]# tar -zxvf mongodb-linux-x86_64-4.0.6.tgz
mongodb-linux-x86_64-4.0.6/README
mongodb-linux-x86_64-4.0.6/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-4.0.6/MPL-2
mongodb-linux-x86_64-4.0.6/LICENSE-Community.txt
mongodb-linux-x86_64-4.0.6/bin/mongodump
mongodb-linux-x86_64-4.0.6/bin/mongorestore
mongodb-linux-x86_64-4.0.6/bin/mongoexport
mongodb-linux-x86_64-4.0.6/bin/mongoimport
mongodb-linux-x86_64-4.0.6/bin/mongostat
mongodb-linux-x86_64-4.0.6/bin/mongotop
mongodb-linux-x86_64-4.0.6/bin/bsondump
mongodb-linux-x86_64-4.0.6/bin/mongofiles
mongodb-linux-x86_64-4.0.6/bin/mongoreplay
mongodb-linux-x86_64-4.0.6/bin/mongod
mongodb-linux-x86_64-4.0.6/bin/mongos
mongodb-linux-x86_64-4.0.6/bin/mongo
mongodb-linux-x86_64-4.0.6/bin/install_compass
[root@localhost mongodb]# ll
total 71552
drwxr-xr-x. 3 root root 95 Mar 12 22:42 mongodb-linux-x86_64-4.0.6
-rw-r--r--. 1 root root 73265692 Feb 5 13:32 mongodb-linux-x86_64-4.0.6.tgz
[root@localhost mongodb]# cd mongodb-linux-x86_64-4.0.6/
[root@localhost mongodb-linux-x86_64-4.0.6]# pwd
/software/mongodb/mongodb-linux-x86_64-4.0.6
[root@localhost mongodb-linux-x86_64-4.0.6]# vim /etc/profile
[root@localhost mongodb-linux-x86_64-4.0.6]# cat /etc/profile
配置好的环境变量
# mongodb
export MONGODB_HOME=/software/mongodb/mongodb-linux-x86_64-4.0.6
export PATH=$PATH:$MONGODB_HOME/bin
重启环境变量
[root@localhost mongodb-linux-x86_64-4.0.6]# source /etc/profile
创建db和logs目录
[root@localhost mongodb-linux-x86_64-4.0.6]# mkdir -p data/db
[root@localhost mongodb-linux-x86_64-4.0.6]# mkdir -p data/logs
[root@localhost mongodb-linux-x86_64-4.0.6]# ll
total 116
drwxr-xr-x. 2 root root 4096 Mar 12 22:42 bin
drwxr-xr-x. 4 root root 26 Mar 12 22:47 data
-rw-r--r--. 1 root root 30608 Feb 5 13:08 LICENSE-Community.txt
-rw-r--r--. 1 root root 16726 Feb 5 13:08 MPL-2
-rw-r--r--. 1 root root 2601 Feb 5 13:08 README
-rw-r--r--. 1 root root 57190 Feb 5 13:08 THIRD-PARTY-NOTICES
[root@localhost mongodb-linux-x86_64-4.0.6]# tree data/ -L 1
data/
├── db
└── logs
2 directories, 0 files
创建日志文件
[root@localhost mongodb-linux-x86_64-4.0.6]# touch data/logs/mongodb.log
[root@localhost mongodb-linux-x86_64-4.0.6]# tree data/ -L 2
data/
├── db
└── logs
└── mongodb.log
2 directories, 1 file
创建配置文件
[root@localhost mongodb-linux-x86_64-4.0.6]# vim mongodb.conf
[root@localhost mongodb-linux-x86_64-4.0.6]# cat mongodb.conf
dbpath=/software/mongodb/mongodb-linux-x86_64-4.0.6/data/db
logpath=/software/mongodb/mongodb-linux-x86_64-4.0.6/data/logs/mongodb.log
port=27017
fork=true
logappend=true
bind_ip=0.0.0.0
启动mongodb
[root@localhost mongodb-linux-x86_64-4.0.6]# ./bin/mongod --config mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 10799
child process started successfully, parent exiting
[root@localhost mongodb-linux-x86_64-4.0.6]# ps -ef | grep mongod
root 10799 1 10 22:54 ? 00:00:01 ./bin/mongod --config mongodb.conf
root 10846 2752 0 22:54 pts/0 00:00:00 grep --color=auto mongod
拾柒……