MariaDB Galera Clusterãã¤ã³ã¹ãã¼ã«ãã¦ãã¼ã¿ãã¼ã¹ãã¯ã©ã¹ã¿ã¼å
æ°ãµã¼ãã¹ã®ãµã¼ãã¼æ§æãèãã¦ããã¨ãã®è¦æ¸。
ç°å¢: CentOS 6.5 x86_64, MariaDB Galera Server 10.0.13
åã®è¨äºãåèã«。
ãµã¼ãã¹å ¨ä½ã®ãµã¼ãã¼æ§æ。
ãã¼ããã©ã³ãµã¼02ãWeb02ãããã°ããã«å®å¿ã§ãã。
ã¡ãªã¿ã«MariaDB Galera Clusterã®æå°ãã¼ãæ°ã¯「3」。ä»åã¯ãã¼ã¿ãã¼ã¹ãã¯ã©ã¹ã¿ã¼åããã¾ã§。
åèãµã¤ã
- MariaDB Galera Clusterã試ã (1) | ãããã¤ã³ã¿ã¼ãããç 究æ
- Galera - MariaDB Knowledge Base
- CentOS 6.5 㧠MariaDB ã® Galera Replication Cluster ã試ã | CUBE SUGAR STORAGE
ç®æ¬¡
- YUMçµç±ã§ã¤ã³ã¹ãã¼ã«
- èµ·åã¨è¨å®
- ï¼å°ç®ä»¥éã®ãã¼ãè¨å®
- ã¯ã©ã¹ã¿ã¼ã«åå
ï¼.YUMçµç±ã§ã¤ã³ã¹ãã¼ã«
å ¬å¼ãµã¤ããåèã«YUMã®ãªãã¸ããªã追å ãã。
[web01]# vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
ã¤ã³ã¹ãã¼ã«å®è¡
[web01]# yum search MariaDB
[web01]# yum install MariaDB-Galera-server
epelãªãã¸ããªã使ã£ãã®ã§、åã®è¨äºãåèã«ç»é²ããæ¹ããããã。
ã¯ã©ã¹ã¿ã¼æ§æãªã®ã§å¸¸ã«ç¨¼åããåæ。ã¡ã³ããã³ã¹ã§åæ¢ããã¨ãã¯æåã§èµ·åããããèªåèµ·åã¯ããªãããã«ãã¦ãã。
[web01]# chkconfig mysql off
ï¼.èµ·åã¨è¨å®
å ¬å¼ããã¥ã¡ã³ãã«å¾ã。
è¨å®ãã¡ã¤ã«ãç·¨é
[web01]# vi /etc/my.cnf.d/server.cnf
[mysqld]
thread_handling = pool-of-threads
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
max_connections = 500# Tuning
sort_buffer_size = 1MB
read_rnd_buffer_size = 1MB
join_buffer_size = 1MB
query_cache_size=16M#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name=hoge-cluster
wsrep_cluster_address=gcomm://
wsrep_node_name=WEB01
wsrep_node_address=192.168.0.2
wsrep_slave_threads=8
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
「wsrep_provider」「wsrep_cluster_address」ã¯ãªãã¦ãè¯ãããã ãã©、ã³ã¡ã³ãã¢ã¦ããããåããªãã£ã。
æåã®ãã¼ãã¨ãã¦èµ·åãã。èµ·åã¹ã¯ãªãããèªãã¨「bootstrap」ãæå®ããã¨「--wsrep-new-cluster」ã¨ãã¦å®è¡ãã¦ãããã¿ãã。
[web01]# /etc/rc.d/init.d/mysql bootstrap
ã»ãã¥ãªãã£ã®åæè¨å®
[web01]# mysql_secure_installation
èµ·åç¶æ
ã確èª
[web01]# mysql -u root -p
> SHOW GLOBAL VARIABLES LIKE 'wsrep_%';
MySQLã³ã³ã½ã¼ã«çµäº
> quit
åãã¼ãã¨ã®éä¿¡ã«ä½¿ããã¼ããéãã。
åè:Galera Cluster Address - MariaDB Knowledge Base
åè:ç¿ãããæ
£ãã! iptablesãã³ãã¬ã¼ãé(1):ã¹ãã¼ããã«ãã±ãããã£ã«ã¿ã使ã£ããµã¼ãã¹ã®å
Ž (2/6) - @IT
[web01]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -s 192.168.0.0/24 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4567 -s 192.168.0.0/24 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4444 -s 192.168.0.0/24 -j ACCEPT
ã¡ãªã¿ã«4444ã¯rsyncã使ã。
åæ 。確èª。
[web01]# /etc/rc.d/init.d/iptables reload
[web01]# /etc/rc.d/init.d/iptables status
ï¼.ï¼çªç®ä»¥éã®ãã¼ãè¨å®
ã¤ã³ã¹ãã¼ã«ã¾ã§ã¯ä¸ç·。
èªåèµ·åããªãããã«ãã¦ãã。
[app01]# chkconfig mysql off
è¨å®ãã¡ã¤ã«ãç·¨é
[app01]# vi /etc/my.cnf.d/server.cnf
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
thread_handling = pool-of-threads
max_connections = 500# Tuning
sort_buffer_size = 1MB
read_rnd_buffer_size = 1MB
join_buffer_size = 1MB
query_cache_size=16M#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name=hoge-cluster
wsrep_cluster_address=gcomm://
wsrep_node_name=APP01
wsrep_node_address=192.168.0.3
wsrep_slave_threads=8
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
赤æå以å¤ã¯ä¸ç·。
ã¼ã¼ã¼ ãããã。å¾ã§æ°ä»ããã¯ã©ã¹ã¿ã¼ã«åå ããã®ã§ä¸è¦ãªè¨å®
ã¯ã©ã¹ã¿ã¼ã«åå ããèµ·å
[app01]# /etc/rc.d/init.d/mysql start
[app01]# mysql_secure_installation
Web01ä¸ã®phpMyAdminãããã°ã¤ã³ã§ããã¦ã¼ã¶ã¼ãä½æãã。
åè:MySQL :: MySQL 4.1 ãªãã¡ã¬ã³ã¹ããã¥ã¢ã« :: 4.4.5 MySQL ã¸ã®æ°è¦ã¦ã¼ã¶ã®è¿½å
[app01]# mysql -p -u root mysql
> GRANT ALL PRIVILEGES ON *.* TO admin@localhost IDENTIFIED BY 'admin#1sec' WITH GRANT OPTION;
> GRANT ALL PRIVILEGES ON *.* TO admin@'192.168.0.%' IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
> select host, user from user;
> quit
。。。ã¨ãã£ããã©、åæå¾(ã¯ã©ã¹ã¿ã¼ã«åå å¾)ã¯WEB01ã§ä¸æ¸ããããã®ã§WEB01ã§è¨å®ãã¦ããã°å¤§ä¸å¤«ã ã£ã。
ã¼ã¼ã¼ ããã¾ã§。å¾ã§æ°ä»ããã¯ã©ã¹ã¿ã¼ã«åå ããã®ã§ä¸è¦ãªè¨å®
次ã¯ãã¡ã¤ã¤ã¼ã¦ã©ã¼ã«(iptables)ãè¨å®。WEB01ã¨åã。ãã¼ã«ã«IP以å¤ã¯ã¢ã¯ã»ã¹ä¸å¯ã«ãã。
[app01]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -s 192.168.0.0/24 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4567 -s 192.168.0.0/24 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4444 -s 192.168.0.0/24 -j ACCEPT
iptablesãåæ ãã¦ç¢ºèª。
[app01]# /etc/rc.d/init.d/iptables reload
[app01]# /etc/rc.d/init.d/iptables status
Web01ä¸ã®phpMyAdminããApp01ã®ãã¼ã¿ãã¼ã¹ã確èªã§ããããã«ãã¦ãã。
[web01]# cd /home/httpd/httpdocs/phpMyAdmin/
[web01]# cp config.sample.inc.php config.inc.php
[web01]# vi config.inc.php
/*
* First server(WEB01)
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;/*
* Second server(APP01)
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '192.168.0.3';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
ä¸è¨ã«ã¢ã¯ã»ã¹ããã¨Cookieç¨ã®ã©ã³ãã æååãçæãã¦ããã。
phpMyAdminããåãµã¼ãã¼ã«æ¥ç¶ã§ãããã¨ã確èª。
ï¼.ã¯ã©ã¹ã¿ã¼ã«åå
APP01ä¸ã§ä½æ¥。ã¾ãã¯ä¸æ¦åæ¢。
[app01]# /etc/rc.d/init.d/mysql stop
ã¯ã©ã¹ã¿ã¼ã®ãã¼ãã¨ãã¦èµ·å。gcommã«æå®ãããã¼ãã¯ã¯ã©ã¹ã¿ã¼ã«åå ãã¦ãããã¼ãã§ããã°ã©ãã§ãããããã。èªåçã«ä»ã®ãã¼ãã«ãä¼æ¬ããã。
[app01]# /etc/rc.d/init.d/mysql start --wsrep_cluster_address=gcomm://192.168.0.2
ã¨ã©ã¼ã«ãªã£ãå ´åã¯ãã°ã確èª
[app01]# less /var/lib/mysql/app01.hoge.com.err
æåããå ´åã¯ç¶æ
ã確èª
[app01]# mysql -p -u root
> SHOW STATUS LIKE 'wsrep_%';
| wsrep_local_state_comment | Synced
| wsrep_incoming_addresses | 192.168.0.2:3306,192.168.0.3:3306
phpMyAdminãã、WEB01ä¸ã§ãã¼ãã«ãä½ã£ã¦ããAPP01ä¸ã§åé¤ããããã¦åæãããã確èª。
ãã®è¨å®ã ã¨èµ·åããã¨ãã«「wsrep_cluster_address」ãªãã·ã§ã³ãä»ããªãã¨ã¯ã©ã¹ã¿ã¼ã«åå ããªãã®ã§æ³¨æ。
ä¸åº¦ã¯ã©ã¹ã¿ã¼ãæ§æãã¦ãã¾ãã°、å ¨ã¦ããã©ã¤ããªãªã®ã§æåã«bootstrapã§èµ·åãããã¼ã(WEB01)ã「wsrep_cluster_address」ãä»ãã¦åèµ·åããå¿ è¦ããã。
å ¨ã¦ããã©ã¤ããªã¨ããæè¦ããã¹ã¿ã¼・ã¹ã¬ã¤ãã«æ £ãã¦ããã¨æåæ¸æã。「ã©ãããã¹ã¿ã¼?」ã¨èãã¦ãã¾ã。
< 2014/09/25 Modified >
注æäºé
。詳ããã¯å
¬å¼ããã¥ã¡ã³ããåèã«。MariaDB Galera Cluster - Known Limitations - MariaDB Knowledge Base
- InnoDBããåæããªã。MyISAMã¯Insertãããã¨ä»ã®Nodeã«åæ ãããªã。
- å ¨ã¦ã®ãã¼ãã«ã¯Primary Keyãæã¤å¿ è¦ããã。
< Related Posts >