標籤:密碼 建立資料庫 accept 驗證 command -- warnings fas nec
1.下載安裝
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz
tar zxf mongodb-linux-x86_64-3.0.6.tgz
mv mongodb-linux-x86_64-3.0.6 /usr/local/mongodb
2.建立資料目錄,必須建立,不然啟動失敗。
mkdir -p /data/db
啟動:
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/server/mongodb/data --logpath=/usr/local/server/mongodb/logs --logappend --port=27017 --fork
3.參數解釋
--dbpath 資料庫路徑(資料檔案)--logpath 記錄檔路徑--master 指定為主機器--slave 指定為從機器--source 指定主機器的IP地址--logappend 記錄檔末尾添加--port 啟用連接埠號碼--fork 在後台運行--only 指定只複製哪一個資料庫--slavedelay 指從複製檢測的時間間隔--auth 是否需要驗證許可權登入(使用者名稱和密碼)
4.進入資料庫的CLI管理介面
/usr/local/mongodb/bin/mongo
MongoDB shell version: 3.0.6
connecting to: test
>2+2
4
若資料庫出現如不能連上,則是一個data目錄下的mongod.lock檔案的問題,可以用如下的修複的命令,mongod --repair查看logstail -f logs
2017-06-11T00:12:09.875+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:54624 #13 (1 connection now open)
2017-06-11T00:12:09.880+0800 I ACCESS [conn13] Unauthorized not authorized on admin to execute command { getLog: "startupWarnings" }
2017-06-11T00:12:28.804+0800 I NETWORK [initandlisten] connection accepted from 10.10.2.13:63225 #14 (2 connections now open)
2017-06-11T00:12:28.805+0800 I NETWORK [initandlisten] connection accepted from 10.10.2.13:63227 #15 (3 connections now open)
2017-06-11T00:12:28.805+0800 I NETWORK [initandlisten] connection accepted from 10.10.2.13:63226 #16 (4 connections now open)
2017-06-11T00:12:28.808+0800 I NETWORK [conn14] end connection 10.10.2.13:63225 (3 connections now open)
2017-06-11T00:12:28.831+0800 I NETWORK [conn15] end connection 10.10.2.13:63227 (2 connections now open)
2017-06-11T00:12:29.717+0800 I NETWORK [conn16] end connection 10.10.2.13:63226 (1 connection now open)
(1 connection now open)#表明一個來自原生串連
5.建立資料庫
> use aaa #建立
switched to db aaa
> db #查看
aaa
6.MongoDB 備份(mongodump)與恢複(mongorestore)
mongodb的安裝和配置