mongodb-mms的安装与使用

服务器信息

ip 系统 配置 目录 版本
172.24.32.202 centos7.7 4c16g /opt/mongodb/mms/ 4.0.8

官网地址

https://docs.opsmanager.mongodb.com/v4.0/core/installation-checklist/

可以看到,对数据和快照的冗余性要求越高,即是对用于存储ops数据的db容灾性越高。
ops底层使用mongodb存储,所以使用多副本集加仲裁更好。

这里机器有限,使用单机版的mongodb作为底层存储

安装要求

虚拟机 配置 4c16
可以监控400台实例

1、安装mongodb,给mms存储数据

echo "[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el7-4.0/
gpgcheck=0
enabled=1" | sudo tee /etc/yum.repos.d/mongodb.repo
yum install -y mongodb-org mongodb-org-shell

创建application db的目录

mkdir -p /data/appdb
chown -R mongod:mongod /data/appdb

创建backup db的目录

mkdir -p /data/backup
chown -R mongod:mongod /data/backup
cp /etc/mongod.conf /etc/mongodapp.conf
cp /etc/mongod.conf /etc/mongodbackup.conf
cp /usr/lib/systemd/system/mongod.service /usr/lib/systemd/system/mongodapp.service
cp /usr/lib/systemd/system/mongod.service /usr/lib/systemd/system/mongodbackup.service

2、安装mms

下载ops安装包到/data目录

wget https://downloads.mongodb.com/on-prem-mms/rpm/mongodb-mms-4.0.18.50621.20200512T1431Z-1.x86_64.rpm

安装

rpm -ivh mongodb-mms-4.0.18.50621.20200512T1431Z-1.x86_64.rpm

启动

service mongodb-mms start

3、stmp安装

4、kmip

https://github.com/OpenKMIP/PyKMIP
pip install pykmip
git clone https://github.com/openkmip/pykmip.git
python pykmip/setup.py install

5、监控已经安装的集群

mms界面上点击添加已有服务的监控
在agent节点上执行

curl -OL http://172.24.32.202:8080/download/agent/automation/mongodb-mms-automation-agent-manager-5.4.24.5565-1.x86_64.rhel7.rpm
rpm -U mongodb-mms-automation-agent-manager-5.4.24.5565-1.x86_64.rhel7.rpm
vi /etc/mongodb-mms/automation-agent.config
mmsGroupId=5ec6338632ca5552d5595f73
mmsApiKey=5ec6570632ca5552d5596091f739ee7f079d460eb6eb3367ebd06b79
mmsBaseUrl=http://172.24.32.202:8080

启动和开机自启动

systemctl start mongodb-mms-automation-agent.service
systemctl enable mongodb-mms-automation-agent.service

自动发现创建用户

use admin
db.createUser({user: 'mms-automation', pwd: 'test123', roles: ['clusterAdmin', 'dbAdminAnyDatabase', 'readWriteAnyDatabase', 'restore', 'userAdminAnyDatabase']})

6、下载完整的 backup 镜像(分片模式取单一分片),并将其恢复到一个新的 mongod 实例中,并验证其中的数据.

mms开启备份,创建目录存放元数据

backup 
mkdir /data/backupDaemon
chown mongodb-mms:mongodb-mms /data/backupDaemon

在服务器172.24.32.202上新建一个mongo实例,mongodtest的数据存储
目录为

/data/mongorestore

去mms界面上面下载一个备份文件

lugotestrepl-1590130420-5ec7796d32ca5552d55da260.tar.gz

将文件传到172.24.32.202的/tmp目录下
解压并且赋权

tar zxf lugotestrepl-1590130420-5ec7796d32ca5552d55da260.tar.gz
chown -R mongod.mongod lugotestrepl-1590130420-5ec7796d32ca5552d55da260

将备份的数据覆盖进新的mongodtest实例

mv lugotestrepl-1590130420-5ec7796d32ca5552d55da260/* /data/mongorestore/

重启mongodtest实例

systemctl restart mongodtest

进入mongodtest实例,查看数据

mongo 127.0.0.1:23456

结果

> show dbs;
admin     0.000GB
config    0.000GB
local     0.000GB
lugotest  0.000GB
> use lugotest;
switched to db lugotest
> show dbs;
admin     0.000GB
config    0.000GB
local     0.000GB
lugotest  0.000GB
> show collections;
movie
test
> db.test.find();
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543cf"), "id" : 9, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d4"), "id" : 14, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543cd"), "id" : 7, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543c8"), "id" : 2, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543da"), "id" : 20, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d7"), "id" : 17, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543cb"), "id" : 5, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543c9"), "id" : 3, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d9"), "id" : 19, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543cc"), "id" : 6, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d6"), "id" : 16, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d0"), "id" : 10, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543c7"), "id" : 1, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543ce"), "id" : 8, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543ca"), "id" : 4, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d2"), "id" : 12, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d5"), "id" : 15, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d1"), "id" : 11, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d3"), "id" : 13, "username" : "U" }
{ "_id" : ObjectId("5ebe5eb9825f7f2e238543d8"), "id" : 18, "username" : "U" }
Type "it" for more
> it
{ "_id" : ObjectId("5ec65b424e9dd0a6b7d61d0c"), "id" : 1, "username" : "U" }
{ "_id" : ObjectId("5ec65b424e9dd0a6b7d61d0f"), "id" : 4, "username" : "U" }
{ "_id" : ObjectId("5ec65b424e9dd0a6b7d61d0d"), "id" : 2, "username" : "U" }
{ "_id" : ObjectId("5ec65b424e9dd0a6b7d61d0e"), "id" : 3, "username" : "U" }
{ "_id" : ObjectId("5ec65b424e9dd0a6b7d61d10"), "id" : 5, "username" : "U" }
{ "_id" : ObjectId("5ec66a9a2c5f4c03bf55e755"), "id" : 1, "username" : "U" }
{ "_id" : ObjectId("5ec66a9a2c5f4c03bf55e756"), "id" : 2, "username" : "U" }
{ "_id" : ObjectId("5ec66a9a2c5f4c03bf55e757"), "id" : 3, "username" : "U" }
{ "_id" : ObjectId("5ec66a9a2c5f4c03bf55e759"), "id" : 5, "username" : "U" }
{ "_id" : ObjectId("5ec66a9a2c5f4c03bf55e758"), "id" : 4, "username" : "U" }

发现数据一致

你可能感兴趣的:(mongodb-mms的安装与使用)