grant replication client on *.* to monitor@'%'>
grant replication client,process,super on *.* to agent@'%'> 三、启动数据节点服务和管理节点主机上的mmm_monitor服务
1、在五台主机上安装启动的依赖包:下面三个rpm包或者tar包
解决启动agent服务的依赖包:
Algorithm-Diff-1.1902.tar.gz
perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm
Proc-Daemon-0.03.tar.gz
2、安装上面的三个包
yum -y install gcc gcc-c++
cd mysql-mmm/
tar -zxf Algorithm-Diff-1.1902.tar.gz
cd Algorithm-Diff-1.1902/
perl Makefile.PL
make
make install
cd ..
rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm
tar -zxf Proc-Daemon-0.03.tar.gz
cd Proc-Daemon-0.03/
perl Makefile.PL
make
make install
3、安装获取VIP的软件包:Net-ARP-1.0.8.tgz(在四台mysql服务上安装)
gunzip Net-ARP-1.0.8.tgz
tar -xf Net-ARP-1.0.8.tar
cd Net-ARP-1.0.8/
perl Makefile.PL
make && make install
4、启动agent服务:在五台服务器上启动
/etc/init.d/mysql-mmm-agent start //启动服务
netstat -ntulp | grep 9989 //查看端口号,查看服务是否启动
cat /var/log/mysql-mmm/mmm_agentd.log //启动日志
5、启动管理节点主机上的mmm_monitor服务
/etc/init.d/mysql-mmm-monitor start //启动
netstat -ntulp | grep 9988 //查看是否启动
ls /var/log/mysql-mmm/mmm_mond.log //日志文件
6、在管理主机上,查看监控信息:mmm_control show
master122(192.168.4.122) master/AWAITING_RECOVERY. Roles:
master123(192.168.4.123) master/AWAITING_RECOVERY. Roles:
slave126(192.168.4.126) slave/AWAITING_RECOVERY. Roles:
slave127(192.168.4.127) slave/AWAITING_RECOVERY. Roles:
7、设置在线: mmm_control set_online 四台都需要设置
mmm_control set_online master122
mmm_control set_online master123
mmm_control set_online slave126
mmm_control set_online slave127
设置完成后查看:mmm_control show
master122(192.168.4.122) master/ONLINE. Roles: writer(192.168.4.100)
master123(192.168.4.123) master/ONLINE. Roles:
slave126(192.168.4.126) slave/ONLINE. Roles: reader(192.168.4.101)
slave127(192.168.4.127) slave/ONLINE. Roles: reader(192.168.4.102)
如何查看IP:
ip addr show | grep 192.168.4. //可以看到获取到了两个ip地址
四、测试
1、在数据节点上添加访问数据库的连接用户,只需要在4.122上创建一个授权帐号
grant all on *.* to admin@'%'> 2、客户端测试:
mysql -h192.168.4.100 -uadmin -p123456
登陆上去后,增删改查数据库,然后在四台mysql
服务器上验证是否正确
3、手动把4.122这台主mysql服务器停掉,
看在客户端是否能访问,增删改查等。
4、4.122手动起来后,首先需要设置在线:mmm_control set_online master122
但是VIP对应的还是4.123,不会自动切换过去,
必须要先把4.123:mmm_control set_offline master123,
这样4.122才会获得VIP