MYSQL GALERA部署实录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MYSQL GALERA部署实录相关的知识,希望对你有一定的参考价值。
[[email protected] ~]# yum install bison bison-devel check check-devel boost boost-devel scons socat perl-DBD-mysql
[[email protected] ~]# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
[[email protected] ~]# rpm -ivh percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm
[[email protected] ~]# tar zxvf mysql-wsrep-5.6.38-25.21.tar.gz
[[email protected] ~]# cd mysql-wsrep-5.6.38-25.21
[[email protected] mysql-wsrep-5.6.38-25.21]# cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1
[[email protected] mysql-wsrep-5.6.38-25.21]# make && make install
[[email protected] mysql-wsrep-5.6.38-25.21]# cd support-files/
[[email protected] mysql-wsrep-5.6.38-25.21]# cp mysql.server /etc/init.d/mysqld
[[email protected] ~]# vi /etc/my.cnf
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so
wsrep_provider_options="gcache.size=300M; gcache.page_size=300M"
wsrep_cluster_name = "my_wsrep_cluster"
wsrep_cluster_address = "gcomm://192.168.1.201,192.168.1.202"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sst:sst
wsrep_node_name = king01
wsrep_node_address="192.168.1.201"
log_bin = mysql-bin
binlog_format = row
sync_binlog = 1
binlog_cache_size = 16M
max_binlog_cache_size = 32M
max_binlog_size = 512M
expire_logs_days = 7
[[email protected] ~]# tar zxvf galera-3-25.3.22.tar.gz
[[email protected] ~]# cd galera-3-25.3.22
[[email protected] galera-3-25.3.22]# scons
[[email protected] galera-3-25.3.22]# cp libgalera_smm.so /usr/local/mysql/lib/
[[email protected] galera-3-25.3.22]# cp garb/garbd /usr/local/mysql/bin
[[email protected] ~]# cd /usr/local/mysql/
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[[email protected] ~]# service mysqld start --wsrep-new-cluster
[[email protected] ~]# mysql_secure_installation
[[email protected] ~]# mysql -uroot -pabcd.1234
mysql> grant usage on *.* to [email protected]'localhost' identified by 'sst';
Query OK, 0 rows affected (0.05 sec)
mysql> grant all privileges on *.* to [email protected]'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[[email protected] ~]# netstat -tunlp | grep mysqld
tcp 0 0 0.0.0.0:4567 0.0.0.0:* LISTEN 18117/mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 18117/mysqld
[[email protected] ~]# rpm -ivh epel-release-6-8.noarch.rpm
[[email protected] ~]# yum install bison bison-devel check check-devel boost boost-devel scons socat perl-DBD-MySQL
[[email protected] ~]# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
[[email protected] ~]# rpm -ivh percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm
[[email protected] ~]# tar zxvf mysql-wsrep-5.6.38-25.21.tar.gz
[[email protected] ~]# cd mysql-wsrep-5.6.38-25.21
[[email protected] mysql-wsrep-5.6.38-25.21]# cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1
[[email protected] mysql-wsrep-5.6.38-25.21]# make && make install
[[email protected] mysql-wsrep-5.6.38-25.21]# cd support-files/
[[email protected] mysql-wsrep-5.6.38-25.21]# cp mysql.server /etc/init.d/mysqld
[[email protected] ~]# vi /etc/my.cnf
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so
wsrep_provider_options="gcache.size=300M; gcache.page_size=300M"
wsrep_cluster_name = "my_wsrep_cluster"
wsrep_cluster_address = "gcomm://192.168.1.201,192.168.1.202"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sst:sst
wsrep_node_name = king02
wsrep_node_address="192.168.1.202"
log_bin = mysql-bin
binlog_format = row
sync_binlog = 1
binlog_cache_size = 16M
max_binlog_cache_size = 32M
max_binlog_size = 512M
expire_logs_days = 7
[[email protected] ~]# tar zxvf galera-3-25.3.22.tar.gz
[[email protected] ~]# cd galera-3-25.3.22
[[email protected] galera-3-25.3.22]# scons
[[email protected] galera-3-25.3.22]# cp libgalera_smm.so /usr/local/mysql/lib/
[[email protected] galera-3-25.3.22]# cp garb/garbd /usr/local/mysql/bin
[[email protected] ~]# cd /usr/local/mysql/
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[[email protected] ~]# service mysqld start
[[email protected] ~]# netstat -tunlp | grep mysqld
tcp 0 0 0.0.0.0:4567 0.0.0.0:* LISTEN 18364/mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 18364/mysqld
以上是关于MYSQL GALERA部署实录的主要内容,如果未能解决你的问题,请参考以下文章
Percona Mysql Galera多读写集群部署生产环境实记