环境
CentOS7
mongodb3.2
绿色版使用,推荐使用绿色版
1.下载mongodb
参考网址【https://www.mongodb.org/downloads#production】
解压到相应目录
2.配置mongodb文件,这是3.2.4版本的配置文件
# mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # where to write logging data. systemLog: destination: file logAppend: true path: /home/mongodb57020/log/mongod.log # Where and how to store data. storage: dbPath: /home/mongodb57020/data journal: enabled: true # engine: # mmapv1: # wiredTiger: # how the process runs processManagement: fork: true # fork and run in background pidFilePath: /home/mongodb57020/mongod.pid # location of pidfile # network interfaces net: port: 27020 # bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces. # make lower version driver can login #setParameter: # authenticationMechanisms: MONGODB-CR #security: # authorization: enabled #operationProfiling: #replication: #sharding: ## Enterprise-Only Options #auditLog: #snmp:
3.启动mongodb
/home/mongodb57020/mongodb-linux-x86_64-rhel62-3.2.4/bin/mongod -f /home/mongodb57020/mongod.conf
4.停止mongodb
/home/mongodb57020/mongodb-linux-x86_64-rhel62-3.2.4/bin/mongod -f /home/mongodb57020/mongod.conf --shutdown
安装版使用
1.安装mongodb
参考以下网址进行配置:https://docs.mongodb.org/master/tutorial/install-mongodb-on-red-hat/
新建文件【/etc/yum.repos.d/mongodb-org-3.2.repo】
内容为;
[mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=0 enabled=1
2.准备安装mongodb
yum install mongodb-org
3.关闭SELINUX
修改【/etc/selinux/config】的配置,重启服务
4.mongo相关配置
配置文件放在【/etc/mongod.conf】,可以修改相关配置
5.启动/停止/重启mongo
service mongod start service mongod stop service mongod restart
6.开机自启动
chkconfig mongod on
7.卸载mongdb,需要遵照以下步骤(需要备份,请先备份数据库)
Stop MongoDB
Remove Packages
Remove Data Directories
service mongod stop yum erase $(rpm -qa | grep mongodb-org) rm -r /var/log/mongodb rm -r /var/lib/mongo