PXC5.7.21 for linux7.2安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PXC5.7.21 for linux7.2安装相关的知识,希望对你有一定的参考价值。
PXC的安装非常简单!!!!!!
--软件下载
https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/LATEST/
--基础环境准备
[[email protected] ~]# vim /etc/hosts ---在3个节点hosts文件加入如下信息
192.168.2.100 node1
192.168.2.200 node2
192.168.2.210 node3
[[email protected] ~]# rpm -e --nodeps mariadb mariadb-server mariadb-libs marisa --卸载
1、3个节点安装依赖包
yum install -y git scons gcc* gcc-c++ openssl* check cmake bison boost-devel asio-devel libaio-devel ncurses-devel readline-devel pam-devel socat perl-time-hires perl-io-socket-ssl.noarch perl-dbd-mysql.x86_64
--解压软件包,并安装:
下载软件包要注意:切记选择ssl101版本,官方使用手册上有如下说明
[[email protected] ~]# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm [[email protected] ~]# rpm -ivh percona-xtrabackup-24-2.4.11-1.el7.x86_64.rpm [[email protected] ~]# tar zxvf Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl101.tar.gz -C /usr/local/^C [[email protected] ~]# cd /usr/local/ [[email protected] local]# ln -s Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl101.tar.gz pxc_mysql
2、创建用户,新建文件夹请授权【三个节点都要操作】 :
[[email protected] ~]# userdel mysql [[email protected] ~]# useradd -g mysql mysql [[email protected] ~]# passwd mysql [[email protected] ~]# mkdir -p /usr/local/pxc_mysql/{data,logs,tmp} [[email protected] ~]# mkdir -p /usr/local/pxc_mysql/logs/binlog [[email protected] ~]# chown -R mysql:mysql /usr/local/pxc_mysql/ [[email protected] ~]# chmod -R +x /usr/local/pxc_mysql/
3、切换mysql用户创建my.cnf (该配置文件只简单的几个参数,如果生产环境需要更多的数据库参数)
[[email protected] ~]# su - mysql [[email protected] ~]$ cd /usr/local/pxc_mysql/ [[email protected] pxc_mysql]$ vi my.cnf [client] socket=/usr/local/pxc_mysql/data [mysqld] server-id=142 port = 3306 basedir=/usr/local/pxc_mysql datadir=/usr/local/pxc_mysql/data socket=/usr/local/pxc_mysql/data/mysql.sock log-error=/usr/local/pxc_mysql/data/mysqld.log pid-file=/usr/local/pxc_mysql/data/mysqld.pid log-bin=/usr/local/pxc_mysql/logs slow_query_log_file = /usr/local/pxc_mysql/data/slow.log log_slave_updates expire_logs_days=7 binlog_format=ROW innodb_buffer_pool_size = 1524M #pxc wsrep_provider=/usr/local/pxc_mysql/lib/libgalera_smm.so wsrep_cluster_name=pxc-nie wsrep_cluster_address=gcomm://192.168.2.100,192.168.2.200,192.168.2.210 wsrep_node_name=node1 wsrep_node_address=192.168.2.100 wsrep_sst_method=xtrabackup-v2 wsrep_sst_auth=pxc:123456 pxc_strict_mode=ENFORCING binlog_format=ROW default_storage_engine=InnoDB innodb_autoinc_lock_mode=2
注意:
其他两个个节点,只需要修改:
server-id=142 --id不能一样
wsrep_node_name=node1 --改成自己节点的主机名
wsrep_node_address=192.168.2.100 --改成自己节点的主机IP
4、初始化3个节点的数据库
/usr/local/pxc_mysql/bin/mysqld --defaults-file=/usr/local/pxc_mysql/my.cnf --datadir=/usr/local/pxc_mysql/data --basedir=/usr/local/pxc_mysql --initialize
(在/usr/local/pxc_mysql/data/mysqld.log这个日志里有root的密码)
5、首先启动第一个节点:
[[email protected] pxc_mysql]# /usr/local/pxc_mysql/bin/mysqld_safe --defaults-file=/usr/local/pxc_mysql/my.cnf --wsrep-new-cluster --user=mysql & ---用root起
然后进入MySQL,执行如下操作(如果进不去,报错密码过期,那么在my.cnf文件加入:skip-grant-tables,然后无密码进入数据库: update mysql.user set password_expired="N" where user="root"; 最后把参数从配置文件去掉,重启数据库,用刚才的root密码进入即可。)
MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) MySQL [(none)]> show status like 'wsrep_local_state%'; +---------------------------+--------------------------------------+ | Variable_name | Value | +---------------------------+--------------------------------------+ | wsrep_local_state_uuid | c2ab52e7-67cf-11e8-9d02-e76acee85210 | | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced | +---------------------------+--------------------------------------+ 3 rows in set (0.00 sec) MySQL [(none)]> show status like 'wsrep_cluster_%'; +--------------------------+--------------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------------+ | wsrep_cluster_conf_id | 1 | | wsrep_cluster_size | 1 | | wsrep_cluster_state_uuid | c2ab52e7-67cf-11e8-9d02-e76acee85210 | | wsrep_cluster_status | Primary | +--------------------------+--------------------------------------+ 4 rows in set (0.00 sec) MySQL [(none)]> GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'pxc'@'%' IDENTIFIED BY '123456'; ---创建一个SST用户 MySQL [(none)]> flush privileges;
(从上面的信息集群大小为1个节点,状态为primary,节点处于Synced状态,它已完全连接,可以进行write-set replication。 )
6、依次启动第二、第三个节点:
[[email protected] pxc_mysql]# /usr/local/pxc_mysql/bin/mysqld_safe --defaults-file=/usr/local/pxc_mysql/my.cnf --user=mysql &
7、验证集群部署成功:
在各个节点查看:
MySQL [(none)]> show status like 'wsrep_cluster_%'; +--------------------------+--------------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------------+ | wsrep_cluster_conf_id | 5 | | wsrep_cluster_size | 3 | ---现在是3个节点都加入了集群 | wsrep_cluster_state_uuid | c2ab52e7-67cf-11e8-9d02-e76acee85210 | | wsrep_cluster_status | Primary | +--------------------------+--------------------------------------+
在其中一个节点创建表或数据库 看看是否3个节点都同步完成。
以上是关于PXC5.7.21 for linux7.2安装的主要内容,如果未能解决你的问题,请参考以下文章
安装mmcv报错 ERROR: error: Microsoft Visual C++ 14.0 or greater is Failed building wheel for mmcv-full(代
exec: "/bin/xtensa-lx106-elf-g++": file does not exist Arduino for 8266 core 开发错误解决办法(示例代