建立mongodb分片叢集 + keyFile認證
1. 伺服器節點資訊【三台伺服器】
x.x.x.159、 x.x.x..160、 x.x.x..161
2. 伺服器系統
linux x86_64 GNU/Linux 或者 centos7 或者 redhat
3. mongodb版本
mongodb v4.2.5
下載下傳位址:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.5.tgz
1. 三個 分片 複制集合
shard1(x.x.x.159:27017、 x.x.x.160:27017、 x.x.x.161:27017)
shard2(x.x.x.159:27018、 x.x.x.160:27018、 x.x.x.161:27018)
shard3(x.x.x.159:27019、 x.x.x.160:27019、 x.x.x.161:27019)
2. 一個 config 複制集合
(x.x.x.159:28018、 x.x.x.160:28018、 x.x.x.161:28018)
3. 一個 mongos 節點
(x.x.x.159:27000)
1. vim /etc/profile
2. 檔案末尾追加: export PATH=$PATH:/opt/mongodb/bin
3. 加載檔案立刻生效: source /etc/profile
1. 分别在三台伺服器(x.x.x.159、x.x.x.160、 x.x.x.161)節點 執行如下指令
2. mongodb分片叢集 配置檔案 目錄
3. 分片日志目錄
4. 建立叢集安全認證機制KeyFile
Notice: keyfile 必須滿足以下條件:
1) 至少6個字元,小于1024位元組。
2) 認證的時候不考慮檔案中的空白字元。
3) 連接配接副本內建員的KeyFile和啟動mongos程序的 KeyFile檔案内容必須一緻。
4) 必須是base64編碼,但不能有等号。
5) 檔案權限必須是 600(chmod 600),不能配置設定任何權限給group成員和其他成員。
5. 建立分片 資料存儲目錄
6. 建立分片配置檔案
1. 在其中任意一台節點伺服器登入 本人使用 x.x.x.159節點
2. mongo -port 27017 【登入】
3. 進入mongodb指令輸入終端 輸入指令如下
4. 找到mongodb自己選舉出來的 主庫 輸入指令:
2. 建立 config 資料存儲 目錄
3. 建立 config 日志 目錄
4. 建立 config複制集 配置檔案
5. 啟動config節點複制集
6. 登入config節點
7.初始化 config節點
8. 建立認證使用者
9. 開啟config複制集 認證
關閉 config複制集
在配置檔案追加
vim /opt/mongodb4.2/conf/mongodb-cfg.conf
啟動 config複制集
1. 在 x.x.x.159 伺服器上搭建用戶端
2. 建立mongos 日志目錄
3. 建立mongos 配置檔案
vim /opt/mongodb4.2/conf/mongos.conf
4. 啟動mongos
5. 登入并初始化 mongos
6. 測試是否搭建成功
1. 分片指令
2.config 複制集指令
3. mongos 指令
https://my.oschina.net/u/563789/blog/3050068
https://blog.csdn.net/qq_24434491/article/details/102907486
https://blog.csdn.net/lezeqe/article/details/90518179
https://blog.csdn.net/tototuzuoquan/article/details/78295040
https://www.freesion.com/article/6886370039/#8mongo_247
https://www.cnblogs.com/shaosks/p/5775757.html
https://www.cnblogs.com/wxmdevelop/p/7341292.html