1. 程式人生 > 實用技巧 >mongodb 3.4單例項安裝與備

mongodb 3.4單例項安裝與備

一、mongodb下載

官方下載地址:https://www.mongodb.com/download-center#community

wKiom1lsJpnSu9JzAAE4f0an-f0304.png

沒有yueyu的使用者可能下載比較緩慢,請自行解決

二、環境配置

測試系統centos6.8 ip地址:192.168.1.197

1、關閉SELinux

vim/etc/selinux/config

SELINUX=disabled


setenforce0

2.關閉防火牆

service iptables stop

3、增加使用者和組

groupadd mongodb && useradd -g mongodb mongodb

4、上傳二進位制包到/opt下解壓並授權

cd /opt && tar -xf mongodb-linux-x86_64-rhel62-3.4.5.tgz

5、建立軟連線

ln -s /opt/mongodb-linux-x86_64-rhel62-3.4.5 /usr/local/mongodb

6、更改屬性

chown -R mongodb:mongodb /opt/mongodb-linux-x86_64-rhel62-3.4.5

chown -R mongodb:mongodb /usr/local/mongodb

7、配置環境變數


echo 'PATH=/usr/local/mongodb/bin:$PATH' >>/etc/profile

source /etc/profile

8、建立相關目錄

mkdir -p /data/mongo/{db,log,tmp}

mkdir -p /etc/mongodb

9、建立mongodb配置檔案

vim /etc/mongodb/mongo.conf


storage:

dbPath: /data/mongo/db

journal:

enabled: true

engine: wiredTiger

systemLog:

destination: file

logAppend: true

path: /data/mongo/log/mongod.log

processManagement:

fork: true # fork and run in background

pidFilePath: /data/mongo/tmp/mongod.pid

net:

port: 27017

bindIp: 192.168.1.197,127.0.0.1

security:

authorization: enabled

10、授權

chown -R mongodb:mongodb /data/mongo

chown -R mongodb:mongodb /etc/mongodb

11、啟動mongodb

su - mongodb

mongod --config /etc/mongodb/mongo.conf

#ps aux |grep mongo

mongodb 1649 0.6 1.1 1015552 46780 ? SLl 08:45 0:55 /usr/local/mongodb/bin/mongod --config /etc/mongodb/mongo.conf

mongodb 30100 0.0 0.0 103256 848 pts/0 S+ 11:08 0:00 grep mongo


轉載於:https://blog.51cto.com/412166174/1948147