标签:
分布式系统的CAP理论:
C 一致性,所有的节点数据一致
A 可用性,一个或者多个节点失效,不影响服务请求
P 分区容忍性,节点间的连接失效,仍然可以处理请求
任何一个分布式系统,需要满足这三个中的两个
安装部署
三个node节点
yum -y groupinstall Base Compatibility libraries Debugging Tools Dial-up Networking suppport Hardware monitoring utilities Performance Tools Development tools
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm -y
yum install Percona-XtraDB-Cluster-55 -y
选择一个node作为名义上的master,咱们以node1为master,以下操作只在node1上执行。
只需要修改mysql的配置文件--/etc/my.cnf
说明:这里的IP地址是内网地址。
[root@i-kysyolko ~]# cat /etc/my.cnf
# Template my.cnf for PXC
# Edit to your requirements.
[mysqld]
datadir=/var/lib/mysql
user=mysql
# Path to Galera library
wsrep_provider=/usr/lib64/libgalera_smm.so
# Cluster connection URL contains the IPs of node#1, node#2 and node#3
wsrep_cluster_address=gcomm://192.168.100.7,192.168.100.8,192.168.100.9
# In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW
# MyISAM storage engine has only experimental support
default_storage_engine=InnoDB
# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2
# Node #1 address
wsrep_node_address=192.168.100.7
# SST method
wsrep_sst_method=xtrabackup-v2
# Cluster name
wsrep_cluster_name=my_centos_cluster
# Authentication for SST method
wsrep_sst_auth="sstuser:s3cret"
[mysqld_safe]
pid-file = /run/mysqld/mysql.pid
syslog
!includedir /etc/my.cnf.d
CentOS6:/etc/init.d/mysql bootstrap-pxc
CentOS7:systemctl start mysql@bootstrap.service
mysql> show status like ‘wsrep%‘;
+----------------------------+--------------------------------------+
| Variable_name | Value |
+----------------------------+--------------------------------------+
| wsrep_local_state_uuid | c2883338-834d-11e2-0800-03c9c68e41ec |
...
| wsrep_local_state | 4 |
| wsrep_local_state_comment | Synced |
...
| wsrep_cluster_size | 1 #主要看这里 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
...
| wsrep_ready | ON |
+----------------------------+--------------------------------------+
40 rows in set (0.01 sec)
# 数据库用户名密码的设置
mysql@percona1> UPDATE mysql.user SET password=PASSWORD("Passw0rd") where user=‘root‘;
# 创建、授权、同步账号
mysql@percona1> CREATE USER ‘sstuser‘@‘localhost‘ IDENTIFIED BY ‘s3cret‘;
mysql@percona1> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO ‘sstuser‘@‘localhost‘;
mysql@percona1> FLUSH PRIVILEGES;
wsrep_node_address=192.168.100.8
[root@i-kysyolko ~]# cat /etc/my.cnf
# Template my.cnf for PXC
# Edit to your requirements.
[mysqld]
datadir=/var/lib/mysql
user=mysql
# Path to Galera library
wsrep_provider=/usr/lib64/libgalera_smm.so
# Cluster connection URL contains the IPs of node#1, node#2 and node#3
wsrep_cluster_address=gcomm://192.168.100.7,192.168.100.8,192.168.100.9
# In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW
# MyISAM storage engine has only experimental support
default_storage_engine=InnoDB
# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2
# Node #1 address
wsrep_node_address=192.168.100.8
# SST method
wsrep_sst_method=xtrabackup-v2
# Cluster name
wsrep_cluster_name=my_centos_cluster
# Authentication for SST method
wsrep_sst_auth="sstuser:s3cret"
[mysqld_safe]
pid-file = /run/mysqld/mysql.pid
syslog
!includedir /etc/my.cnf.d
CentOS6:/etc/init.d/mysql start
CentOS7:systemctl start mysql.service
1、除了名义上的master之外,其它的node节点只需要启动mysql即可。
2、节点的数据库的登陆和master节点的用户名密码一致,自动同步。所以其它的节点数据库用户名密码无须重新设置。
在任意一个node上,进行操作,然后去其它的节点上看是否取得相同的结果。
https://www.percona.com/doc/percona-xtradb-cluster/5.5/howtos/centos_howto.html
Installing Percona XtraDB Cluster on CentOS
标签:
原文地址:http://www.cnblogs.com/caoxiaojian/p/5644600.html