龙空技术网

CentOS 7.9,二分钟搭建好MySQL8.0-PXC集群(实操不说原理)

街头角落里 742

前言:

此刻看官们对“centos7mysqlutf8”大体比较关心,你们都想要了解一些“centos7mysqlutf8”的相关资讯。那么小编同时在网络上收集了一些有关“centos7mysqlutf8””的相关文章,希望你们能喜欢,姐妹们一起来学习一下吧!

推荐

CentOS 7.9服务器,一分钟部署完mysql8.0

Mycat1.6版部署mysql读写分离

Mycat2版部署mysql读写分离

一/环境准备

1/CentOS 7.9

2/Percona XtraDB Cluster 8.0程序包

3/3 台 CentOS 7.9

二/安装yum源和下载包

安装 percona-releaseyum install  -y下载安装包
三/安装PXC
# 安装 pxctar -xvf Percona-XtraDB-Cluster-8.0.27-rac35177-el7-x86_64-bundle.tar 安装sudo yum install -y percona-xtradb-cluster-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-full-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-shared-8.0.30-22.1.el7.x86_64.rpm Percona-XtraDB-Cluster-8.0.30-raff6a8b-el7-x86_64-bundle.tar  percona-xtradb-cluster-garbd-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-shared-compat-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-client-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-icu-data-files-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-test-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-debuginfo-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-mysql-router-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-devel-8.0.30-22.1.el7.x86_64.rpm percona-xtradb-cluster-server-8.0.30-22.1.el7.x86_64.rpm
四/创建文件和权限
mkdir /data/mysql/chown -R mysql:mysql /data/mysql/
五/配置文件

第一台服务器

[root@ab_10_0_0_225 data]# cat /etc/my.cnf [client]socket=/var/lib/mysql/mysql.sockdefault-character-set = utf8mb4[mysql]default-character-set = utf8mb4[mysqld]server-id=225datadir=/data/mysql/datasocket=/var/lib/mysql/mysql.socklog-error=/data/mysql/mysqld.logpid-file=/data/mysql/mysqld/mysqld.pid#连接数max_connections = 2000#innodb使用内存innodb_buffer_pool_size = 1G#utf8mb4编码character-set-client-handshake = FALSEcharacter-set-server = utf8mb4init_connect='SET NAMES utf8mb4'#开启log-bin日志log-bin-trust-function-creators=1#开启事件调度器event_scheduler=1#慢查询开启slow_query_log=1#慢查询时间为2slong_query_time=2#缓冲的数据hash到不同的缓冲池中,并行的内存读写innodb_buffer_pool_instances = 2#该变量将数据存导入到内存中,可以减少大量的IO资源消耗。当事务提交时,保存数据,后续在刷#新到磁盘。innodb_log_buffer_size = 128M#在一个日志组每个日志文件的字节大小,日志文件的总大小innodb_log_file_size = 256M#修改InnoDB为独立表空间模式,每个数据库的每个表都会生成一个数据空间。innodb_file_per_table =ON#库里的表特别多的情况使用,这个值默认是300Minnodb_open_files=2M#限制了一次有多少线程能进入内核,0表示不限制进入内核的数量innodb_thread_concurrency=0#开启log-bin日志log-bin-trust-function-creators=1#开启事件调度器event_scheduler=1#关闭大小写lower_case_table_names=1#pxcbinlog_expire_logs_seconds=604800wsrep_provider=/usr/lib64/galera4/libgalera_smm.so#配置集群信息地址如wsrep_cluster_address=gcomm://10.1.1.225,10.1.1.226,10.1.1.227wsrep_cluster_address=gcomm://binlog_format=ROWwsrep_slave_threads=8wsrep_log_conflictsinnodb_autoinc_lock_mode=2#集群的名字,必须是统一的wsrep_cluster_name=pxc-cluster-sz-abc#该节点的名称wsrep_node_name=pxc-abc-node-sz-1#该节点的地址wsrep_node_address=10.1.1.225pxc_strict_mode=ENFORCINGwsrep_sst_method=xtrabackup-v2#集群同步的用户名密码,这里没用到#wsrep_sst_auth=abc:666666#启用加密自动配置的变量pxc-encrypt-cluster-traffic=OFFsql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
六/修改用户
# 重启 MySQLsystemctl restart mysql.service# 查看初始密码grep 'temporary password' /data/mysql/mysqld.log#修改密码#8.0 需要先用这条命令alter user 'root'@'localhost' identified by '1234567890';CREATE USER 'root'@'%' IDENTIFIED BY '1234567890'; GRANT ALL ON *.* TO 'root'@'%'; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234567890';#密码永不过期的ALTER USER 'root'@'localhost' IDENTIFIED BY '1234567890' PASSWORD EXPIRE NEVER; # 查看 MySQL 版本select @@version ;# 更新权限flush privileges;
七/安装二三台服务器

安装步骤同上可得。

注:修改项1/my.cnf文件内容;#id一般ip的最后个位就行server-id=226#把所有集群ip写入,等二,三台服务器部署好,mysql启来了再修改第一台服务器的配置wsrep_cluster_address=gcomm://10.1.1.225,10.1.1.226,10.1.1.227#集群的名字,必须是统一的wsrep_cluster_name=pxc-cluster-sz-abc#该节点的名称pxc-abc-node-sz-2; pxc-abc-node-sz-3wsrep_node_name=pxc-abc-node-sz-2#该节点的地址10.1.1.226,10.1.1.227wsrep_node_address=10.1.1.226
八/查看集群
# 重启 MySQLsystemctl restart mysql.service#查看集群状态,可以看到集群中有3个节点root@localhost 16:43: [(none)]>show global status like 'wsrep_cluster_%';+--------------------------+--------------------------------------+| Variable_name            | Value                                |+--------------------------+--------------------------------------+| wsrep_cluster_weight     | 3                                    || wsrep_cluster_conf_id    | 3                                    || wsrep_cluster_size       | 3                                    || wsrep_cluster_state_uuid | b30f83dd-be99-11ea-b21c-b61232d3c9ee || wsrep_cluster_status     | Primary                              |+--------------------------+--------------------------------------+5 rows in set (0.00 sec)root@localhost 16:49: [(none)]>show global status like '%wsrep_ready%';+---------------+-------+| Variable_name | Value |+---------------+-------+| wsrep_ready   | ON    |+---------------+-------+1 row in set (0.00 sec)
九/使用Navicat查看

标签: #centos7mysqlutf8