zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

MySQL高可用MMM方案安装部署分享

mysql安装部署 分享 方案 可用 mmm
2023-06-13 09:15:18 时间

1installmysql

2.Basicconfigurationofmaster1

3.Createusers
GRANTREPLICATIONCLIENTON*.*TO"mmm_monitor"@"%"IDENTIFIEDBY"mmm_monitor";
GRANTSUPER,REPLICATIONCLIENT,PROCESSON*.*TO"mmm_agent"@"%"IDENTIFIEDBY"mmm_agent";
GRANTREPLICATIONSLAVEON*.*TO"repl"@"10.88.49.%"IDENTIFIEDBY"repl";
grantinsert,create,delete,update,selecton*.*to"tim"@"%"identifiedby"tim";
Note:Donnotuseareplication_passwordlongerthan32characters


4.Synchronisationofdatabetweenbothdatabases


5.Setupreplication
setm-s:
changemastertomaster_host="10.88.49.119",master_log_file="mysql56-bin.000026",master_log_pos=332,master_user="repl",master_password="repl";


6.Installmmm
6.1downloadmmm.tar.gz
wgethttp://mysql-mmm.org/_media/:mmm2:mysql-mmm-2.2.1.tar.gz
6.2mv:mmm2:mysql-mmm-2.2.1.tar.gzmysql-mmm-2.2.1.tar.gz
tar-xvfmysql-mmm-2.2.1.tar.gz
cdmysql-mmm-2.2.1
make
cmake
[]donnotrequiremakeandmakeinstall,therehave*.confin/etc/mysql-mmmfolder.

7.installlibpackage
yuminstall-yperl-*
yuminstall-ylibart_lgpl.x86_64
yuminstall-ymysql-mmm.noarchfail
yuminstall-yrrdtool.x86_64
yuminstall-yrrdtool-perl.x86_64
7.1[]anotherwaytoinstalllibpackageinnetwork
cpan-iAlgorithm::DiffClass::SingletonDBIDBD::mysqlLog::DispatchLog::Log4perlMail::SendNet::PingProc::DaemonTime::HiResParams::ValidateNet::ARP


8.ConfigMMMofDBhost
vim/etc/mysql-mmm/mmm_common.conf
Donnotforgettocopythisfiletoallotherhosts(includingthemonitoringhost).
#Bugsfor$
scp/etc/mysql-mmm/mmm_common.conf10.88.49.119:/etc/mysql-mmm/
scp/etc/mysql-mmm/mmm_common.conf10.88.49.122:/etc/mysql-mmm/
scp/etc/mysql-mmm/mmm_common.conf10.88.49.123:/etc/mysql-mmm/

Onthedatabasehostsweneedtoedit/etc/mysql-mmm/mmm_agent.conf.Change“db1”accordinglyontheotherhosts:
chkconfig--addmysql-mmm-agent

9.ConfigMonitor
Onthemonitorhost(10.88.49.123)weneedtoedit/etc/mysql-mmm/mmm_mon.conf:
includemmm_common.conf
<monitor>
ip127.0.0.1
pid_path/var/run/mmm_mond.pid
bin_path/usr/lib/mysql-mmm/
status_path/var/lib/misc/mmm_mond.status
auto_set_online5
ping_ips10.88.49.254,10.88.49.130,10.88.49.131,10.88.49.132,10.88.49.133,10.88.49.134
</monitor>
<hostdefault>
monitor_usermmm_monitor
monitor_passwordmmm_monitor
</host>
debug0
ping_ipsaresomeipsthatarepingedtodeterminewhetherthenetworkconnectionofthemonitorisok.IusedmyswitchofGATEWAY(10.88.49.254)andthefourdatabaseserver.followthis
[root@oraclemysql-mmm]#cat/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=10.88.49.118
NETWASK=255.255.254.0
GATEWAY=10.88.49.254
DNS1=10.106.185.143
DNS2=10.106.185.138
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
HWADDR=00:15:5D:01:6A:0C


10.Startindatabasehosts
chkconfig--addmysql-mmm-agent
[root@oracle~]#mysql-mmm-agentstart
-bash:mysql-mmm-agent:commandnotfound
[root@oracle~]#servicemysql-mmm-agentstart
Daemonbin:"/usr/sbin/mmm_agentd"
Daemonpid:"/var/run/mmm_agentd.pid"
StartingMMMAgentdaemon...CannotlocateProc/Daemon.pmin@INC(@INCcontains:/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.)at/usr/sbin/mmm_agentdline7.
BEGINfailed--compilationabortedat/usr/sbin/mmm_agentdline7.
[root@oracle~]#cpanProc::Daemon
[root@oracle~]#cpanLog::Log4perl
[root@oracle~]#/etc/init.d/mysql-mmm-agentstart
Daemonbin:"/usr/sbin/mmm_agentd"
Daemonpid:"/var/run/mmm_agentd.pid"
StartingMMMAgentdaemon...Ok


11.Startinmonitorhosts
chkconfig--addmysql-mmm-monitor
[root@localhostmysql-mmm-2.2.1]#servicemysql-mmm-monitorstart
Daemonbin:"/usr/sbin/mmm_mond"
Daemonpid:"/var/run/mmm_mond.pid"
StartingMMMMonitordaemon:CannotlocateProc/Daemon.pmin@INC(@INCcontains:/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.)at/usr/sbin/mmm_mondline11.
BEGINfailed--compilationabortedat/usr/sbin/mmm_mondline11.
failed
[root@oracle~]#cpanProc::Daemon
[root@oracle~]#cpanLog::Log4perl
[root@localhostmysql-mmm-2.2.1]#servicemysql-mmm-monitorstart
Daemonbin:"/usr/sbin/mmm_mond"
Daemonpid:"/var/run/mmm_mond.pid"
StartingMMMMonitordaemon:Ok

12.Checkfail
[root@oraclemysql-mmm]#ping10.88.49.130
PING10.88.49.130(10.88.49.130)56(84)bytesofdata.
From10.88.49.118icmp_seq=2DestinationHostUnreachable
From10.88.49.118icmp_seq=3DestinationHostUnreachable
From10.88.49.118icmp_seq=4DestinationHostUnreachable
From10.88.49.118icmp_seq=6DestinationHostUnreachable
From10.88.49.118icmp_seq=7DestinationHostUnreachable
From10.88.49.118icmp_seq=8DestinationHostUnreachable

12.1debugerrorinfo
在agent.conf和monitor.conf分别加上debug1
然后看输出的日志

[root@localhostmysql-mmm]#mmm_controlshow
db1(10.88.49.118)master/AWAITING_RECOVERY.Roles:
db2(10.88.49.119)master/AWAITING_RECOVERY.Roles:
db3(10.88.49.122)slave/AWAITING_RECOVERY.Roles:
[root@localhostmysql-mmm]#mmm_controlset_onlinedb1
OK:Stateof"db1"changedtoONLINE.Nowyoucanwaitsometimeandcheckitsnewroles!
[root@localhostmysql-mmm]#mmm_controlset_onlinedb2
OK:Stateof"db2"changedtoONLINE.Nowyoucanwaitsometimeandcheckitsnewroles!
[root@localhostmysql-mmm]#mmm_controlset_onlinedb3
OK:Stateof"db3"changedtoONLINE.Nowyoucanwaitsometimeandcheckitsnewroles!

12.2pingvipfail
2013/02/1910:00:15FATALCouldn"tconfigureIP"10.88.49.131"oninterface"eth1":undef
2013/02/1910:00:15DEBUGExecuting/usr/lib/mysql-mmm//agent/mysql_allow_write
Can"tlocateNet/ARP.pmin@INC(@INCcontains:/usr/local/lib64/perl5/usr/local/share/perl5/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl/usr/lib64/perl5/usr/share/perl5.)at/usr/share/perl5/vendor_perl/MMM/Agent/Helpers/Network.pmline11.
[1.1]
cpanNet/ARP.pm
yuminstalllibuuid*Error
[2.1]if[1.1]fail,trythis
[root@localhostmysql-mmm]#perl-MCPAN-eshell
cpan>installNet::ARP
[ok]


12.3failinfo:
2013/02/1910:25:23INFOAdded:reader(10.88.49.131),writer(10.88.49.130)
2013/02/1910:25:23DEBUGExecuting/usr/lib/mysql-mmm//agent/configure_ipeth110.88.49.131
Device"eth1"doesnotexist.
2013/02/1910:25:23FATALCouldn"tconfigureIP"10.88.49.131"oninterface"eth1":ERROR:Couldnotcheckifip10.88.49.131isconfiguredoneth1:
2013/02/1910:25:23DEBUGExecuting/usr/lib/mysql-mmm//agent/sync_with_master
2013/02/1910:25:23DEBUGExecuting/usr/lib/mysql-mmm//agent/mysql_allow_write
2013/02/1910:25:23DEBUGExecuting/usr/lib/mysql-mmm//agent/configure_ipeth110.88.49.130
Device"eth1"doesnotexist.
2013/02/1910:25:23FATALCouldn"tconfigureIP"10.88.49.130"oninterface"eth1":ERROR:Couldnotcheckifip10.88.49.130isconfiguredoneth1:
2013/02/1910:25:23DEBUGFetchinguptimefrom/proc/uptime
2013/02/1910:25:23DEBUGUptimeis158489.10
2013/02/1910:25:23DEBUGDaemon:Answer="OK:Statusappliedsuccessfully!"
[ok]cluster_interfaceshouldsetthe

12.4Whenconnectreadervip,Lostpackage,info:
[root@localhostmysql-mmm]#ping10.88.49.134
PING10.88.49.134(10.88.49.134)56(84)bytesofdata.
64bytesfrom10.88.49.134:icmp_seq=3ttl=64time=0.265ms
64bytesfrom10.88.49.134:icmp_seq=6ttl=64time=0.699ms
64bytesfrom10.88.49.134:icmp_seq=9ttl=64time=0.482ms
64bytesfrom10.88.49.134:icmp_seq=12ttl=64time=0.405ms
64bytesfrom10.88.49.134:icmp_seq=15ttl=64time=0.430ms


14.Checkall
[root@localhost~]#mmm_controlchecks
db2ping[lastchange:2013/02/1912:41:45]OK
db2mysql[lastchange:2013/02/1912:41:45]OK
db2rep_threads[lastchange:2013/02/1912:41:45]OK
db2rep_backlog[lastchange:2013/02/1912:41:45]OK:Backlogisnull
db3ping[lastchange:2013/02/1912:41:45]OK
db3mysql[lastchange:2013/02/1912:41:45]OK
db3rep_threads[lastchange:2013/02/1912:41:45]OK
db3rep_backlog[lastchange:2013/02/1912:41:45]OK:Backlogisnull
db1ping[lastchange:2013/02/1912:41:45]OK
db1mysql[lastchange:2013/02/1912:41:45]OK
db1rep_threads[lastchange:2013/02/1912:41:45]OK
db1rep_backlog[lastchange:2013/02/1912:41:45]OK:Backlogisnull

15Checkm<->m<->schange
15.1changewriterfrom10.88.49.118to10.88.49.119Stopmysqldindb110.88.49.118
showslavestatuson10.88.49.122,seeMaster_Hostis"10.88.49.118"
[root@oracle~]#servicemysqld56stop
ShuttingdownMySQL...SUCCESS!


15.1.1showinfoinmonitorhostlog
[root@localhost~]#tail-f/var/log/mysql-mmm/mmm_mond.log
2013/02/2010:34:42INFORemovingallrolesfromhost"db1":
2013/02/2010:34:42INFORemovedrole"reader(10.88.49.134)"fromhost"db1"
2013/02/2010:34:42INFORemovedrole"writer(10.88.49.130)"fromhost"db1"
2013/02/2010:34:42INFOOrphanedrole"writer(10.88.49.130)"hasbeenassignedto"db2"
2013/02/2010:34:42INFOOrphanedrole"reader(10.88.49.134)"hasbeenassignedto"db3"
15.1.2showinfoinslavehostof10.88.49.122,slavewillchangeitsmaster_host
[root@localhost~]#mysql-P3307-S/data56/mysql.sock-p123456
mysql>showslavestatus\G
***************************1.row***************************
Slave_IO_State:Waitingformastertosendevent
Master_Host:10.88.49.119


15.1.3buttherearesomebadinfoinmonitorhostof10.88.49.123,whenyourun"mmm_controlshow",itmayholdon.
2013/02/2010:37:25DEBUGListener:Waitingforconnection...
2013/02/2010:37:28DEBUGListener:Waitingforconnection...

15.1.4[]why?
ihavesolvedthisproblem,itmaybeoccurwhen:
(1):"peer"paramteriswrong.
(2):"ping_ips"and"ips"arewrong


15.2changewriterfrom10.88.49.119to10.88.49.118
15.2.1startmysqldin10.88.49.118,stopmysqldin10.88.49.119,run"mmm_controlset_onlinedb1"inmonitor_host
15.2.2showslaveinfoinslave_hostof10.88.49.122
[root@localhost~]#mysql-P3307-S/data56/mysql.sock-p123456
mysql>showslavestatus\G
***************************1.row***************************
Slave_IO_State:Waitingformastertosendevent
Master_Host:10.88.49.118
15.3stopmysqldonslave_hostof10.88.49.122
15.3.1showinfoinmonitor_host
[root@localhostmysql-mmm]#mmm_controlshow
db1(10.88.49.118)master/ONLINE.Roles:reader(10.88.49.134),reader(10.88.49.135),writer(10.88.49.130)
db2(10.88.49.119)master/ONLINE.Roles:reader(10.88.49.131),reader(10.88.49.132),reader(10.88.49.133)
db3(10.88.49.122)slave/HARD_OFFLINE.Roles:
[]theipschangetomm.

15.3.2startmysqldonslave_hostof10.88.49.122

15.3.3showinfoinmonitor_host
[root@localhostmysql-mmm]#mmm_controlshow
db1(10.88.49.118)master/ONLINE.Roles:reader(10.88.49.134),reader(10.88.49.135),writer(10.88.49.130)
db2(10.88.49.119)master/ONLINE.Roles:reader(10.88.49.131),reader(10.88.49.132),reader(10.88.49.133)
db3(10.88.49.122)slave/AWAITING_RECOVERY.Roles:
[]needsetonline
[root@localhostmysql-mmm]#mmm_controlset_onlinedb3
OK:Stateof"db3"changedtoONLINE.Nowyoucanwaitsometimeandcheckitsnewroles!
[root@localhostmysql-mmm]#mmm_controlshow
db1(10.88.49.118)master/ONLINE.Roles:reader(10.88.49.135),writer(10.88.49.130)
db2(10.88.49.119)master/ONLINE.Roles:reader(10.88.49.131),reader(10.88.49.133)
db3(10.88.49.122)slave/ONLINE.Roles:reader(10.88.49.132),reader(10.88.49.134)


15.4stopmaster_hostdb2of10.88.49.119
15.4.1showinfoinmonitor_host
[root@localhostmysql-mmm]#mmm_controlshow
db1(10.88.49.118)master/ONLINE.Roles:reader(10.88.49.131),reader(10.88.49.135),writer(10.88.49.130)
db2(10.88.49.119)master/HARD_OFFLINE.Roles:
db3(10.88.49.122)slave/ONLINE.Roles:reader(10.88.49.132),reader(10.88.49.133),reader(10.88.49.134)
seedb2isHARD_OFFLINE

15.4.2startmaster_hostdb2of10.88.49.119
[root@localhostmysql-mmm]#mmm_controlshow
db1(10.88.49.118)master/ONLINE.Roles:reader(10.88.49.131),reader(10.88.49.135),writer(10.88.49.130)
db2(10.88.49.119)master/AWAITING_RECOVERY.Roles:
db3(10.88.49.122)slave/ONLINE.Roles:reader(10.88.49.132),reader(10.88.49.133),reader(10.88.49.134)
seedb2isAWAITING_RECOVERY,soneedsetonline
[root@localhostmysql-mmm]#mmm_controlset_onlinedb2
OK:Stateof"db2"changedtoONLINE.Nowyoucanwaitsometimeandcheckitsnewroles!
[root@localhostmysql-mmm]#mmm_controlshow
db1(10.88.49.118)master/ONLINE.Roles:reader(10.88.49.135),writer(10.88.49.130)
db2(10.88.49.119)master/ONLINE.Roles:reader(10.88.49.131),reader(10.88.49.132)
db3(10.88.49.122)slave/ONLINE.Roles:reader(10.88.49.133),reader(10.88.49.134)
seedb2isonline


15.5changewritertodb2
mmm_controlmove_rolewriterdb2

相关文章:

http://blog.csdn.net/hguisu/article/details/7349562
http://blog.chinaunix.net/uid-28437434-id-3471237.html
http://mysql-mmm.org/downloads;
http://mysql-mmm.org/mmm2:guide
http://dev.mysql.com/doc/internals/en/optimizer-primary-optimizations.html