SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
How to Setup Multi-Master Replication using
Tungsten and Mysql-Proxy For Mysql High
Availability on Ubuntu 10.04.3 LTS
This tutorial is based on my experience setting up Tungsten Replicator and Mysql-Proxy for a client's
production setup.


1. My Setup
For the tutorial I'll be using 3 virtual machines

Web Server 1                   : web1               IP Address 192.168.56.101
Master 1                       : master1            IP Address 192.168.56.10
Master 2                       : master2            IP Address 192.168.56.11



2. Setup Web Server
$ sudo su
$ tasksel


select LAMP server and click OK


3. Configuring Mysql-Proxy on the web server
$sudo apt-get -y install mysql-proxy

$vi /etc/default/mysql-proxy


ENABLED="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 = true
proxy-address = 127.0.0.1:3305
proxy-skip-profiling = true
keepalive = true
event-threads = 50
pid-file = /var/run/mysql-proxy.pid
log-file = /var/log/mysql-proxy.log
log-level = debug
proxy-backend-addresses = 192.168.56.10:3306,192.168.56.11:3306
proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/balance.lua

We don't need to start mysql-proxy yet as we still need to configure our backend
4. Configure Mysql Servers
I 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-server


5. Preparing Mysql Servers for Tungsten Replicator Installation
The 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 I've prepared a short list of what I
had 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 servers
auto_increment_increment = 4
# increment offset for this server, next server would be 2
auto_increment_offset = 1


log-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=InnoDB
innodb_flush_log_at_trx_commit=2
sync_binlog=0

# Recommended general settings. max_allowed_packet must be greater than
# the size of the largest transaction.
max_allowed_packet=48m



MYSQL User Permissions

Tungsten uses this account to recreate transactions

$ mysql -u root -p
mysql> grant all on *.* to tungsten@'%' identified by 'secret' with grant option;



Ruby
$ apt-get install -y ruby libopenssl-ruby
To 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 -version



How to set your JAVA_HOME

Edit /etc/bash.bashrc and append the following at the end of the file.

JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JAVA_HOME

Reload bash settings

$source /etc/bash.bashrc



Network
uname -n should resolve to unique name of host
hostname --ip-address resolve to real IP, private IP accepted

cat /etc/hosts
...
192.168.56.10 master1
192.168.56.11 master2
...



SSH

Certificate based ssh login for account used to run tungsten, I used the root account. The machine you're
using to setup Tungsten must be able to ssh without a password to the other machine.

$ sudo su
$ ssh-keygen
$ cat .ssh/id_rsa.pub


On the other machine copy the contents of id_rsa.pub to .ssh/authorized_keys

$ chmod 0600 .ssh/authorized_keys




6. Installing Tungsten Replicator
You only need to install tungsten on one machine and from there you can install additional services to other
nodes.

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.4


I used the following script to configure the master servers.

$ cat setup-masters.sh


#! /bin/bash

TUNGSTEN_HOME=/opt/replication
MASTER1=master1
MASTER2=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-report

After 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 like
this:

master1
master service                 - master1
slave service                  - master2 - copies events from master1 and transfers it to
master2 master service

master2
master service                 - master2
slave service                  - master1 - copies events from master2 and transfers it to
master1 master service

$ cd /opt/replication/tungsten
$ cat setup-slaves.sh


#! /bin/bash
MASTER1=master1
MASTER2=master2
TUNGSTEN_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 zoid

Now let's check if our services are running.

root@master1:/opt/replication/tungsten# tungsten-replicator/bin/trepctl services
Processing services command...
NAME              VALUE
----              -----
appliedLastSeqno: 2296
appliedLatency : 2.178
role            : slave
serviceName     : linus
serviceType     : remote
started         : true
state           : ONLINE
NAME              VALUE
----              -----
appliedLastSeqno: 1611
appliedLatency : 0.953
role            : master
serviceName     : zoid
serviceType     : local
started         : true
state           : ONLINE
Finished services command...


And on master2

root@master1:/opt/replication/tungsten# tungsten-replicator/bin/trepctl services
Processing services command...
NAME              VALUE
----              -----
appliedLastSeqno: 2296
appliedLatency : 2.178
role            : slave
serviceName     : linus
serviceType     : remote
started         : true
state           : ONLINE
NAME              VALUE
----              -----
appliedLastSeqno: 1611
appliedLatency : 0.953
role            : master
serviceName     : zoid
serviceType     : local
started         : true
state           : ONLINE
Finished services command...
7. Start Mysql-Proxy
$ /etc/init.d/mysql-proxy start


Verify that it is running

$ netstat -tulnap | grep 3305




8. Test Replication
Let's test it using phpmyadmin, download and install phpmyadmin and configure it. On you browser go to
http://192.168.56.101/phpmyadmin/ and on the list of servers you should be able to connect to mysql-proxy
and the two other nodes. You can now test and see if your replication is working properly, you can shutdown
one node by unplugging of its ethernet connection, write data to the other node and then turn the other node
back 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;

Contenu connexe

Dernier

Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDeepika Singh
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theorydrae5
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterssuserdfec6a
 
2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing YogaRaphaël Semeteys
 
March 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterMarch 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterssuserdfec6a
 
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxSIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxStephenMino
 
WOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxWOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxpadhand000
 
the Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationthe Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationbrynpueblos04
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...Cara Menggugurkan Kandungan 087776558899
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...mitaliverma221
 

Dernier (10)

Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theory
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletter
 
2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga
 
March 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterMarch 2023 Recommendations for newsletter
March 2023 Recommendations for newsletter
 
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxSIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
 
WOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptxWOMEN EMPOWERMENT women empowerment.pptx
WOMEN EMPOWERMENT women empowerment.pptx
 
the Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentationthe Husband rolesBrown Aesthetic Cute Group Project Presentation
the Husband rolesBrown Aesthetic Cute Group Project Presentation
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
 

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

En vedette (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

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

  • 1. How to Setup Multi-Master Replication using Tungsten and Mysql-Proxy For Mysql High Availability on Ubuntu 10.04.3 LTS This tutorial is based on my experience setting up Tungsten Replicator and Mysql-Proxy for a client's production setup. 1. My Setup For the tutorial I'll be using 3 virtual machines Web Server 1 : web1 IP Address 192.168.56.101 Master 1 : master1 IP Address 192.168.56.10 Master 2 : master2 IP Address 192.168.56.11 2. Setup Web Server $ sudo su $ tasksel select LAMP server and click OK 3. Configuring Mysql-Proxy on the web server $sudo apt-get -y install mysql-proxy $vi /etc/default/mysql-proxy ENABLED="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 = true proxy-address = 127.0.0.1:3305 proxy-skip-profiling = true keepalive = true event-threads = 50 pid-file = /var/run/mysql-proxy.pid log-file = /var/log/mysql-proxy.log log-level = debug proxy-backend-addresses = 192.168.56.10:3306,192.168.56.11:3306 proxy-lua-script=/usr/lib/mysql-proxy/lua/proxy/balance.lua We don't need to start mysql-proxy yet as we still need to configure our backend
  • 2. 4. Configure Mysql Servers I 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-server 5. Preparing Mysql Servers for Tungsten Replicator Installation The 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 I've prepared a short list of what I had 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 servers auto_increment_increment = 4 # increment offset for this server, next server would be 2 auto_increment_offset = 1 log-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=InnoDB innodb_flush_log_at_trx_commit=2 sync_binlog=0 # Recommended general settings. max_allowed_packet must be greater than # the size of the largest transaction. max_allowed_packet=48m MYSQL User Permissions Tungsten uses this account to recreate transactions $ mysql -u root -p mysql> grant all on *.* to tungsten@'%' identified by 'secret' with grant option; Ruby $ apt-get install -y ruby libopenssl-ruby To test:
  • 3. $ 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 -version How to set your JAVA_HOME Edit /etc/bash.bashrc and append the following at the end of the file. JAVA_HOME=/usr/lib/jvm/java-6-openjdk export JAVA_HOME Reload bash settings $source /etc/bash.bashrc Network uname -n should resolve to unique name of host hostname --ip-address resolve to real IP, private IP accepted cat /etc/hosts ... 192.168.56.10 master1 192.168.56.11 master2 ... SSH Certificate based ssh login for account used to run tungsten, I used the root account. The machine you're using to setup Tungsten must be able to ssh without a password to the other machine. $ sudo su $ ssh-keygen $ cat .ssh/id_rsa.pub On the other machine copy the contents of id_rsa.pub to .ssh/authorized_keys $ chmod 0600 .ssh/authorized_keys 6. Installing Tungsten Replicator You only need to install tungsten on one machine and from there you can install additional services to other nodes. Binary Build Download
  • 4. $ 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.4 I used the following script to configure the master servers. $ cat setup-masters.sh #! /bin/bash TUNGSTEN_HOME=/opt/replication MASTER1=master1 MASTER2=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-report After 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 like this: master1 master service - master1 slave service - master2 - copies events from master1 and transfers it to master2 master service master2 master service - master2 slave service - master1 - copies events from master2 and transfers it to master1 master service $ cd /opt/replication/tungsten $ cat setup-slaves.sh #! /bin/bash MASTER1=master1 MASTER2=master2 TUNGSTEN_TOOLS=tools $TUNGSTEN_TOOLS/configure-service --host $MASTER1 -C -q --local-service-name=zoid
  • 5. --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 zoid Now let's check if our services are running. root@master1:/opt/replication/tungsten# tungsten-replicator/bin/trepctl services Processing services command... NAME VALUE ---- ----- appliedLastSeqno: 2296 appliedLatency : 2.178 role : slave serviceName : linus serviceType : remote started : true state : ONLINE NAME VALUE ---- ----- appliedLastSeqno: 1611 appliedLatency : 0.953 role : master serviceName : zoid serviceType : local started : true state : ONLINE Finished services command... And on master2 root@master1:/opt/replication/tungsten# tungsten-replicator/bin/trepctl services Processing services command... NAME VALUE ---- ----- appliedLastSeqno: 2296 appliedLatency : 2.178 role : slave serviceName : linus serviceType : remote started : true state : ONLINE NAME VALUE ---- ----- appliedLastSeqno: 1611 appliedLatency : 0.953 role : master serviceName : zoid serviceType : local started : true state : ONLINE Finished services command...
  • 6. 7. Start Mysql-Proxy $ /etc/init.d/mysql-proxy start Verify that it is running $ netstat -tulnap | grep 3305 8. Test Replication Let's test it using phpmyadmin, download and install phpmyadmin and configure it. On you browser go to http://192.168.56.101/phpmyadmin/ and on the list of servers you should be able to connect to mysql-proxy and the two other nodes. You can now test and see if your replication is working properly, you can shutdown one node by unplugging of its ethernet connection, write data to the other node and then turn the other node back 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;