Deployment - Monitoring - Backup -all-in-one
dbm database management center
Is there a set of open-source MySQL database software used to manage it? This is the dbm really have it done automatically deploy various types of MySQL environment, monitoring, backup and other work; dbm overall architecture is shown, here we mainly introduce dbm-agent.
dbm-agent Installation and Configuration
dbm-agent to be installed on the host you used to deploy the MySQL database, in order to facilitate the use dbm-agent offers some handy command line to complete routine tasks, not mandatory, and dbm-center used together, if you need web management page, then then you need to dbm-center. Below an example using dbm-agent alone.
#安装
sudo su
pip3 install dbm-agent
#配置初始化
dbm-agent init
2020-03-19 10:24:31,063 INFO user 'dbma' not exists going to create it
2020-03-19 10:24:31,064 WARNING user group dbma not exits
2020-03-19 10:24:31,064 INFO groupadd dbma
2020-03-19 10:24:31,110 INFO create dir /usr/local/dbm-agent/
2020-03-19 10:24:31,111 INFO create config file '/usr/local/dbm-agent/etc/dbma.cnf' 2020-03-19 10:24:31,120 INFO prepare rende init-sql-file /usr/local/dbm-agent/etc/init-users.sql 2020-03-19 10:24:31,120 INFO init-sql-file render complete 2020-03-19 10:24:31,121 INFO inseption data saved to '/usr/local/dbm-agent/logs/auto-inseption.db' 2020-03-19 10:24:31,139 DEBUG sudo context config dbm-monitor-gateway 2020-03-19 10:24:31,372 INFO monitor-gateway render complete 2020-03-19 10:24:31,373 DEBUG sudo context config dbm-backup-proxy 2020-03-19 10:24:31,600 INFO monitor-gateway render complete 2020-03-19 10:24:31,606 INFO init complete #初始化完成之后会自动拉起 dbm-monitor-gateway(数据库监控) 服务 systemctl status dbm-monitor-gatewayd ● dbm-monitor-gatewayd.service - dbm monitor gateway Loaded: loaded (/usr/lib/systemd/system/dbm-monitor-gatewayd.service; enabled; vendor preset: disabled) Active: active (running) since 四 2020-03-19 10:24:31 CST; 4min 55s ago Main PID: 1568 (dbm-monitor-gat) CGroup: /system.slice/dbm-monitor-gatewayd.service └─1568 /usr/local/python-3.8.1/bin/python3.8 /usr/local/python/bin/dbm-monitor-gate... 3月 19 10:24:31 lestudio systemd[1]: Started dbm monitor gateway. #监控服务以守护进程运行 ps -ef | grep dbm-monitor dbma 1568 1 0 10:24 ? 00:00:01 /usr/local/python-3.8.1/bin/python3.8 /usr/local/python/bin/dbm-monitor-gateway --monitor-user=monitor --monitor-password=dbma@0352 --bind-ip=127.0.0.1 --bind-port=8080 start
Download MySQL binary package to dbm-agent package directory.
#下载 MySQL 二进制包
cd /usr/local/dbm-agent/pkg/
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
Automated installation of MySQL
In dbm-agent to install the single MySQL-8.0.19 Case (dbm-agent from the main support replication, MGR herein by way of example in order to facilitate single).
dbma-cli-single-instance --pkg=mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz \
--port=3306 --max-mem=128 install
2020-03-19 11:35:30,087 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller.install - im - INFO - 1118 - execute checkings for install mysql
...
...
2020-03-19 11:35:43,384 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller.install - im - INFO - 1153 - install mysql single instance complete
Verify that the installation was successful.
mysql -uroot -pdbma@0352 -h127.0.0.1 -P3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.19 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.19 | +-----------+ 1 row in set (0.00 sec)
Automated monitoring
After initialization dbm-agent monitoring service runs in the background, it will periodically scan ports to see if a new MySQL instance is installed, if you find a new instance of the monitor put it up; and to expose the monitored items with http protocol.
#查看当前主机上有哪些实例
curl http://127.0.0.1:8080/instances/
[3306]
#查看给定实例的监控项
curl http://127.0.0.1:8080/instances/3306/com_select
{
"com_select": "90"
}
#查看给定实例的所有监控项 curl http://127.0.0.1:8080/instances/3306/ { "aborted_clients": "0", "aborted_connects": "10", "acl_cache_items_count": "0", ... ... "binlog_ignore_db": "", "executed_gtid_set": "" }
Automated Backup
Because the backup is to use disk space, for a variety of reasons for it, the backup repository is not activated by default, if you want to back up, then a start on it.
systemctl start dbm-backup-proxyd
Check the backup has not been successful.
tree /backup/mysql/backup/3306/
/backup/mysql/backup/3306/
└── 2020-12
├── 2020-03-19T11:47:46.620437-full-backup.sql
└── binlog-position.log
1 directory, 2 files
Of course, if you are a local tyrant mysqlbackup
backup is also supported.
tree /backup/mysql/backup/3306/
/backup/mysql/backup/3306/
├── 2020-11
│ ├── 2020-03-09T10:05:02.924898-full-backup.mbi
│ ├── 2020-03-09T10:05:02.924898.log
dbm concept
dbm beginning of the design is to do everything possible to reduce the workload of the DBA, from the above examples can also be seen after as long as the dbm related services start, dirty, dirty work, and duplication of effort on the DBA does not matter; I hope that every DBA can do nothing.
dbm official site: https: //www.sqlpy.com/
dbm source: https: //github.com/Neeky/dbm-agent
Reprinted from: https://www.sqlpy.com/blogs/586861252