标签:序列 def log-error glob test secure let led pen
MySQL 8.0.11 innodb cluster 高可用集群部署运维管理手册之二 集群建设系统:centos 7.5
Mysql:8.0.11 二进制包
Mysqlshell: 8.0.11 rpm 包
Mysql router: 8.0.11 二进制包
192.168.181.101 myrouter1 Keepalived、MySQL-shell、MySQL-Router、MySQL-client
192.168.181.102 myrouter2 Keepalived、MySQL-shell、MySQL-Router、MySQL-client
192.168.181.103 mysql3 MySQL服务端、MySQL-shell
192.168.181.104 mysql4 MySQL服务端、MySQL-shell
192.168.181.105 mysql5 MySQL服务端、MySQL-shell
192.168.181.101 mysql1
192.168.181.102 mysql2
192.168.181.103 mysql3
192.168.181.104 mysql4
192.168.181.105 ysql5
yum -y install gcc glibc libaio libstdc++ libstdc libncurses ld-linux
(1)、关闭SElinux
setenforce 0
修改/etc/selinux/config
vim /etc/selinux/config
SELINUX=disabled
(2)、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
cat>>/etc/sysctl.conf <<EOF
fs.aio-max-nr = 1048576
fs.file-max = 681574400
kernel.shmmax = 137438953472
kernel.shmmni = 4096
kernel.sem = 250 32000 100 200
net.ipv4.ip_local_port_range = 9000 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
EOF
cat>>/etc/security/limits.conf <<EOF
mysql soft nproc 65536
mysql hard nproc 65536
mysql soft nofile 65536
mysql hard nofile 65536
EOF
cat>>/etc/pam.d/login <<EOF
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF
cat>>/etc/profile<<EOF
if [ $USER = "mysql" ]; then
ulimit -u 16384 -n 65536
fi
EOF
source /etc/profile
useradd mysql
cat >>/home/mysql/.bash_profile<<EOF
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
EOF
cd /data
tar -xzvf mysql-8.0.11-el7-x86_64.tar.gz -C /usr/local
mv /usr/local/mysql-8.0.11-el7-x86_64 /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
mkdir -p /data/mysql_3306_test/{data,log,binlog,conf,tmp}
chown -R mysql.mysql /data/mysql_3306_test
su – mysql
Vim /data/mysql_3306_test/conf/my.cnf
[mysqld]
lower_case_table_names = 1
user = mysql
server_id = 1104 #各个实例全局唯一
port = 3310
enforce_gtid_consistency = ON
gtid_mode = ON
binlog_checksum = none
default_authentication_plugin = mysql_native_password #为了兼容以前的驱动
datadir = /data/mysql_3310_test/data
pid-file = /data/mysql_3310_test/tmp/mysqld.pid
socket = /data/mysql_3310_test/tmp/mysqld.sock
tmpdir = /data/mysql_3310_test/tmp/
skip-name-resolve = ON
table_open_cache = 2000
#################innodb########################
innodb_data_home_dir = /data/mysql_3310_test/data
innodb_data_file_path = ibdata1:512M;ibdata2:512M:autoextend
innodb_buffer_pool_size = 2000M
innodb_flush_log_at_trx_commit = 1
innodb_io_capacity = 600
innodb_lock_wait_timeout = 120
innodb_log_buffer_size = 8M
innodb_log_file_size = 200M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 85
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_thread_concurrency = 32
innodb_file_per_table
innodb_rollback_on_timeout
innodb_undo_directory = /data/mysql_3310_test/data
innodb_log_group_home_dir = /data/mysql_3310_test/data
###################session###########################
join_buffer_size = 8M
key_buffer_size = 256M
bulk_insert_buffer_size = 8M
max_heap_table_size = 96M
tmp_table_size = 96M
read_buffer_size = 8M
sort_buffer_size = 2M
max_allowed_packet = 64M
read_rnd_buffer_size = 32M
############log set###################
log-error = /data/mysql_3310_test/log/mysqld.err
log-bin = /data/mysql_3310_test/binlog/binlog
log_bin_index = /data/mysql_3310_test/binlog/binlog.index
max_binlog_size = 500M
slow_query_log_file = /data/mysql_3310_test/log/slow.log
slow_query_log = 1
long_query_time = 10
log_queries_not_using_indexes = ON
log_throttle_queries_not_using_indexes = 10
log_slow_admin_statements = ON
log_output = FILE,TABLE
master_info_file = /data/mysql_3310_test/binlog/master.info
##########################mgr set##############################
mysqlx_port=33101 #要设置,因为组复制协议走的就是这个端口,多实例下要调整
mysqlx_socket=/data/mysql_3310_test/tmp/mysqlx.sock
loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "mysql4:33101"
loose-group_replication_group_seeds= "mysql3:33101,mysql4:33101,mysql5:33101"
loose-group_replication_bootstrap_group= off
loose-group_replication_ip_whitelist="192.168.181.0/24"
loose-group_replication_single_primary_mode = on #我们在次都要单主模式云因看后面
loose-group_replication_auto_increment_increment=1 #这个默认是7,我们单主模式设置为1
多主模式下:
loose-group_replication_single_primary_mode = off
操作流程:业务端连接IP处理 -> GROUP内成员逐个依次主动退出GROUP (全部退出才行)-> 关闭 group_replication_single_primary_mode参数-> 逐个启动GROUP内的SERVER
Set global group_replication_single_primary_mode=off
mysqld --defaults-file=/data/mysql_3306_test/conf/my.cnf --initialize-insecure --user=mysql
mysqld --defaults-file=/data/mysql_3310_test/conf/my.cnf --initialize-insecure --user=mysql
mysqladmin --defaults-file=my.cnf password 跟密码
进入数据库
mysql -uroot -p -S /data/mysql_3306_test/tmp/mysqld.sock
create user root@‘127.0.0.1‘ identified by ‘password‘;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`127.0.0.1` WITH GRANT OPTION;
GRANT PROXY ON ‘‘@‘‘ TO ‘root‘@‘127.0.0.1‘ WITH GRANT OPTION;
GRANT BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN ON *.* TO `root`@`127.0.0.1` WITH GRANT OPTION;
create user root@‘192.168.181.%‘ identified by ‘password‘;
GRANT all on *.* TO root@‘192.168.181.%‘ WITH GRANT OPTION;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`192.168.181.%` WITH GRANT OPTION;
GRANT BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN ON *.* TO root@‘192.168.181.%‘ WITH GRANT OPTION;
关闭主库节点
打包
传递
解压
rpm -ivh mysql-shell-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-router-8.0.11-1.el7.x86_64
使用mysql命令
(1)、检查并配置实例(每个mysql节点)
mysqlsh --log-level=DEBUG3 日志位置 ~/.mysqlsh/mysqlsh.log
检查实例
dba.configureLocalInstance(‘root@127.0.0.1:3306‘);
dba.chekInstanceConfiguration(‘root@127.0.0.1:3306‘)
(2)、创建cluster集群(确认每个SQL节点的实例都完成上述实例配置并且验证成功)
在任意一台mysql实例节点执行以下命令:
mysqlsh
shell.connect(‘root@mysql1:3306‘)
var cluster = dba.createCluster(‘qwCluster‘);
如果创建成功输出的信息中会有类似“Cluster successfully created.”的语句
将另外两个节点加入到Cluster集群中
cluster.addInstance(‘root@mysql4:3306‘);
cluster.addInstance(‘root@mysql5:3306‘);
mysql.shell 查看
cluster.status()
navacat 连接mysql 查看
select @@hostname
多实例环境下,某个实例采用了默认的3306端口,会导致经常性的误操作。切记
本环境建议的端口
3300 3310 3320 … 3390
一台主机最多部署10个实例
dba.dropMetadataSchema() mysqlshell 清空集群
mysql> stop group_replication;
mysql> reset master; (清空日志,确保和从库的表没有冲突奥,)
mysql> reset slave
mysql> stop group_replication;
mysql> reset master;
mysql> reset slave
[Repl] Slave I/O for channel ‘group_replication_recovery‘: error connecting to master ‘mysql_innodb_cluster_r0430970923@mysql3:3306‘ - retry-time: 60 retries: 1, Error_code: MY-002005
[ERROR] [MY-011582] [Repl] Plugin group_replication reported: ‘There was an error when connecting to the donor server. Please check that group_replication_recovery channel credentials and all MEMBER_HOST column values of performance_schema.replication_group_members table are correct and DNS resolvable.‘
[ERROR] [MY-011583] [Repl] Plugin group_replication reported: ‘For details please check performance_schema.replication_connection_status table and error log messages of Slave I/O for channel group_replication_recovery.‘
这个问题郁闷了我很久,
Hostname 是
mysql4
mysql5
mysql6
而我在 /etc/hosts中是
192.168.181.103 mysql-1
192.168.181.103 mysql-2
192.168.181.103 mysql-3
[ERROR] [MY-010586] [Repl] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log ‘binlog.000007‘ position 151
[ERROR] [MY-010584] [Repl] Slave SQL for channel ‘group_replication_applier‘: Error executing row event: ‘Unknown database ‘mysql_innodb_cluster_metadata‘‘, Error_code: MY-001049
重建master:MySQL>reset master
MySQL 8.0.11 innodb cluster 运维管理手册之二--集群搭建
标签:序列 def log-error glob test secure let led pen
原文地址:http://blog.51cto.com/yunfang/2151050