MongoDB複本集配置系列一:安裝MongoDB

來源:互聯網
上載者:User

標籤:

1:下載MongoDB 2.6版本

https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.9.zip

 

2:解壓

tar -zxvf mongodb-linux-x86_64-2.6.9.zip
mv mongodb-linux-x86_64-2.6.9 mongodb

  

 

3:在mongodb目錄建立 data目錄和 log 目錄 和conf設定檔

同時保證data和log目錄有可讀寫權限

 

4:編輯設定檔 vi mongo.conf

#日誌目錄logpath=/root/software/mongodb/log/mongod#資料目錄dbpath=/root/software/mongodb/data#日誌以追加方式添加logappend=true# 開啟後台進程運行fork = true#連接埠port = 27017

  

5:用該設定檔啟動mongod

./bin/mongod --config mongo.conf

 

6:串連mongo即可

 

7:添加使用者名稱和密碼

db.addUser("gechong" , "password")

認證使用者:

db.auth("gechong" , "password")1

查看使用者

 db.auth("gechong" , "password")1

給test庫添加一個有讀寫權限的使用者

> use testswitched to db test >db.addUser("ge" , "password")WARNING: The ‘addUser‘ shell helper is DEPRECATED. Please use ‘createUser‘ insteadSuccessfully added user: { "user" : "ge", "roles" : [ "dbOwner" ] }

  

給test庫添加一個唯讀許可權的客戶

db.addUser("geread" , "password" ,true)

  

刪除無效使用者

db.system.users.remove({user:"geread"})

 

下一篇部落格:http://www.cnblogs.com/xiaoit/p/4478951.html

 

MongoDB複本集配置系列一:安裝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.