---1.在proc中关闭NUMA
rpm -qa | grep numactl
yum install -y numactl
# echo 0 > /proc/sys/vm/zone_reclaim_mode
# sysctl -w vm.zone_reclaim_mode=0
---2.改动最大连接数
#vi /etc/security/limits.conf
* soft nofile 25000
* hard nofile 25000
---3.关闭防火墙
chkconfig --level 123456 iptables off
service iptables stop
---4.改动hosts
vi /etc/hosts
---5.安装mongodb
--安装openssl
yum install -y openssl-devel openssl
tar xvzf mongodb-linux-x86_64-rhel62-3.0.5.gz
mkdir -p /data/mongodb
mkdir -p /data/mongodb/db
mkdir -p /data/mongodb/logs
mkdir -p /data/mongodb/apps
mkdir -p /data/mongodb/{db,logs,apps}
touch /data/mongodb/logs/mongodb.log
chmod -R 777 /data/mongodb/logs/mongodb.log
mv mongodb-linux-x86_64-rhel62-3.0.5 /data/mongodb/apps/mongodb
# cd /data/mongodb/apps/mongodb/bin
# vi /data/mongodb/apps/mongodb/bin/mongodb.conf
port=27017 #端口
dbpath= /data/mongodb/db #数据文件存放文件夹
logpath= /data/mongodb/logs/mongodb.log #日志文件存放文件夹
logappend=true #使用追加的方式写日志
fork=true #以守护程序的方式启用,即在后台执行
maxConns=5000 #最大同一时候连接数 默认2000
bind_ip=127.0.0.1,192.168.1.25 #仅仅同意通过局域网IP192.168.1.25及本机訪问
noauth=true #不启用验证
nohttpinterface=true
rest=false
syncdelay=60
启动mongodb
# numactl --interleave=all /data/mongodb/apps/mongodb/bin/mongod --config /data/mongodb/apps/mongodb/bin/mongodb.conf
或
# numactl --interleave=all /data/mongodb/apps/mongodb/bin/mongod -f /data/mongodb/apps/mongodb/bin/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 3765
child process started successfully, parent exiting
---mongodb连接
# /data/mongodb/apps/mongodb/bin/mongo
MongoDB shell version: 3.0.5
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions?
Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten]
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten]
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten]
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-08-03T12:39:33.996+0800 I CONTROL [initandlisten]
>
/******************解决的方法
不重新启动server的情况下解决的方法,在Linux下运行:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
server重新启动后马上生效办法:
# vi /etc/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
********************/
----正常停止方法:
# ps aux | grep mongod
root 3765 1.9 0.1 500832 58224 ?
Sl 12:38 0:02 /data/mongodb/apps/mongodb/bin/mongod --config /data/mongodb/apps/mongodb/bin/mongodb.conf
# kill -2 3765
或
# /data/mongodb/apps/mongodb/bin/mongo -port 27107
> use admin
> db.shutdownServer();
----开机自己主动启动mongodb
# vi /etc/rc.d/rc.local
rm -rf /data/mongodb/db/mongod.lock
numactl --interleave=all /data/mongodb/apps/mongodb/bin/mongod --config /data/mongodb/apps/mongodb/bin/mongodb.conf
说明:启动时必须加numactl --interleave=all