将自己日常学习工作过程中的问题及心得记录下来
1 环境构建
Master -- master
1 server1
111.10.10.10(master1)
虚拟IP 111.10.10.11
2 server2
111.10.10.40 (master2)
虚拟IP 111.10.10.12
3 server3
111.10.10.20 (监控主机)
虚拟IP 111.10.10.13
server1 和 server2 互为主从
2 安装过程
yum install epel* -y
yum install mysql-mmm* -y
server1,server2 赋权:
grant replication client on *.* to 'mmm_monitor'@'111.10.10.%' identified by 'monitor_password';
grant super,replication client,process on *.* to 'mmm_agent'@'111.10.10.%' identified by 'agent_password';
flush privileges;
修改配置文件
/etc/mysql-mmm/mmm_common.conf
[root@centos02 mysql-mmm]# cat mmm_common.conf
active_master_role writer
<host default>
cluster_interface eth1
pid_path /var/run/mysql-mmm/mmm_agentd.pid
bin_path /usr/libexec/mysql-mmm/
mysql_port 3351
replication_user replicant
replication_password slave
agent_user mmm_agent
agent_password agent_password
</host>
<host db1>
ip 111.10.10.10
mode master
peer db2
</host>
<host db2>
ip 111.10.10.40
mode master
peer db1
</host>
<role writer>
hosts db1, db2
ips 111.10.10.13
mode exclusive
</role>
<role reader>
hosts db1, db2
ips 111.10.10.11,111.10.10.12
mode balanced
</role>
数据库服务器server1,server2 修改
/etc/mysql-mmm/mmm_agent.conf
[root@centos02 mysql-mmm]# cat mmm_agent.conf
include mmm_common.conf
# The 'this' variable refers to this server. Proper operation requires
# that 'this' server (db1 by default), as well as all other servers, have the
# proper IP addresses set in mmm_common.conf.
this db1 --根据实际情况指定
监控服务器server3 上 修改
[root@centos02 mysql-mmm]# cat mmm_mon.conf
include mmm_common.conf
<monitor>
ip 127.0.0.1
pid_path /var/run/mysql-mmm/mmm_mond.pid
bin_path /usr/libexec/mysql-mmm
status_path /var/lib/mysql-mmm/mmm_mond.status
ping_ips 111.10.10.10,111.10.10.40
auto_set_online 60
# The kill_host_bin does not exist by default, though the monitor will
# throw a warning about it missing. See the section 5.10 "Kill Host
# Functionality" in the PDF documentation.
#
# kill_host_bin /usr/libexec/mysql-mmm/monitor/kill_host
#
</monitor>
<host default>
monitor_user mmm_monitor
monitor_password monitor_password
</host>
debug 0
3 启动测试:
server1,server2 启动agent
[root@centos01 ~]# /etc/init.d/mysql-mmm-agent start
Starting MMM Agent Daemon: [ OK ]
server3 启动
/etc/init.d/mysql-mmm-monitor start
4 查看
[root@centos02 mysql-mmm]# mmm_control show
db1(111.10.10.10) master/ONLINE. Roles: reader(111.10.10.12), writer(111.10.10.13)
db2(111.10.10.40) master/ONLINE. Roles: reader(111.10.10.11)
[root@centos02 mysql-mmm]# mmm_control checks
db2 ping [last change: 2014/09/12 08:07:08] OK
db2 mysql [last change: 2014/09/12 08:07:08] OK
db2 rep_threads [last change: 2014/09/12 08:08:53] OK
db2 rep_backlog [last change: 2014/09/12 08:07:08] OK: Backlog is null
db1 ping [last change: 2014/09/12 08:07:08] OK
db1 mysql [last change: 2014/09/12 08:07:08] OK
db1 rep_threads [last change: 2014/09/12 08:08:35] OK
db1 rep_backlog [last change: 2014/09/12 08:07:08] OK: Backlog is null
*****************************************************************
问题: 错误1
[root@centos02 ~]# mmm_control checks
db2 ping [last change: 2014/09/12 04:35:58] OK
db2 mysql [last change: 2014/09/12 04:35:58] ERROR: Connect error (host = 111.10.10.40:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111
db2 rep_threads [last change: 2014/09/12 04:35:58] UNKNOWN: Connect error (host = 111.10.10.40:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111
db2 rep_backlog [last change: 2014/09/12 04:35:58] UNKNOWN: Connect error (host = 111.10.10.40:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111
db1 ping [last change: 2014/09/12 04:35:58] OK
db1 mysql [last change: 2014/09/12 04:35:58] ERROR: Connect error (host = 111.10.10.10:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111
db1 rep_threads [last change: 2014/09/12 04:35:58] UNKNOWN: Connect error (host = 111.10.10.10:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111
db1 rep_backlog [last change: 2014/09/12 04:35:58] UNKNOWN: Connect error (host = 111.10.10.10:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111
原因分析: 端口配置错误。
解决办法: 修改 /etc/mysql-mmm 下 mmm_common.conf 文件内容:
active_master_role writer
<host default>
cluster_interface eth0
pid_path /var/run/mysql-mmm/mmm_agentd.pid
bin_path /usr/libexec/mysql-mmm/
mysql_port 3351 --指定正确端口号
replication_user replication
replication_password slave
agent_user mmm_agent
agent_password agent_password
</host>
错误2
[root@centos02 mysql-mmm]# mmm_control checks
db2 ping [last change: 2014/09/12 07:37:36] OK
db2 mysql [last change: 2014/09/12 07:37:36] ERROR: Connect error (host = 111.10.10.40:3351, user = mmm_monitor)! Access denied for user 'mmm_monitor'@'111.10.10.20' (using password: YES)
db2 rep_threads [last change: 2014/09/12 07:37:36] UNKNOWN: Connect error (host = 111.10.10.40:3351, user = mmm_monitor)! Access denied for user 'mmm_monitor'@'111.10.10.20' (using password: YES)
db2 rep_backlog [last change: 2014/09/12 07:37:36] UNKNOWN: Connect error (host = 111.10.10.40:3351, user = mmm_monitor)! Access denied for user 'mmm_monitor'@'111.10.10.20' (using password: YES)
db1 ping [last change: 2014/09/12 07:37:36] OK
db1 mysql [last change: 2014/09/12 07:37:36] ERROR: Connect error (host = 111.10.10.10:3351, user = mmm_monitor)! Access denied for user 'mmm_monitor'@'111.10.10.20' (using password: YES)
db1 rep_threads [last change: 2014/09/12 07:37:36] UNKNOWN: Connect error (host = 111.10.10.10:3351, user = mmm_monitor)! Access denied for user 'mmm_monitor'@'111.10.10.20' (using password: YES)
db1 rep_backlog [last change: 2014/09/12 07:37:36] UNKNOWN: Connect error (host = 111.10.10.10:3351, user = mmm_monitor)! Access denied for user 'mmm_monitor'@'111.10.10.20' (using password: YES)
问题原因: 密码错误,经验证 数据库密码无问题
解决办法:
root@centos02 mysql-mmm]# pwd
/etc/mysql-mmm
[root@centos02 mysql-mmm]# cat mmm_mon.conf
include mmm_common.conf
<monitor>
ip 127.0.0.1
pid_path /var/run/mysql-mmm/mmm_mond.pid
bin_path /usr/libexec/mysql-mmm
status_path /var/lib/mysql-mmm/mmm_mond.status
ping_ips 111.10.10.10,111.10.10.40
auto_set_online 60
# The kill_host_bin does not exist by default, though the monitor will
# throw a warning about it missing. See the section 5.10 "Kill Host
# Functionality" in the PDF documentation.
#
# kill_host_bin /usr/libexec/mysql-mmm/monitor/kill_host
#
</monitor>
<host default>
monitor_user mmm_monitor
monitor_password monitor_password --修改密码后问题解决
</host>
debug 0
*******************************************************************************************
Tieger 2014/9/12