通過Ops Manager安裝管理mongodb-3.4集群


node1

Ops Manager,mongodb,agent

node2 mongodb,agent
node3 mongodb,agent

參考文檔

NUMA Settings

sysctl -w vm.zone_reclaim_mode=0

NTP Settings

yum install -y ntp
/etc/init.d/ntpd start

Turn off Atime

vim /etc/fstab
/dev/mapper/VolGroup-lv_data /data                       ext4    defaults,noatime,nodiratime        1 1

ulimt settings

ulimit -a
 
修改/etc/security/limits.conf
    mongod soft nproc 65535
    mongod hard nproc 65535

Disable Transparent Huge Pages

通過啟動腳本可以在每次啟動時關閉THP

vim /etc/init.d/disable-transparent-hugepages
#以下為腳本內容
 
#!/bin/bash
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO
 
case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi
 
    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag
 
    re='^[0-1]+$'
    if [[ $(cat ${thp_path}/khugepaged/defrag) =~ $re ]]
    then
      # RHEL 7
      echo 0  > ${thp_path}/khugepaged/defrag
    else
      # RHEL 6
      echo 'no' > ${thp_path}/khugepaged/defrag
    fi
 
    unset re
    unset thp_path
    ;;
esac

執行腳本

chmod +x /etc/init.d/disable-transparent-hugepages
chkconfig --add disable-transparent-hugepages
/etc/init.d/disable-transparent-hugepages start

檢查是否生效

cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag

#有以下輸出表示正確
always madvise [never]

Install the Ops Manager Application Database

Ops Manager需要先安裝mongodb,創建其數據庫副本集后才能部署安裝。

創建yum repo

在每台節點上執行以下命令創建官方3.4版本的repo文件

官方的yum源比較慢,推薦使用阿里雲yum源

#官方repo
cat > /etc/yum.repos.d/mongodb-org-3.4.repo << EOF
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
EOF
 
  
# 阿里雲repo
cat > /etc/yum.repos.d/mongodb-org-3.4.repo << EOF
[mongodb-org-3.4]
name=MongoDB Repository
#baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
baseurl=https://mirrors.aliyun.com/mongodb/yum/redhat/\$releasever/mongodb-org/3.4/x86_64/
gpgcheck=0
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
EOF

安裝mongod

在每台節點上執行以下步驟

yum install -y mongodb-org
chkconfig mongod on

修改配置

vim /etc/mongod.conf
#修改為數據分區,需創建該目錄,並確保mongod用戶可讀寫
# Where and how to store data.
storage:
  dbPath: /data/mongo  
  journal:
    enabled: true
 
#默認監聽本地lo,注釋掉
# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.

啟動服務

service mongod start

部署Ops Manager副本集

參考 https://docs.mongodb.com/manual/tutorial/deploy-replica-set/

通過修改配置文件的方式創建Ops Manager所需副本集。

注:也可以通過命令行方式指定副本集啟動。修改配置文件的方式便於通過init script管理。

在所有節點上修改配置

vim mongod.conf
#添加以下內容
replication:
  replSetName: rs_ops_manager
 
#重啟生效
service mongod restart

在任一節點上執行mongo shell,添加副本集節點,此處使用node1節點

mongo --host localhost --port 27017

#Initiate the replica set
rs.initiate()
#display the replica set configuration object
rs.conf()
#Add the remaining members to the replica set
rs.add("node2_fqdn")
rs.add("node3_fqdn")
#Check the status of the replica set
rs.status()

Install Ops Manager

#下載安裝
wget -c https://downloads.mongodb.com/on-prem-mms/rpm/mongodb-mms-3.4.2.389-1.x86_64.rpm
rpm -ivh mongodb-mms-<version>.x86_64.rpm

Configure the Ops Manager connection to the Ops Manager Application Database

vim /opt/mongodb/mms/conf/conf-mms.properties
#設置mongo.mongoUri
mongo.mongoUri=mongodb://node1:27017,node2:27017,node3:27017/?replicaSet=rs_ops_manager
/etc/init.d/mongodb-mms start 啟動

 

 

Open the Ops Manager home page and register the first user.

  • http://<host>:8080
  • Click the Register link and follow the prompts to register the first user and create the first group. The first user is automatically assigned the Global Owner role.

 

配置本地二進制包進行安裝MongoDB

參考:https://docs.opsmanager.mongodb.com/v3.4/tutorial/configure-local-mode/

Configure Local Mode for Ops Manager Servers without Internet Access(Optional)

Set Ops Manager to Local Mode.

  • Click Admin in the upper right corner to open system administration.
  • From the General tab, click Ops Manager Config.
  • Click the Miscellaneous button at the top of the page.
  • For Version Manifest Source, select Local.
  • Note the directory specified in Versions Directory. This is the directory on your Ops Manager servers where you will store the MongoDB binaries.
  • For Backup Version Auto Download, select false.

Download the required MongoDB archives

wget -c http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.2.tgz

Populate all Ops Manager servers with the necessary MongoDB binaries and archives

tar xzf mongodb-linux-x86_64-rhel62-3.4.2.tgz -C /opt/mongodb/mms/mongodb-releases/
chown -R mongodb-mms.mongodb-mms /opt/mongodb/mms/mongodb-releases/mongodb-linux-x86_64-rhel62-3.4.2/
 chown  -R mongodb-mms:mongodb-mms  /opt/mongodb/mms/mongodb-releases
 chmod  -R 640  /opt/mongodb/mms/mongodb-releases

Download the version manifest for Ops Manager.

Paste the contents the version manifest into the Ops Manager application on each Ops Manager server.

  • In Ops Manager, click Admin in the upper right corner to open system administration.
  • Click the General tab.
  • Click Version Manifest.
  • Click the Update the MongoDB Version Manifest button.
  • Paste the version manifest.

For each group, specify which versions are available for download by Automation Agents.

  • In Ops Manager, click Back To Group in the upper left to exit system administration.
  • Click the Group link at the top of the page and select the desired group.
  • Click Deployment, then the More drop-down list, then Version Manager.
  • Select the checkboxes for the versions of MongoDB that you have made available on the Ops Manager Application server.

Review and approve your changes.

Ops Manager displays your proposed changes.

If you are satisfied, click Confirm & Deploy.
Otherwise, click Cancel and you can make additional changes.

Configure Ops Manager agents

參考https://docs.opsmanager.mongodb.com/current/tutorial/install-automation-agent-with-rpm-package/

在node1,node2,node3上安裝mongodb-mms-automation-agent-manager
curl -OL http://172.17.20.127:8080/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm
rpm -U mongodb-mms-automation-agent-manager-latest.x86_64.rpm

按上圖ID修改

vim /etc/mongodb-mms/automation-agent.config
#get id and key from Group Settings
mmsGroupId=<Group ID>
mmsApiKey=<agent API key>
mmsBaseUrl=<application URL>

#啟動agent
/etc/init.d/mongodb-mms-automation-agent start

查看各個節點的agent是否連接上

通過Ops Manager安裝配置管理mongodb集群

導入已經存在的mongodb集群到Ops Manager

 准備工作

解壓mongodb壓縮包,避免部署的時候在線下載這個包
tar xvf mongodb-linux-x86_64-rhel62-3.4.2.tgz -C /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.4.2
chown -R mongod.mongod /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.4.2/
檢查各個節點的mongodb-mms-automation-agent是否連接上了

點擊ADD添加已經存在的集群

查看集群狀態(mongodb啟動程序有警告,所以status有警告)

通過Ops Manager自動化部署mongodb shard集群

#創建mongodb數據存放目錄,后面部署時要填寫
mkdir /mongodata
chown mongod:mongod /mongodata

確認后點擊REVIEW&DEPLOY

部署中可查看日志/var/log/mongodb-mms-automation/automation-agent.log排查錯誤,錯誤解決后點擊REVIEW&DEPLOY繼續部署。

 其他配置可參考官網

 4.x版本的可參考:https://blog.51cto.com/candon123/2162461

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM