Mongodb帶使用者驗證的Replica Set配置

來源:互聯網
上載者:User

標籤:

Replica Set配置好之後,發現啟用auth選項之後就不能同步了,應該是身分識別驗證的部分漏掉了哪些步驟。

後來發現是少了keyFile的配置,於是就產生一個。

keyFile其實沒有什麼神秘的,只要

  1. 是base64字元集中的字元,
  2. 長度在6~1024之間就可以了,
  3. 空白字元會被MongoDB刪除掉,
  4. 每一個節點都要使用相同的keyFile檔案
  5. linux環境需要修改keyFile許可權(chmod 600 mongodb-keyfile)。

由於MongoDB官方文檔的樣本是使用openssl產生的,base64編碼的字串,可能會給人造成誤解,keyFile一定要使用openssl產生,一定要使用Base64編碼,其實不是這樣的,

可以不用openssl產生,不需要Base64編碼,只要長度在6~1024之間,Base64字元集中的字元就OK,用您最方便的工具整一個或者隨便輸入一些字元都是可以的。

看一下官方的原文(附後)就很容易發現這一點。

Base64字元集如下:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

 

修改後的配置資訊如下:

1 replSet = rs012 auth = true3 port = 270174 bind_ip = localhost5 journal = true6 dbpath = e:\data\db7 logpath = e:\data\log\mongo.log8 keyFile = D:\mongodb\key

 

參考:

1. Generate a Key File: http://docs.mongodb.org/manual/tutorial/generate-key-file/

2. openssl下載(Windows):http://www.openssl.org/related/binaries.html

Mongodb帶使用者驗證的Replica Set配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.