本次安装mongodb使用yum.repo方式。详细过程请参考,也列出一些安装过程中的错误,欢迎指正。
mongodb版本:3.0
先在linux下cd 到 /etc/yum.repos.d/
新建脚本文件mongodb-org-3.0.repo:
[mongodb-org-3.0]
name=MongoDB 3.0 Repository
baseurl=https://repo.mongodb.org/yum/redhat/6/mongodb-org/3.0/x86_64/
gpgcheck=
enabled=
:wq保存后,清理yum资源
yum clean all
然后搜索下源
yum search mongodb
以搜索出来的名称为准。
上图search后出来的结果是mongodb-org.x86_64,然后mongo安装即可
yum install mongodb-org.x86_64
注:在安装过程中,如果遇到下面的错误:
[root@localhost yum.repos.d]# yum install mongodb
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* epel: mirrors.aliyun.com
* extras: mirror.neu.edu.cn
* updates: mirrors.btte.net
Resolving Dependencies
--> Running transaction check
---> Package mongodb.x86_64 :2.4.-.el6 will be installed
--> Processing Conflict: mongodb-org-3.0.-.el6.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-mongos-3.0.-.el6.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-server-3.0.-.el6.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-shell-3.0.-.el6.x86_64 conflicts mongodb
--> Processing Conflict: mongodb-org-tools-3.0.-.el6.x86_64 conflicts mongodb
--> Finished Dependency Resolution
Error: mongodb-org-mongos conflicts with mongodb-2.4.-.el6.x86_64
Error: mongodb-org-server conflicts with mongodb-2.4.-.el6.x86_64
Error: mongodb-org-tools conflicts with mongodb-2.4.-.el6.x86_64
Error: mongodb-org-shell conflicts with mongodb-2.4.-.el6.x86_64
Error: mongodb-org conflicts with mongodb-2.4.-.el6.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
解决方法如下:
yum install mongodb-org.x86_64 --skip-broken
跳过依赖关系就可以安装了。
mongod启动:
service mongod start
关闭(查找到进程然后kill掉):
ps -ef|grep mongod
kill xx pid
如果存在类似下面的一些警告:
I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
I CONTROL [initandlisten] ** We suggest setting it to 'never'
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
I CONTROL [initandlisten] ** We suggest setting it to 'never'
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
请参考下面资料:http://bbs.51cto.com/thread-1146184-1.html
如果有遇到这种错误:
--08T11::14.789+ I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to processes, files. Number of processes should be at least : 0.5 times number of files.
可以尝试:
cd /etc/security/limits.d
vim -nproc.conf
* soft nproc 32000
root soft nproc unlimited
将第一行改成提示的值(此处的值:Number of processes should be at least 32000)
关闭mongodb:
mongod -f /etc/mongod.conf --shutdown
查看mongo状态:
service mongod status
启动mongo:
mongod -f /etc/mongod.conf
查看运行状态:
ps aux|grep mongod
netstat -aux|grep mongod