Categories
linux pengkalan data

Apabila semua nod kluster Galera MariaDB shutdown

Tambah atau benarkan “enable_autorecovery=0” pada /etc/cmon.cnf pada nod ClusterControl.

Mulakan semula cmon

admin@cc:~$ sudo service cmon restart

Perhatikan perbezaan nombor “Recovered position” selepas tanda kolon.

admin@db2:~$ sudo mysqld_safe --wsrep-recover
150408 09:38:59 mysqld_safe Logging to '/var/log/mysql.log'.
150408 09:38:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150408 09:38:59 mysqld_safe WSREP: Running position recovery with --log_error='/var/lib/mysql/wsrep_recovery.x2Epct' --pid-file='/var/lib/mysql/db2-recover.pid'
150408 09:39:25 mysqld_safe WSREP: Recovered position 00000000-0000-0000-0000-000000000000:-1
150408 09:39:34 mysqld_safe mysqld from pid file /var/lib/mysql/mysqld.pid ended

admin@db1:~$ sudo mysqld_safe --wsrep-recover
150408 09:40:22 mysqld_safe Logging to '/var/log/mysql.log'.
150408 09:40:22 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150408 09:40:22 mysqld_safe WSREP: Running position recovery with --log_error='/var/lib/mysql/wsrep_recovery.ISjnrN' --pid-file='/var/lib/mysql/db1-recover.pid'
150408 09:40:32 mysqld_safe WSREP: Recovered position 1f6e96d3-dd06-11e4-a086-1a4287304197:92216

Berdasarkan situasi diatas, data db1 lebih terkini, jadi kita bootstrap db1.

admin@db1:~$ sudo mysqld --wsrep_cluster_address=gcomm://

admin@db1:~$ sudo tailf /var/log/mysql.log

Tunggu sampai ada mesej berikut di dalam /var/log/mysql.log

[Note] mysqld: ready for connections.

admin@db2:~$ sudo service mysql start

Tunggu sampai ada mesej berikut di dalam /var/log/mysql.log

[Note] /usr/sbin/mysqld: ready for connections.

Buang tetapan “enable_autorecovery=0” pada /etc/cmon.cnf pada nod ClusterControl.

Mulakan semula cmon

Siap.

Categories
linux pengkalan data

Ralat “ib_logfile0 is of different size”

Masalah ini berlaku semasa cuba bootstrap nod pertama galera cluster selepas konfigurasi my.cnf

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 536870912 bytes!

Buang fail yang bermasalah

sudo rm /var/lib/mysql/ib_logfile*

Bootstrap semula nod tadi

sudo mysqld --wsrep_cluster_address=gcomm://

Categories
linux pengkalan data

Kluster Galera MariaDB (Aktif-Aktif)

OS: Ubuntu 14.04
Untuk situasi dimana kita hanya ada 2 server yang boleh digunakan.

2 node mariadb + 1 node garb/arbiter (elak split-brain)

Pastikan /etc/hosts ada entri ketiga-tiga node. Contoh:

[code lang=’plain’]127.0.0.1 localhost
127.0.1.1 ubuntu
192.168.56.215 db1
192.168.56.216 db2
192.168.56.217 garb[/code]

Pasang mariadb pada kedua-dua node mariadb

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mariadb.nethub.com.hk//repo/10.0/ubuntu trusty main'
sudo apt-get update
sudo apt-get install mariadb-galera-server galera

Pasang garbd pada node garb

sudo apt-get install galera

Matikan service mariadb pada kedua-dua node

sudo service mysql stop

Contoh setting /etc/mysql/my.cnf. Sesuaikan untuk setiap node. srep_cluster_address="gcomm://db2?pc.wait_prim=no" perlu set terbalik seperti ditunjukkan.

[code lang=’plain’][client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

[mysqld_safe]
nice = 0
socket = /var/run/mysqld/mysqld.sock

[mysqld]
basedir = /var/lib/mysql
bind-address = 192.168.56.215
binlog_format = ROW
character_set_server = utf8
collation_server = utf8_general_ci
datadir = /var/lib/mysql
default-storage-engine = InnoDB
expire_logs_days = 10
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 1G
innodb_log_file_size = 512M
innodb_doublewrite = 1
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 60
innodb_locks_unsafe_for_binlog = 1
innodb_stats_on_metadata = 0
key_buffer = 256M
lc-messages-dir = /usr/share/mysql
lock_wait_timeout = 300
max_allowed_packet = 128M
max_binlog_size = 128M
max_connections = 64
myisam-recover = BACKUP
myisam_sort_buffer_size = 64M
net_buffer_length = 8K
open-files-limit = 65535
pid-file = /var/run/mysqld/mysqld.pid
port = 3306
query_cache_limit = 8M
query_cache_size = 16M
read_buffer_size = 8M
read_rnd_buffer_size = 8M
skip-external-locking
socket = /var/run/mysqld/mysqld.sock
sort_buffer_size = 16M
table_cache = 2M
table_definition_cache = 65535
table_open_cache = 65535
thread_cache_size = 8
thread_concurrency = 8
tmpdir = /tmp
user = mysql
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address=”gcomm://db2?pc.wait_prim=no”
wsrep_sst_method=rsync
wsrep_cluster_name=”joomla_db_cluster”

[mysqldump]
max_allowed_packet = 16M
quick
quote-names

[mysql]

[isamchk]
!includedir /etc/mysql/conf.d/
key_buffer = 256M
read_buffer = 16M
sort_buffer_size = 256M
write_buffer = 16M
[/code]

Pada node db1, mulakan cluster mariadb

mysqld --wsrep_cluster_address=gcomm://

Pada nod db1, salin fail debian.cnf ke nod db2

scp /etc/mysql/debian.cnf user1@192.168.56.216:/home/user1/debian.cnf
sudo cp debian.cnf /etc/mysql/

Mulakan mariadb pada node2

sudo service mysql start

Cuba mulakan garbd pada nod garb

sudo garbd -a gcomm://db1:4567,db2:4567?pc.wait_prim=no -g "joomla_db_cluster"

Contoh setting /etc/default/garb pada node garb

[code lang=’plain’]GALERA_NODES=”db1:4567 db2:4567″
GALERA_GROUP=”joomla_db_cluster”
GALERA_OPTIONS=”pc.wait_prim=no”
LOG_FILE=”/var/log/garbd.log”[/code]

Mulakan garbd pada node garb

sudo service garb start

Matikan mariadb pada node db1

sudo service mysql stop

Mulakan semula mariadb pada node db1

sudo service mysql start

Contoh log cluster dengan kesemua node berjalan (semak dalam /var/log/garb.log)

[code lang=’plain’]2015-01-28 22:46:37.658 INFO: Quorum results:
version = 3,
component = PRIMARY,
conf_id = 6,
members = 3/3 (joined/total),
act_id = 0,
last_appl. = 0,
protocols = 0/5/3 (gcs/repl/appl),
group UUID = 1828d0b2-a6ef-11e4-bf0a-3217c0075751
2015-01-28 22:46:37.658 INFO: Flow-control interval: [9999999, 9999999]
2015-01-28 22:46:37.665 INFO: Member 2.0 (db1) synced with group.[/code]