mysql 七
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 七相关的知识,希望对你有一定的参考价值。
部署mysql高可用集群
高可用集群介绍: 主备模式 当主不能提供服务的时候备用主机接替它提供服务,这个过程对于客户端是透明的。
一 配置MySQL主从同步
主主结构
主从从
一主多从
二配置MySQL-mmm perl
mmm_monitor 监控服务 运行在管理节点主机上。
mmm_agentd 代理服务 运行在所有的数据节点主机上。
writer-vip : 192.168.4.100
read -vip : 192.168.4.101/102
2.1 在所有主机上安装mysql-mmm-2.2.1.tar.gz软件包
#yum -y install perl-*
#unzip mysql-mmm.zip
#cd mysql-mmm
#tar -zxf mysql-mmm-2.2.1.tar.gz
#cd mysql-mmm-2.2.1
#make install
#ls /etc/mysql-mmm/
mmm_agent.conf //mmm_agentd服务主配置文件
mmm_common.conf //公共配置文件(管理主机和数据节点主机)
mmm_mon.conf //mmm_monitor服务主配置文件
mmm_tools.conf
2.2 修改配置
2.2.1 修改数据节点主机mmm_agentd服务的配置文件
ip地址 名称
192.168.4.51 master51
192.168.4.52 master52
192.168.4.53 slave53
192.168.4.54 slave54
#vim /etc/mysql-mmm/mmm_agent.conf
include mmm_common.conf
this 主机名
[[email protected] ~]#
2.2.2 修改管理节点主机mmm_monitor服务的配置文件
vim /etc/mysql-mmm/mmm_mon.conf
[[email protected] ~]# cat /etc/mysql-mmm/mmm_mon.conf
include mmm_common.conf
<monitor>
ip 192.168.4.55
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
ping_ips 192.168.4.51, 192.168.4.52, 192.168.4.53, 192.168.4.54
</monitor>
<host default>
monitor_user monitor
monitor_password 123456
</host>
debug 0
[[email protected] ~]#
2.2.3 修改公共配置文件mmm_common.conf
vim /etc/mysql-mmm/mmm_common.conf
[[email protected] mysql-mmm-2.2.1]# cat /etc/mysql-mmm/mmm_common.conf
active_master_role writer
<host default>
cluster_interface eth0
pid_path /var/run/mmm_agentd.pid
bin_path /usr/lib/mysql-mmm/
replication_user h51
replication_password 123456
agent_user agent
agent_password 123456
</host>
<host master51>
ip 192.168.4.51
mode master
peer master52
</host>
<host master52>
ip 192.168.4.52
mode master
peer master51
</host>
<host slave53>
ip 192.168.4.53
mode slave
</host>
<host slave54>
ip 192.168.4.54
mode slave
</host>
<role writer>
hosts master51, master52
ips 192.168.4.100
mode exclusive
</role>
<role reader>
hosts slave53, slave54
ips 192.168.4.101, 192.168.4.102
mode balanced
</role>
[[email protected] mysql-mmm-2.2.1]#
2.2.4 根据配置文件里设置,在数据节点主机天添加对应的授权用户
监控用户monitor agent
mmm_monitor mmm_agentd
51 :
mysql> grant replication client on . to [email protected]"%" identified by "123456";
mysql> grant replication client,process,super on . to [email protected]"%" identified by "123456";
mysql> select user,host from mysql.user where user in ("monitor","agent");
52-54:
select user,host from mysql.user where user in ("monitor","agent");
2.3 启动服务
2.3.0 安装依赖的软件包
安装mmm_monitor服务和mmm_agentd运行依赖的软件包(51~55)
#yum -y install gcc gcc-c++
#tar -zxf Algorithm-Diff-1.1902.tar.gz
#cd Algorithm-Diff-1.1902/
#perl Makefile.PL
#make
#make install
#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
安装获取vip地址的程序(51-54 )
289 gunzip Net-ARP-1.0.8.tgz
291 tar -xf Net-ARP-1.0.8.tar
293 cd Net-ARP-1.0.8/
295 perl Makefile.PL
296 make
297 make install
2.3.1 启动数据节点主机上的 mmm_agentd服务(51~54)
[[email protected] ~]# /etc/init.d/mysql-mmm-agent status
Daemon bin: ‘/usr/sbin/mmm_agentd‘
Daemon pid: ‘/var/run/mmm_agentd.pid‘
Checking MMM Agent process: not running.
[[email protected] ~]#
[[email protected] ~]# /etc/init.d/mysql-mmm-agent start
Daemon bin: ‘/usr/sbin/mmm_agentd‘
Daemon pid: ‘/var/run/mmm_agentd.pid‘
Starting MMM Agent daemon... defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.
(Maybe you should just omit the defined()?)
Ok
[[email protected] ~]# netstat -utnalp | grep :9989
tcp 0 0 192.168.4.51:9989 0.0.0.0:* LISTEN 12389/mmm_agentd
[[email protected] ~]# ls /var/log/mysql-mmm/
mmm_agentd.log
[[email protected] ~]#
2.3.2 启动管理节点主机上的 mmm_monitor服务
[[email protected] ~]# /etc/init.d/mysql-mmm-monitor status
Daemon bin: ‘/usr/sbin/mmm_mond‘
Daemon pid: ‘/var/run/mmm_mond.pid‘
Checking MMM Monitor process: not running.
[[email protected] ~]#
[[email protected] ~]# /etc/init.d/mysql-mmm-monitor start
Daemon bin: ‘/usr/sbin/mmm_mond‘
Daemon pid: ‘/var/run/mmm_mond.pid‘
Starting MMM Monitor daemon: defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.
(Maybe you should just omit the defined()?)
Ok
[[email protected] ~]# netstat -utnalp | grep :9988
tcp 0 0 192.168.4.55:9988 0.0.0.0:* LISTEN 11433/mmm_mond
[[email protected] ~]# ls /var/log/mysql-mmm/
mmm_mond.log
[[email protected] ~]#
2.3.3 在管理节点55主机上,查看监控信息
[[email protected] ~]# mmm_control show
defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.
(Maybe you should just omit the defined()?)
master51(192.168.4.51) master/AWAITING_RECOVERY. Roles:
master52(192.168.4.52) master/AWAITING_RECOVERY. Roles:
slave53(192.168.4.53) slave/AWAITING_RECOVERY. Roles:
slave54(192.168.4.54) slave/AWAITING_RECOVERY. Roles:
[[email protected] ~]# mmm_control set_online 主机名
[[email protected] ~]# mmm_control set_online master51
defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.
(Maybe you should just omit the defined()?)
OK: State of ‘master51‘ changed to ONLINE. Now you can wait some time and check its new roles!
[[email protected] ~]#
[[email protected] ~]# mmm_control show
defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.
(Maybe you should just omit the defined()?)
master51(192.168.4.51) master/ONLINE. Roles: writer(192.168.4.100)
master52(192.168.4.52) master/ONLINE. Roles:
slave53(192.168.4.53) slave/ONLINE. Roles: reader(192.168.4.101)
slave54(192.168.4.54) slave/ONLINE. Roles: reader(192.168.4.102)
[[email protected] ~]#
[[email protected] ~]# ping -c 2 192.168.4.100
数据节点主机查看 VIP 地址?51~54
#ip addr show | grep 192.168.4.
在数据节点主机上添加访问数据的连接用户
51#mysql -uroot -p123456
mysql> grant all on gamedb.* to [email protected]"%"
-> identified by "123456";
mysql> select user,host from mysql.user where user="admin";
三、客户端254测试,高可用集群的配置
#mysql -h192.168.4.100 -uamdin -p123456
以上是关于mysql 七的主要内容,如果未能解决你的问题,请参考以下文章
阿里云服务器ECS第七代c7/g7/r7/c7t/g7ne/g7t/r7t参数性能详解!