• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

多实例MySQL监控

mysql技术 gnzhutan 70次浏览 已收录 0个评论

环境 说明

  1. 10.0.0.121 CentOS 7.3

[root@slave2 tmp]# cat /etc/*release

CentOS Linux release 7.3.1611 (Core)
NAME=”CentOS Linux
VERSION=”7 (Core)”
ID=”centos”
ID_LIKE=”rhel fedora”
VERSION_ID=”7″
PRETTY_NAME=”CentOS Linux 7 (Core)”
ANSI_COLOR=”0;31″
CPE_NAME=”cpe:/o:centos:centos:7″
HOME_URL=”https://www.centos.org/”
BUG_REPORT_URL=”https://bugs.centos.org/”

CENTOS_MANTISBT_PROJECT=”CentOS-7″
CENTOS_MANTISBT_PROJECT_VERSION=”7″
REDHAT_SUPPORT_PRODUCT=”centos”
REDHAT_SUPPORT_PRODUCT_VERSION=”7″

CentOS Linux release 7.3.1611 (Core)
CentOS Linux release 7.3.1611 (Core)

MySQL Community Server (GPL) 5.7.21

 

初始化

mysqld –defaults-file=/usr/local/mysql/3306/my.cnf –initialize –basedir=/usr/local/mysql/3306 –datadir=/data/mysql/3306
mysqld –defaults-file=/usr/local/mysql/3307/my.cnf –initialize –basedir=/usr/local/mysql/3307 –datadir=/data/mysql/3307

 

启动多实例

[root@mysql01 ~]# mysqld_safe –defaults-file=/usr/local/mysql/3306/my.cnf &
[root@mysql01 ~]# mysqld_safe –defaults-file=/usr/local/mysql/3307/my.cnf &

 

连接多实例并修改密码

mysql -uroot -pd%+8eIshm?f. -S /tmp/mysql3306.sock

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 4
Server version: 5.7.21

Copyright (c) 2000, 2018, 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> set password for root@localhost = password(‘123’);
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit

mysql -uroot -p#;rYJI.UP8Lh -S /tmp/mysql3307.sock

停止多实例

[root@mysql01 ~]# mysqladmin -uroot -p123 -S /tmp/mysql3306.sock shutdown
[root@mysql01 ~]# mysqladmin -uroot -p123 -S /tmp/mysql3307.sock shutdown

创建监控用户

          1.为3306实例创建监控用户

[root@slave2 tmp]# mysql -uroot -p123 -S /tmp/mysql3306.sock
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 2
Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> CREATE USER ‘monitor’@’%’ IDENTIFIED BY ‘123456’;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO  ‘monitor’@’%’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

 

2. 为3307实例创建监控用户

[root@slave2 tmp]# mysql -uroot -p123 -S /tmp/mysql3307.sock
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 2
Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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>  CREATE USER ‘monitor’@’%’ IDENTIFIED BY ‘123456’;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO  ‘monitor’@’%’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye


VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明多实例MySQL监控
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址