1.准备环境
[admin@FYProject /usr/local]$ sudo mkdir mongodb
[admin@FYProject /usr/local]$ cd mongodb/
2.下载mongodb包
[admin@FYProject /usr/local/mongodb]$ sudo wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.0.tgz
2.1 准备环境
[admin@FYProject /usr/local/mongodb]$ sudo tar -zxvf mongodb-linux-x86_64-4.0.0.tgz
[admin@FYProject /usr/local/mongodb]$ sudo mv mongodb-linux-x86_64-4.0.0 mongodbserver
[admin@FYProject /usr/local/mongodb/mongodbserver]$ sudo mkdir data
[admin@FYProject /usr/local/mongodb/mongodbserver]$ sudo mkdir log
[admin@FYProject /usr/local/mongodb/mongodbserver]$ sudo mkdir etc
[admin@FYProject /usr/local/mongodb/mongodbserver]$ cd etc/
[admin@FYProject /usr/local/mongodb/mongodbserver/etc]$ sudo vim mongodb.conf
dbpath=/usr/local/mongodb/mongodbserver/data
logpath=/usr/local/mongodb/mongodbserver/log/mongodb.log
port=27017
fork=true
journal=false
storageEngine=mmapv1
3.启动
[admin@FYProject /usr/local/mongodb/mongodbserver/etc]$ cd ../bin/
[admin@FYProject /usr/local/mongodb/mongodbserver/bin]$ sudo ./mongod --config /usr/local/mongodb/mongodbserver/etc/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 14232
child process started successfully, parent exiting
[admin@FYProject /usr/local/mongodb/mongodbserver/bin]$ sudo netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 850/zabbix_agentd
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 14232/./mongod
tcp 0 0 0.0.0.0:19826 0.0.0.0:* LISTEN 3181/sshd
tcp6 0 0 :::5666 :::* LISTEN 897/xinetd
tcp6 0 0 :::10050 :::* LISTEN 850/zabbix_agentd
tcp6 0 0 :::33080 :::* LISTEN 1624/mysqld
3. 调优
[admin@FYProject /usr/local/mongodb/bin]$ sudo cp ./* /usr/bin/
4.启动 关闭
sudo ./mongod --config /usr/local/mongodb/mongodbserver/etc/mongodb.conf
sudo ./mongod --config /usr/local/mongodb/mongodbserver/etc/mongodb.conf --shutdown
5.警告解决
解决:
sudo echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
sudo echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
第3个waring
vim /etc/security/limits.conf
添加一下几行
mongod soft nofile 64000
mongod hard nofile 64000
mongod soft nproc 32000
mongod hard nproc 32000