mongodb的安裝和配置

來源:互聯網
上載者:User

標籤:密碼   建立資料庫   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的安裝和配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.