技术工具类:RPM方式在Linux系统安装 MongoDB数据库

本Linux系统为 centos 7.x

1、去官网下载 rpm资源文件

https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/RPMS/mongodb-org-server-4.0.18-1.el7.x86_64.rpm
https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/RPMS/mongodb-org-shell-4.0.18-1.el7.x86_64.rpm

2、安装命令

rpm -ivh mongodb-org-server-4.0.18-1.el7.x86_64.rpm
rpm -ivh mongodb-org-shell-4.0.18-1.el7.x86_64.rpm

3、查看或修改配置

安装成功后,会产生一个配置文件:/etc/monogd.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: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

配置文件为 ymal 格式:

systemLog.path :mongoDB 的系统日志的路径
storage.dbPath  :mongoDB 数据文件存放路径
processManagement.pidFilePath  : mongoDB 运行时进程文件存放路径
net.port  : mongodDB 网络端口号 
net.bindIp  : mongoDB 绑定的 ip 地址,默认为127.0.0.1 表示只允许本地连接,无法远程连接;修改成0.0.0.0则表示允许其他服务器远程连接到该mongodb服务

上述配置均可按需要做修改。

4、启动与停止

启动命令:

service mongod start
或
systemctl start mongod
或
/usr/bin/mongod -f /etc/mongod.conf

停止命令:

systemctl stop mongod
或
mongod --shutdown
或
ps -ef|grep mongo  查到到进程直接 kill -9

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值