技術工具類: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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章