赞
踩
部署Prometheus请点击此链接:https://blog.csdn.net/ZhanBiaoChina/article/details/107024115
安装mysql方法有多种:
1.源码安装
2.二进制安装
3.在线安装
4.docker安装
1.源码安装示例
mysql源码安装查看此链接:https://note.youdao.com/ynoteshare1/index.html?id=b3b9dd5c30719949eeac071cfd1a66ae&type=note
2.二进制安装
mysql二进制安装查看此链接:https://note.youdao.com/ynoteshare1/index.html?id=d1d3e0e1daf4cbf3cc502aac77349b61&type=note
3.在线安装示例
$ sudo apt-get install mysql-client-5.7 mysql-client-core-5.7
$ sudo apt-get install mysql-server-5.7 mysql-server-core-5.7
$ systemctl enable mysql
$ systemctl start mysql
4.docker-compose示例
# Docker Compose定义并启动MySQL以及MySQLD Exporter: $ cat docker-compose.yml version: '3' services: mysql: image: daocloud.io/library/mysql:5.7 ports: - "3306:3306" environment: - MYSQL_ROOT_PASSWORD=123456 - MYSQL_DATABASE=database mysqlexporter: image: prom/mysqld-exporter ports: - "9104:9104" environment: - DATA_SOURCE_NAME=root:XUANji.20@(mysql:3306)/database # 这里通过环境变量DATA_SOURCE_NAME方式定义监控目标,使用Docker Compose启动测试用的Mysql示例以及MySQLD Exporter $ docker-compose up -d # 启动完成后,可以通过以下命令登录到Mysql容器当中,并执行Mysql相关的指令. docker exec -it cb2017 mysql -uroot -pXUANji.20 mysql>
注意:在安装的时候会让你输入一个密码,此密码是mysql数据库root用户的密码,请记住自己输入的密码,此密码和服务器root用户的密码不是同一个。
prometheus监控MySQL需要用到mysql_exporter。
mysql_exporter 项目地址:https://github.com/prometheus/mysqld_exporter
注意:mysql_exporter可以部署在这两台主机任一一台上,只不过需要注意的是,在配置prometheus.yml添加监控目标的时候,注意填写对应ip即可。
$ cd /usr/local/src
$ wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz
$ tar xf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /usr/local
$ mysql -uroot -pxxxxxx
mysql> grant replication client,process on *.* to 'exporter'@'%' identified by "123456";
mysql> grant select on performance_schema.* to 'exporter'@'%';
mysql> flush privileges;
$ cd cd /usr/local/mysqld_
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。