mongodb入門安裝,mongodb入門
---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]
>
/******************解決辦法
不重啟伺服器的情況下解決辦法,在Linux下執行:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
伺服器重啟後立即生效辦法:
# 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
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。