percona的安装涉及到percona server 和 percona cluster,这里主要讲解percona的cluster,我们主要用到的就是percona cluster。
一、安装
安装详情见官网:
https://www.percona.com/doc/percona-xtradb-cluster/5.6/index.html
二、配置
主要讲解我们使用到的配置。
percona1也就是第一台percona的my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
character-set-server=utf8
collation-server=utf8_bin
default-storage-engine=INNODB
max_allowed_packet=512M
innodb_log_file_size=256M
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_address=gcomm://
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.0.1
wsrep_node_incoming_address=10.0.0.1
wsrep_sst_receive_address=10.0.0.1
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=percona-xtradb-primary
wsrep_node_name=percona-xtradb-node1
wsrep_sst_auth="manager:password"
key_buffer = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
max_connections = 300
query_cache_limit = 1M
query_cache_size = 16M
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
expire_logs_days = 10
max_binlog_size = 100M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M
percona2也就是第一台percona的my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
character-set-server=utf8
collation-server=utf8_bin
default-storage-engine=INNODB
max_allowed_packet=512M
innodb_log_file_size=256M
bind-address = 127.0.0.1
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.0.1,10.0.0.2
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.0.2
wsrep_node_incoming_address=10.0.0.2
wsrep_sst_receive_address=10.0.0.2
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=percona-xtradb-primary
wsrep_node_name=percona-xtradb-node2
wsrep_sst_auth="manage:password"
key_buffer = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 16M
general_log_file = /var/log/mysql/mysql.log
general_log = 1
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
expire_logs_days = 10
max_binlog_size = 100M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
[isamchk]
key_buffer = 16M
我的环境是在Ubuntu14.04上使用repository安装的。
第一台percona启动的方法是:
service mysql bootstrap-pxc
重启:
service mysql restart-bootstrap
第二台percona启动的方法是:
service mysql start
重启:
service mysql restart
里面有些参数还可以进行优化。
本文转自ting2junshui51CTO博客,原文链接:http://blog.51cto.com/ting2junshui/1704465 ,如需转载请自行联系原作者