8. # 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
innodb_buffer_pool_size = 512M
# Recommended InnoDB settings for Tungsten.
default-storage-engine=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
default-table-type=InnoDB
innodb_flush_log_at_trx_commit=2
master2
ทำการแก้ไขไฟล์ configuration ของ MySQL
$ sudo vim /etc/mysql/my.cnf
แก้ไขข้อมูลของ MySQL configuration ดังนี้
[mysqld]
#bind-address = 127.0.0.1
server-id = 2
# set increment for up to 4 servers
auto_increment_increment = 4
# increment offset for this server, next server would be 2
auto_increment_offset = 2
log_bin = mysql-bin
8/18
9. innodb_buffer_pool_size = 512M
# Recommended InnoDB settings for Tungsten.
default-storage-engine=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
default-table-type=InnoDB
innodb_flush_log_at_trx_commit=2
การสร้าง MySQL user
ทั้ง master1 และ master2 ให้เพิ่ม user tungsten ให้ฐานข้อมูล MySQL ดังนี้
$ mysql -u root -p
mysql> grant all on *.* to tungsten@'%' identified by 'tungsten' with grant option;
mysql> FLUSH PRIVILEGES;
การติดตั้ง Ruby
ติดตั้ง Ruby และ library ที่จำเป็นใน master1 และ master2
$ sudo apt-get install -y ruby libopenssl-ruby
ทดสอบ Ruby ว่าติดตั้งเรียบร้อยหรือไม่
$ echo "p 'hello'" | ruby -ropenssl
จะต้องแสดงข้อความ "hello"
9/18
18. Reference
[1] Tungsten Replicator, Available At. URL: http://code.google.com/p/tungsten-replicator/
[2] Tungsten Replicator cookbook. Advanced replication topologies made easy, Available At. URL:
http://datacharmer.blogspot.com/2012/10/tungsten-replicator-cookbook-advanced.html
[3] How To Set Up Multi-Master Replication Using Tungsten And MySQL-Proxy For MySQL High Availability On
Ubuntu 10.04.3 LTS; http://www.howtoforge.com/how-to-set-up-multi-master-replication-using-tungsten-and-
mysql-proxy-for-mysql-high-availability-on-ubuntu-10.04.3-lts
[4] Tungsten Replicator Pre-Requisites; http://code.google.com/p/tungsten-replicator/wiki/InstallationPreRequisites
[5] Understanding Tungsten Replication Services; http://scale-out-blog.blogspot.com/2011/03/understanding-
tungsten-replication.html
[6] Tungsten Replication for MySQL users; http://code.google.com/p/tungsten-replicator/wiki/Cheat_Sheet
[7] How To Back Up MySQL Databases With mylvmbackup On Debian Squeeze;
http://www.howtoforge.com/how-to-back-up-mysql-databases-with-mylvmbackup-on-debian-squeeze
18/18