码迷,mamicode.com
首页 > 数据库 > 详细

mongodb入门安装

时间:2015-08-06 18:20:17      阅读:218      评论:0      收藏:0      [点我收藏+]

标签: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



版权声明:本文为博主原创文章,未经博主允许不得转载。

mongodb入门安装

标签:mongodb安装   mongodb源码安装   

原文地址:http://blog.csdn.net/yangzhawen/article/details/47320533

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!