Environmental planning
Amoeba Read-Write splitter |
172.16.254.144/16 |
MySQL server (master) |
172.16.254.150/16 |
MySQL server (slave) |
172.16.254.151/16 |
first, realize MySQL master-slave replication, use yum to install MySQL on master
[Email protected] mysql]# yum-y install MySQL Mysql-server
To enable binary logging, edit/etc/my.cnf Add the following line under [Mysqld]:
Log-bin =/var/lib/mysql/mysql-bin-logbinlog_format=mixedserver_id = 1
Restart mysqld, connect MySQL, authorize remote copy account
mysql> grant replication Slave, replication Client on *. * to ' repluser ' @ ' 172.16.%.% ' identified by ' mypass ';
View binary log files and locations that are currently in use
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/28/60/wKiom1N4T2qTvFgAAAC9ZbNV220309.jpg "title=" QQ Pinyin is not named. png "alt=" wkiom1n4t2qtvfgaaac9zbnv220309.jpg "/>
To enable the relay log and modify server_id on slave, edit/etc/my.cnf add the following line under [Mysqld]:
Relay-log =/var/lib/mysql/relay-binserver_id = 11
Connect to the master server and start the replication function
mysql> Change Master to master_host= ' 172.16.254.150 ', master_user= ' repluser ', master_password= ' mypass ', Master_log _file= ' mysql-bin-log.000002 ',master_log_pos=106;mysql> start slave;
To see if the Slave_io, Slave_sql thread is yes
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/28/60/wKiom1N4U9ST-sXEAAFDaZxtNZI113.jpg "title=" QQ Pinyin is not named. png "alt=" wkiom1n4u9st-sxeaafdazxtnzi113.jpg "/>
Second, installation configuration amoeba
Installing the configuration JDK
[Email protected] ~]chmod +x/jdk-6u31-linux-x64-rpm.bin[[email protected] ~]./jdk-6u31-linux-x64-rpm.bin[[email Protected] ~]# vim/etc/profile.d/java.sh Add the following line: Export Java_home=/usr/java/latestexport path= $JAVA _home/bin:$ Path[[email protected] ~]#. /etc/profile.d/java.sh
Installing Amoeba
[[email protected] ~]# mkdir/usr/local/amoeba[[email protected] ~]# tar XF amoeba-mysql-binary-2.2.0.tar.gz-c/usr/loca L/amoeba/[[email protected] ~]# cd/usr/local/amoeba/[[email protected] ~]# Bin/amoeba start
Install the MySQL client to verify that you can connect
[[email protected] ~]# yum-y install mysql[[email protected] ~]# mysql-uroot-h172.16.254.144-p8066-p
Edit the/usr/local/amoeba/conf/amoeba.xml master configuration file
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/28/60/wKiom1N4a-KBKSehAAEzMmDHLbU238.jpg "title=" QQ Pinyin is not named. png "alt=" wkiom1n4a-kbksehaaezmmdhlbu238.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/28/60/wKiom1N4bEvRtdzFAAGTS-f8yzk155.jpg "title=" QQ Pinyin is not named. png "alt=" wkiom1n4bevrtdzfaagts-f8yzk155.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/28/60/wKioL1N4bVKhjebrAADctn-g_Lc769.jpg "title=" QQ Pinyin is not named. png "alt=" wkiol1n4bvkhjebraadctn-g_lc769.jpg "/>
Edit/usr/local/amoeba/conf/dbservers.xml configuration file, define master and Readservers
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/28/60/wKiom1N4buOj2bwgAAInLGnWEx8390.jpg "title=" QQ Pinyin is not named. png "alt=" wkiom1n4buoj2bwgaainlgnwex8390.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/28/60/wKioL1N4b3_iZs-1AAL-yLqXxhg352.jpg "title=" QQ Pinyin is not named. png "alt=" wkiol1n4b3_izs-1aal-ylqxxhg352.jpg "/>
Start amoeba to run in the background, connect amoeba, use tcpdump to grab packets on master, slave server, create a database, and use several query statements to verify that the write is dispatched to master (172.16.254.150). Read operations are dispatched to master and slave in a round robin manner, and can be allocated to read requests from MySQL
[[email protected] mysql]# tcpdump-i eth0-nn-xx IP DST host 172.16.254.150 and TCP DST Port 3306[[email protected] Mysq l]# tcpdump-i eth0-nn-xx IP DST host 172.16.254.151 and TCP DST Port 3306
This article is from "Dream come true" blog, make sure to keep this source http://lyd0721.blog.51cto.com/4894702/1413191