您好,登錄后才能下訂單哦!
這篇文章主要介紹“PXC5.7的安裝步驟”,在日常操作中,相信很多人在PXC5.7的安裝步驟問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”PXC5.7的安裝步驟”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
節點分配
IP | hostname | 用途 |
192.168.137.201 | c1 | node1 |
192.168.137.202 | c2 | node2 |
192.168.137.203 | c3 | node3 |
需要的包
percona-xtrabackup-24-2.4.7-2.el6.x86_64.rpm
Percona-XtraDB-Cluster-5.7.18-rel15-29.20.1.Linux.x86_64.ssl101.tar.gz
安裝epel源(所有節點)
centos6
rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
centos7
rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
安裝依賴包
yum install perl-IO-Socket-SSL perl-DBD-MySQL perl-Time-HiRes socat nc -y
安裝xtrabackup
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.7-2.el6.x86_64.rpm
rpm -ivh percona-xtrabackup-24-2.4.7-2.el6.x86_64.rpm
數據庫初始化
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3306/data --user=mysql --initialize
修改mysqld_safe啟動文件
#####具體需要替換的路徑根據安裝的包名稱去mysqld_safe文件中查詢#############
sed -i 's#/mnt/workspace/percona-xtradb-cluster-5.7-binary-tarball/label_exp/centos6-64/Percona-XtraDB-Cluster-5.7.18-29.20/346/usr/local/Percona-XtraDB-Cluster-5.7.18-rel15-29.20.1.Linux.x86_64.ssl101#/usr/local/mysql#g' /usr/local/mysql/bin/mysqld_safe
vi /usr/local/mysql/support-files/mysql.server
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3306/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
添加PXC相關的參數
vi /etc/my.cnf
[mysqld]
...
#PXC
wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.137.201,192.168.137.202,192.168.137.203
wsrep_node_address=192.168.137.201
wsrep_slave_threads=2
innodb_autoinc_lock_mode=2
binlog_format = ROW
default_storage_engine=InnoDB
wsrep_cluster_name=pxc-jiangzq
wsrep_sst_auth=sst:jiangzq
wsrep_sst_method=xtrabackup-v2
檢查環境
[root@c1 xtrabackup]# /etc/init.d/mysql --help
Usage: mysql {start|stop|restart|restart-bootstrap|reload|force-reload|status|bootstrap-pxc} [ MySQL (Percona XtraDB Cluster) options ]
啟動第一個節點
shell>/etc/init.d/mysql bootstrap-pxc
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf bootstrap-pxc &
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf bootstrap-pxc
修改root密碼和添加sst賬戶
alter user user() identified by 'root';
create user 'sst'@'localhost' identified by 'jiangz';
grant all on *.* to 'sst'@'localhost';
將整個虛擬機再克隆兩個
#####修改主機名
shell>hostname c2
shell>vi /etc/sysconfig/network
hostname=c2
#####修改ip地址
shell>vi /etc/sysconfig/network-script/ifcfg-eth0
shell>service network restart
#####修改mysql配置文件
shell>vi /etc/my.cnf
server-id=203306
pid-file = c2.pid
wsrep_node_address=192.168.137.202
第2、3個節點啟動
shell>/etc/init.d/mysql
遇到的錯誤
##############啟動第二個節點報的錯誤###############
2017-07-18T06:40:24.829678Z 0 [ERROR] WSREP: Failed to read 'ready ' from: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.137.202' --datadir '/data/mysql/mysql3306/data/' --defaults-file '/etc/my.cnf' --defaults-group-suffix '' --parent '10520' --binlog '/data/mysql/mysql3306/logs/mysql-bin'
Read: '(null)'
2017-07-18T06:40:24.829714Z 0 [ERROR] WSREP: Process completed with error: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.137.202'
--datadir '/data/mysql/mysql3306/data/' --defaults-file '/etc/my.cnf' --defaults-group-suffix '' --parent '10520' --binlog '/data/mysql/mysql3306/logs/mysql-bin' :
2 (No such file or directory)
selinux 沒關和xtrabackup版本太低
日常啟動關閉
#/etc/init.d/mysql stop
全部節點關閉后重啟
第一個節點啟動的節點( 如果集群全部關閉,第一個起動也需要用這樣的形式)
#/etc/init.d/mysql bootstrap-pxc
其它節點
#/etc/init.d/mysql start
備注:
如集群是不是所有的節點都關閉不用使#/etc/init.d/mysql bootstrap-pxc 啟動。都可以用
#/etc/init.d/mysql start
啟動。
到此,關于“PXC5.7的安裝步驟”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。