跳转至

CentOS 7 安装 mongodb


2016-11-04 by dongnan

准备工作

创建 repo 文件

cat  /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=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

安装

yum install -y mongodb-org

配置

监听IP地址,例如:监听 10.0.100.19,其它保持默认配置即可。

grep 'bindIp' /etc/mongod.conf
  bindIp: 10.0.100.19  # Listen to local interface only, comment to listen on all interfaces.

启动

/etc/init.d/mongod start
chkconfig mongod on

验证

日志

head -n2 /var/log/mongodb/mongod.log
2016-10-18T17:41:49.561+0800 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-10-18T17:41:49.575+0800 I CONTROL  [initandlisten] MongoDB starting : pid=25428 port=27017 dbpath=/var/lib/mongo 64-bit host=img01.xyc.ltd

端口

lsof -i :27017
COMMAND   PID   USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
mongod  25428 mongod    6u  IPv4 35829701      0t0  TCP localhost:27017 (LISTEN)

参考

install-mongodb-on-red-hat

欢迎关注微信公众号: 运维录

Back to top