SlideShare uma empresa Scribd logo
1 de 6
Baixar para ler offline
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;

Mais conteúdo relacionado

Último

$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...PsychicRuben LoveSpells
 
The Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushThe Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushShivain97
 
call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..nishakur201
 
Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666nishakur201
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfpastor83
 
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual serviceanilsa9823
 
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)Delhi Call girls
 
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girlsPooja Nehwal
 
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceanilsa9823
 
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)Delhi Call girls
 
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceanilsa9823
 
Lilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxLilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxABMWeaklings
 
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morvikas rana
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theorydrae5
 
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceanilsa9823
 
Introducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfIntroducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfnoumannajam04
 
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...anilsa9823
 

Último (20)

$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
$ Love Spells^ 💎 (310) 882-6330 in West Virginia, WV | Psychic Reading Best B...
 
The Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushThe Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by Mindbrush
 
call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..
 
Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666Call Girls Anjuna beach Mariott Resort ₰8588052666
Call Girls Anjuna beach Mariott Resort ₰8588052666
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdf
 
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
 
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
 
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
 
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
 
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
 
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
 
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Adil Nagar Lucknow best Female service
 
Lilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxLilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptx
 
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
 
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theory
 
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
 
Introducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfIntroducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdf
 
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
 

Destaque

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
 

Destaque (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;