pxc安装mysql集群
PXC搭建
- 环境说明
test1 :192.168.26.136
test2 :192.168.26.145
两个节点均关闭iptables,seliunx的级别设为Permissive - 软件安装
1 | rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm |
创建所需目录
1
2mkdir -p /data/mysql/log
chown mysql:mysql /data/mysql/log初始化数据库
1
2
3mysql_install_db --user=mysql --datadir=/data/mysql
/etc/init.d/mysql start
mysql_secure_installation #安全初始化配置node1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
xtradb cluster settings
binlog_format = ROW
wsrep_cluster_name = PXCqwe
wsrep_cluster_address = gcomm://192.168.26.133,192.168.26.145
wsrep_node_address = 192.168.26.133
wsrep_provider = /usr/lib64/libgalera_smm.so
wsrep_sst_method = rsync
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=root:qwe123
innodb_locks_unsafe_for_binlog = 1
innodb_autoinc_lock_mode = 2
default_storage_engine=InnoDB
wsrep_provider_options="gcache.size=2G"
wsrep_slave_threads=8
server_id = 133启动node1
1
2
3
4
5service mysql bootstrap-pxc
show global status like 'wsrep%';
| wsrep_cluster_size | 1 |
| wsrep_incoming_addresses | 192.168.2.200:3306
##有如上显示说明第一个节点启动成功添加新的 Node 到Cluster中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# xtradb cluster settings
binlog_format = ROW
wsrep_cluster_name = PXCqwe
wsrep_cluster_address = gcomm://192.168.26.133,192.168.26.145
wsrep_node_address = 192.168.26.145
wsrep_provider = /usr/lib64/libgalera_smm.so
wsrep_sst_method = rsync
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=root:qwe123
innodb_locks_unsafe_for_binlog = 1
innodb_autoinc_lock_mode = 2
default_storage_engine=InnoDB
wsrep_provider_options="gcache.size=2G"
wsrep_slave_threads=8
server_id = 145
service mysql start
mysql>show global status like ‘wsrep%‘;
| wsrep_incoming_addresses | 192.168.2.200:3306,192.168.2.201:3306 |
| wsrep_cluster_size | 2 |
- 测试
在某一节点操作数据库,在另一节点查看是否同步操作即可
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 符十三郎!