centos7 手動安裝mongodb

centos7 手動安裝mongodblinux

原創 2017年04月26日 14:19:05sql

標籤:mongodb

centos /shell

mongodb /數據庫

服務器vim

1190centos

一、下載mongoDB的安裝包:mongodb-linux-x86_64-rhel70-3.4.4;
二、上傳安裝包到服務器/data目錄下;
三、解壓安裝包瀏覽器

[plain] view plain copy服務器

tar -zvxf mongodb-linux-x86_64-rhel70-3.4.4.tgz  併發

四、將解壓後的文件夾重命名

[plain] view plain copy

mv mongodb-linux-x86_64-rhel70-3.4.4 mongodb  

五、進入到mongodb文件夾中

[plain] view plain copy

cd mongodb  

六、新建logs和db兩個目錄

[plain] view plain copy

mkdir logs  

[plain] view plain copy

mkdir db  

七、進入到bin目錄中

[plain] view plain copy

cd bin  

八、建立配置文件mongodb.conf

[plain] view plain copy

vim mongodb.conf  

九、在 mongodb.conf 寫入以下內容:
 

 

# mongod.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: /data/mongolog/mongod.log

 

# Where and how to store data.

storage:

  dbPath: /data/mongodata

  journal:

    enabled: false

#  engine:

#  mmapv1:

#  wiredTiger:

 

# how the process runs

processManagement:

  fork: true  # fork and run in background

  pidFilePath: /data/mongodb/mongod.pid  # location of pidfile

  timeZoneInfo: /usr/share/zoneinfo

 

# network interfaces

net:

  port: 27017

  bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.

 

#security:

 

# authorization: enabled

 

#operationProfiling:

 

#replication:

 

#sharding:

 

## Enterprise-Only Options

 

#auditLog:

 

#snmp:

 

 


附:參數解釋: 
--dbpath 數據庫路徑(數據文件)
--logpath 日誌文件路徑
--master 指定爲主機器
--slave 指定爲從機器
--source 指定主機器的IP地址
--pologSize 指定日誌文件大小不超過64M.由於resync是很是操做量大且耗時,最好經過設置一個足夠大的oplogSize來避免resync(默認的 oplog大小是空閒磁盤大小的5%)。
--logappend 日誌文件末尾添加,即便用追加的方式寫日誌
--journal 啓用日誌
--port 啓用端口號
--fork 在後臺運行
--only 指定只複製哪個數據庫
--slavedelay 指從複製檢測的時間間隔
--auth 是否須要驗證權限登陸(用戶名和密碼)
--syncdelay 數據寫入硬盤的時間(秒),0是不等待,直接寫入
--notablescan 不容許表掃描
--maxConns 最大的併發鏈接數,默認2000  
--pidfilepath 指定進程文件,不指定則不產生進程文件
--bind_ip 綁定IP,綁定後只能綁定的IP訪問服務


十、防火牆開通mongodb的訪問端口

[plain] view plain copy

iptables -I INPUT -p tcp --dport 27017 -j ACCEPT  

十一、啓動 mongodb 服務

[sql] view plain copy

./mongod --config mongodb.conf  

十二、查看 mongodb 進程

[plain] view plain copy

ps aux |grep mongodb  

1三、查看 mongodb 服務的運行日誌

[plain] view plain copy

tail -f /usr/local/mongodb/logs/mongodb.log  

1四、將 mongodb 服務加入到自啓動文件中

[plain] view plain copy

vi /etc/rc.local  

    在文件末尾追加以下命令:

[plain] view plain copy

/usr/local/mongodb/bin/mongod --config mongodb.conf  

1五、在/usr/local/mongodb/bin目錄下輸入./mongo即打開一個mongodb的shell客戶端
    輸入db.version();查看mongodb的版本

    在瀏覽器中輸入IP:27017,如:http://192.168.122.205:27017,能夠查看mongodb是否啓動成功。

相關文章
相關標籤/搜索