您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql高可用方案之MHA

2026/3/18 23:52:30发布12次查看
环境规划:节点说明主机名ip地址管理节点tong3192.168.1.249主节点tong2192.168.1.248主节点 tong1&nb..
环境规划:
节点说明    主机名   ip地址
管理节点   tong3   192.168.1.249
主节点     tong2   192.168.1.248
主节点    tong1   192.168.1.247
1.网络和主机名配置
设置每个主机的ip地址和/etc/hosts文件互相解析
[root@tong1 ~]# cat /etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3
[root@tong1 ~]# ping tong1 -c1         --网络必须ping通
ping tong1 (192.168.1.247) 56(84) bytes of data.
64 bytes from localhost (192.168.1.247): icmp_seq=1 ttl=64 time=0.021 ms
--- tong1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.021/0.021/0.021/0.000 ms
[root@tong1 ~]# ping tong2 -c1
ping tong2 (192.168.1.248) 56(84) bytes of data.
64 bytes from tong2 (192.168.1.248): icmp_seq=1 ttl=64 time=0.109 ms
--- tong2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.109/0.109/0.109/0.000 ms
[root@tong1 ~]# ping tong3 -c1
ping tong3 (192.168.1.249) 56(84) bytes of data.
64 bytes from tong3 (192.168.1.249): icmp_seq=1 ttl=64 time=0.124 ms
--- tong3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.124/0.124/0.124/0.000 ms
[root@tong1 ~]#
2.安装mha管理软件mha manager
tong3管理节点:
[root@tong3 ~]# yum install  perl-dbd-mysql cpan  --安装perl工具
[root@tong3 ~]# tar xvf mha4mysql-manager-0.53.tar.gz  -c /usr/local/
[root@tong3 ~]# cd /usr/local/mha4mysql-manager-0.53/
[root@tong3 mha4mysql-manager-0.53]# perl makefile.pl 
[root@tong3 mha4mysql-manager-0.53]# echo $?
0
[root@tong3 mha4mysql-manager-0.53]# make && make install
[root@tong3 mha4mysql-manager-0.53]# echo $?
0
[root@tong3 mha4mysql-manager-0.53]#
3.在各数据节点安装mha node
[root@tong2 ~]# tar xvf mha4mysql-node-0.53.tar.gz
[root@tong2 ~]# cd mha4mysql-node-0.53
[root@tong2 mha4mysql-node-0.53]# yum install perl-dbd-mysql cpan -y
[root@tong2 mha4mysql-node-0.53]# perl makefile.pl
[root@tong2 mha4mysql-node-0.53]# make && make install
[root@tong2 mha4mysql-node-0.53]#  echo $?
0
[root@tong2 mha4mysql-node-0.53]#
4.各节点ssh互相信任
[root@tong3 ~]# ssh-keygen  -t dsa
[root@tong3 ~]# cd .ssh
[root@tong3 .ssh]# cat id_dsa.pub  > authorized_keys
[root@tong3 .ssh]# scp 192.168.1.247:/root/.ssh/id_dsa.pub 247
[root@tong3 .ssh]# scp 192.168.1.248:/root/.ssh/id_dsa.pub 248
[root@tong3 .ssh]# cat 248  247 >> authorized_keys
[root@tong3 .ssh]# scp authorized_keys 192.168.1.248:/root/.ssh/
authorized_keys                                                                                                                                    100% 1800     1.8kb/s   00:00   
[root@tong3 .ssh]# scp authorized_keys 192.168.1.247:/root/.ssh/
root@192.168.1.247's password:
authorized_keys                                                                                                                                    100% 1800     1.8kb/s   00:00    
[root@tong3 .ssh]# ssh tong1 date
tue apr 28 12:57:02 cst 2015
[root@tong3 .ssh]# ssh tong2 date
tue apr 28 12:59:57 cst 2015
[root@tong3 .ssh]# ssh tong3 date
tue apr 28 12:57:25 cst 2015
[root@tong3 .ssh]#
5.在管理节点编辑配置文件
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product