http://www.dbhelp.net/2017/01/06/pxc-5-7-14-%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2-pxc-install.html

 

PXC是Percona XtraDB Cluster的缩写,是一种具有高可用性和高扩展性的MySQL开源集群。它集成了Percona Server和Percona XtraBackup,同时采用了Codership Galera库。

常见的PXC架构如下,

PXC 5.7.14 安装部署

PXC架构

下面,开始安装PXC 5.7.14

一、环境说明

主机

 
1
2
3
4
# PXC #
pxc1
pxc2
pxc3

OS : CentOS release 6.5 (Final)

二、安装 Percona-XtraDB-Cluster

1、卸载CentOS 自带的mysql-libs包

 
1
nodeps

2、所有节点安装依赖包

 
1
2
3
4
5
6
7
3.el6.x86_64.rpm
1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm
1.el6.x86_64.rpm

所有节点安装软件包的步骤

 
1
2
3
4
5
6
7
8
9
HiRes
nc
3.el6.x86_64.rpm
1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm
1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm
26.17.1.el6.x86_64.rpm

3、所有节点创建mysql组和用户

 
1
2
# groupadd mysql  
# useradd -r -g mysql -s /bin/false mysql

4、创建相关目录

 
1
2
# mkdir /data/mysql/{data,logs,tmp} -p
# chown  mysql.mysql /data/ -R

5、配置my.cnf文件

 
1
2
3
'my-default.cnf'
cnf
cnf

拷贝到/etc/my.cnf

 
1
cnf

编辑my.cnf
@第一节点 pxc1

 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
]
mysql
 
1024M
data
3306
3306111
sock
pid
log
2
log
0.1
 
 
STRICT_TRANS_TABLES
 
 
##  pxc variables  ##
# Path to Galera library
so
 
# Cluster connection URL contains the IPs of node#1, node#2 and node#3
//10.9.15.111,10.9.15.112,10.9.15.113
 
# In order for Galera to work correctly binlog format should be ROW
ROW
 
# MyISAM storage engine has only experimental support
InnoDB
 
# This InnoDB autoincrement locking mode is a requirement for Galera
2
 
# Node name
pxc1
 
# Node 1 address
10.9.15.111
 
# SST method
v2
 
# Cluster name
test
 
# Authentication for SST method

@第二节点 pxc2
注意修改 server_id 、wsrep_node_name 、 wsrep_node_address

 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
]
mysql
 
1024M
data
3306
3306112
sock
pid
log
2
log
0.1
 
 
STRICT_TRANS_TABLES
 
 
##  pxc variables  ##
# Path to Galera library
so
 
# Cluster connection URL contains the IPs of node#1, node#2 and node#3
//10.9.15.111,10.9.15.112,10.9.15.113
 
# In order for Galera to work correctly binlog format should be ROW
ROW
 
# MyISAM storage engine has only experimental support
InnoDB
 
# This InnoDB autoincrement locking mode is a requirement for Galera
2
 
# Node name
pxc2
 
# Node 1 address
10.9.15.112
 
# SST method
v2
 
# Cluster name
test
 
# Authentication for SST method

@第三节点 pxc3
注意修改 server_id 、wsrep_node_name 、 wsrep_node_address

 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
]
mysql
 
1024M
data
3306
3306113
sock
pid
log
2
log
0.1
 
 
STRICT_TRANS_TABLES
 
 
##  pxc variables  ##
# Path to Galera library
so
 
# Cluster connection URL contains the IPs of node#1, node#2 and node#3
//10.9.15.111,10.9.15.112,10.9.15.113
 
# In order for Galera to work correctly binlog format should be ROW
ROW
 
# MyISAM storage engine has only experimental support
InnoDB
 
# This InnoDB autoincrement locking mode is a requirement for Galera
2
 
# Node name
pxc3
 
# Node 1 address
10.9.15.113
 
# SST method
v2
 
# Cluster name
test
 
# Authentication for SST method

 

三、启动PXC

1、启动第一节点

 
1
2
3
# /etc/init.d/mysql bootstrap-pxc
  
]

查看进程是否启动

 
1
2
3
# ps -ef|grep mysql
cluster
1

查看错误日志信息

 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%
,
,
c622a8ebb29a
]
)
.
)
# 1: Primary, number of nodes: 1, my index: 0, protocol version 3
0
available
builtins
mutexes
barrier
1.2.3
AIO
1
instructions
128M
pool
.
_doublewrite
.
bytes
tables
.
.
.
.
start
//www.percona.com) 5.7.14-8 started; log sequence number 2491156
_pool
.
37
.
.
.
.
3306
.
;
.
events
.
17
2
.
)
.
3
.
connections
.

去error.log日志搜索关键字password找到默认root密码,登录后修改

 
1
;

第一节点启动后,检查cluster的状态。
当前第一节点是Primary。

 
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
26
;
+
|
+
|
|
|
|
|
.
|
|
|
|
|
.
|
|
|
|
|
|
|
|
+
)

第一节点创建后,其他节点初始化,需要使用xtrabackup工具来备份,然后恢复。
所以,需要创建一个用户用于备份。

 
1
2
3
;
# 注意,官方文档中少了 PROCESS 权限
;

验证sstuser登录

 
1
# mysql -usstuser -psstuser -S /data/mysql/mysql.sock -e 'show databases'

启动第二节点

 
1
# /etc/init.d/mysql start

确认第二节点的状态

 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  
+
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
)

启动第三节点

 
1
# /etc/init.d/mysql start

确定状态

 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;
+
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
)

至此,PXC安装启动完毕。

相关文章: