How to setup multi master replication using tungsten and mysql-proxy for mysql high availability on ubuntu 10.04
Upcoming SlideShare
Loading in...5
×
 

How to setup multi master replication using tungsten and mysql-proxy for mysql high availability on ubuntu 10.04

on

  • 1,491 views

This tutorial is based on my experience setting up Tungsten Replicator and Mysql-Proxy for a client's production setup.

This tutorial is based on my experience setting up Tungsten Replicator and Mysql-Proxy for a client's production setup.

Statistics

Views

Total Views
1,491
Views on SlideShare
1,491
Embed Views
0

Actions

Likes
0
Downloads
20
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

How to setup multi master replication using tungsten and mysql-proxy for mysql high availability on ubuntu 10.04 How to setup multi master replication using tungsten and mysql-proxy for mysql high availability on ubuntu 10.04 Document Transcript

  • How to Setup Multi-Master Replication usingTungsten and Mysql-Proxy For Mysql HighAvailability on Ubuntu 10.04.3 LTSThis tutorial is based on my experience setting up Tungsten Replicator and Mysql-Proxy for a clientsproduction setup.1. My SetupFor the tutorial Ill be using 3 virtual machinesWeb Server 1 : web1 IP Address 192.168.56.101Master 1 : master1 IP Address 192.168.56.10Master 2 : master2 IP Address 192.168.56.112. Setup Web Server$ sudo su$ taskselselect LAMP server and click OK3. Configuring Mysql-Proxy on the web server$sudo apt-get -y install mysql-proxy$vi /etc/default/mysql-proxyENABLED="true"OPTIONS="--defaults-file=/root/mysql-proxy.cnf"The defaults-file option should point to where you have saved /root/mysql-proxy.cnf[mysql-proxy]daemon = trueproxy-address = 127.0.0.1:3305proxy-skip-profiling = truekeepalive = trueevent-threads = 50pid-file = /var/run/mysql-proxy.pidlog-file = /var/log/mysql-proxy.loglog-level = debugproxy-backend-addresses = 192.168.56.10:3306,192.168.56.11:3306proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/balance.luaWe dont need to start mysql-proxy yet as we still need to configure our backend
  • 4. Configure Mysql ServersI actually only configured one and just cloned it after I have setup everything and just changed the/et/hostname, /etc/hosts and /etc/network/interfaces to match the settings for the second server.sudo su apt-get install -y mysql-server5. Preparing Mysql Servers for Tungsten Replicator InstallationThe host requirements can be found here https://s3.amazonaws.com/releases.continuent.com/doc/replicator-2.0.4/html/Tungsten-Installation-Guide-mysql/content/ch05.html however Ive prepared a short list of what Ihad to configure to get my setup working.MYSQL$ cat /etc/mysql/my.cnf[mysqld]# Master replication settings.server-id=1# set increment for up to 4 serversauto_increment_increment = 4# increment offset for this server, next server would be 2auto_increment_offset = 1log-bin=mysql-bin# Required InnoDB parameter settings for Tungsten. Buffer pool size may be# larger but should not be smaller for production deployments.innodb_buffer_pool_size = 512M# Recommended InnoDB settings for Tungsten.default-table-type=InnoDBinnodb_flush_log_at_trx_commit=2sync_binlog=0# Recommended general settings. max_allowed_packet must be greater than# the size of the largest transaction.max_allowed_packet=48mMYSQL User PermissionsTungsten uses this account to recreate transactions$ mysql -u root -pmysql> grant all on *.* to tungsten@% identified by secret with grant option;Ruby$ apt-get install -y ruby libopenssl-rubyTo test:
  • $ echo "p hello" | ruby -ropenssl"hello"JAVA Virtual Machine$ apt-get install openjdk-6-jre$ echo $JAVA_HOME //Should point to Sun JDK install location$ java -versionHow to set your JAVA_HOMEEdit /etc/bash.bashrc and append the following at the end of the file.JAVA_HOME=/usr/lib/jvm/java-6-openjdkexport JAVA_HOMEReload bash settings$source /etc/bash.bashrcNetworkuname -n should resolve to unique name of hosthostname --ip-address resolve to real IP, private IP acceptedcat /etc/hosts...192.168.56.10 master1192.168.56.11 master2...SSHCertificate based ssh login for account used to run tungsten, I used the root account. The machine youreusing to setup Tungsten must be able to ssh without a password to the other machine.$ sudo su$ ssh-keygen$ cat .ssh/id_rsa.pubOn the other machine copy the contents of id_rsa.pub to .ssh/authorized_keys$ chmod 0600 .ssh/authorized_keys6. Installing Tungsten ReplicatorYou only need to install tungsten on one machine and from there you can install additional services to othernodes.Binary Build Download
  • $ wget http://tungsten-replicator.googlecode.com/files/tungsten-replicator-2.0.4.tar.gz$ tar -zxvf tungsten-replicator-2.0.4.tar.gz$ cd tungsten-replicator-2.0.4I used the following script to configure the master servers.$ cat setup-masters.sh#! /bin/bashTUNGSTEN_HOME=/opt/replicationMASTER1=master1MASTER2=master2./tools/tungsten-installer --master-slave --master-host=$MASTER1 --datasource-user=tungsten --datasource-password=secret --service-name=zoid --home-directory=$TUNGSTEN_HOME --cluster-hosts=$MASTER1 --start-and-report ./tools/tungsten-installer --master-slave --master-host=$MASTER2 --datasource-user=tungsten --datasource-password=secret --service-name=linus --home-directory=$TUNGSTEN_HOME --cluster-hosts=$MASTER2 --start-and-reportAfter running the above script the tungsten home directory will be populated, this is in /opt/replication/Inside this folder execute the script to setup the slave services for each master. Our setup is basically likethis:master1master service - master1slave service - master2 - copies events from master1 and transfers it tomaster2 master servicemaster2master service - master2slave service - master1 - copies events from master2 and transfers it tomaster1 master service$ cd /opt/replication/tungsten$ cat setup-slaves.sh#! /bin/bashMASTER1=master1MASTER2=master2TUNGSTEN_TOOLS=tools$TUNGSTEN_TOOLS/configure-service --host $MASTER1 -C -q --local-service-name=zoid
  • --role=slave --service-type=remote --datasource=$MASTER1 --master-thl-host=$MASTER2 --svc-start linus$TUNGSTEN_TOOLS/configure-service --host $MASTER2 -C -q --local-service-name=linus --role=slave --service-type=remote --datasource=$MASTER2 --master-thl-host=$MASTER1 --svc-start zoidNow lets check if our services are running.root@master1:/opt/replication/tungsten# tungsten-replicator/bin/trepctl servicesProcessing services command...NAME VALUE---- -----appliedLastSeqno: 2296appliedLatency : 2.178role : slaveserviceName : linusserviceType : remotestarted : truestate : ONLINENAME VALUE---- -----appliedLastSeqno: 1611appliedLatency : 0.953role : masterserviceName : zoidserviceType : localstarted : truestate : ONLINEFinished services command...And on master2root@master1:/opt/replication/tungsten# tungsten-replicator/bin/trepctl servicesProcessing services command...NAME VALUE---- -----appliedLastSeqno: 2296appliedLatency : 2.178role : slaveserviceName : linusserviceType : remotestarted : truestate : ONLINENAME VALUE---- -----appliedLastSeqno: 1611appliedLatency : 0.953role : masterserviceName : zoidserviceType : localstarted : truestate : ONLINEFinished services command...
  • 7. Start Mysql-Proxy$ /etc/init.d/mysql-proxy startVerify that it is running$ netstat -tulnap | grep 33058. Test ReplicationLets test it using phpmyadmin, download and install phpmyadmin and configure it. On you browser go tohttp://192.168.56.101/phpmyadmin/ and on the list of servers you should be able to connect to mysql-proxyand the two other nodes. You can now test and see if your replication is working properly, you can shutdownone node by unplugging of its ethernet connection, write data to the other node and then turn the other nodeback on.For more information regarding: • Tungsten visit their Wiki. • Mysql Proxy visit their Homepage$i++;/* Authentication type */$cfg[Servers][$i][auth_type] = cookie;/* Server parameters */$cfg[Servers][$i][host] = 127.0.0.1;$cfg[Servers][$i][port] = 3305;$cfg[Servers][$i][connect_type] = tcp;$cfg[Servers][$i][compress] = false;/* Select mysqli if your server has it */$cfg[Servers][$i][extension] = mysqli;$cfg[Servers][$i][AllowNoPassword] = false;$i++;/* Authentication type */$cfg[Servers][$i][auth_type] = cookie;/* Server parameters */$cfg[Servers][$i][host] = 192.168.56.10;$cfg[Servers][$i][port] = 3306;$cfg[Servers][$i][connect_type] = tcp;$cfg[Servers][$i][compress] = false;/* Select mysqli if your server has it */$cfg[Servers][$i][extension] = mysqli;$cfg[Servers][$i][AllowNoPassword] = false;$i++;/* Authentication type */$cfg[Servers][$i][auth_type] = cookie;/* Server parameters */$cfg[Servers][$i][host] = 192.168.56.11;$cfg[Servers][$i][port] = 3306;$cfg[Servers][$i][connect_type] = tcp;$cfg[Servers][$i][compress] = false;/* Select mysqli if your server has it */$cfg[Servers][$i][extension] = mysqli;$cfg[Servers][$i][AllowNoPassword] = false;