1. 程式人生 > 其它 >(1.2)Mongodb安裝

(1.2)Mongodb安裝

【1】下載安裝

(1.1)下載

官網:https://www.mongodb.com/try/download/community

  

 

 

指令碼下載:

mkdir -p /data/dba/software
cd /data/dba/software/
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.13.tgz
tar -zxf mongodb-linux-x86_64-rhel70-4.4.13.tgz
mv mongodb-linux-x86_64-rhel70-4.4.13 /usr/local/
ln -s /usr/local/mongodb-linux-x86_64-rhel70-4.4.13 /usr/local/mongodb
echo "PATH=${PATH}:/usr/local/mongodb/bin" >> /etc/profile && source /etc/profile

【1.2】安裝

# 構建資料與日誌目錄
mkdir
-p /data/mongodb/ mkdir -p /data/mongodb/{data,logs} useradd mongodb

# 配置檔案
cat <<eof >>/data/mongodb/mongodb.conf dbpath=/mongodb/data logpath=/mongodb/logs/mongodb.log port=27017 fork=true #是否後臺守護程序 auth=true #noauth=true #verbose=true #列印更完整的詳細資訊 #vvvv=true journal=true #使用之後備份容災比較容易保障 maxConns
=500 #最大連線數 logappend=true #是否開啟日誌追加 directoryperdb=true #資料目錄儲存模式,是不是每個資料庫一個目錄 bind_ip=0.0.0.0 pidfilepath=/data/mongodb/mongo.pid #程序檔案 #cpu=true #為真的話,每4S報告一次CPU的使用情況,資訊打出到日誌 #nohttpinterface=false #是否開啟http網頁管理介面 #notablescan=false #不禁止表掃描 #profile=0 #資料庫效能分析的 #slowms=200 #慢查詢時間200ms #quiet=true #安靜的日誌輸出 #syncdelay
=60 #重新整理日誌的頻率 #bind_ip=127.0.0.1,192.168.239.131 eof

# 目錄許可權
chown -R mongodb:mongodb /data/mongodb
chmod -R 775 /data/mongodb
# OS優化-檔案修飾符,需要重啟,ulimit -a 核驗
cat <<eof >>/etc/security/limits.conf
mongodb    hard nofile    65535
mongodb    soft nofile    65535
mongodb    hard nproc     65535
mongodb    soft nproc     65535
eof
# 臨時生效請使用 ulimit -n 65535