mysql8.0.20安装测试innodb cluster

Posted knowledge-is-power

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql8.0.20安装测试innodb cluster相关的知识,希望对你有一定的参考价值。

本文记录搭建mysql innodb cluster的过程和基本的测试。

 

1、环境描述

主机名 主机IP 部署
tidb60 192.168.68.60 MySQL8.0.20
tidb61 192.168.68.61 MySQL8.0.20
tidb62 192.168.68.62 MySQL8.0.20
tidb63 192.168.68.63 MySQL-shell,MySQL-route

 

2、下载安装包

https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
https://cdn.mysql.com//Downloads/MySQL-Router/mysql-router-8.0.20-linux-glibc2.12-x86_64.tar.xz
https://cdn.mysql.com//Downloads/MySQL-Shell/mysql-shell-8.0.20-linux-glibc2.12-x86-64bit.tar.gz

 

2、环境部署

2.1 MySQL8.0.20 实例部署,以tidb60主机上为例。

mkdir -p /home/mysql_cluster/my3366/{socket,data,logs,dump_dir}

cd /home/mysql_cluster

chown -R mysql:mysql my3366

/usr/local/mysql8020/bin/mysqld --defaults-file=/home/mysql_cluster/my3366/my3366.cnf --initialize

nohup /usr/local/mysql8020/bin/mysqld_safe --defaults-file=/home/mysql_cluster/my3366/my3366.cnf --user=mysql &

 /usr/local/mysql8020/bin/mysql -S /home/mysql_cluster/my3366/socket/mysql3366.sock -uroot -p

 create user dba@‘%‘ identified  WITH mysql_native_password by ‘dba‘;
 grant all on *.* to dba@‘%‘ with grant option;
 flush privileges;

 

参数文件/home/mysql_cluster/my3366/my3366.cnf

[client]
port    = 
socket    = /home/mysql_cluster/my3366/socket/mysql3366.sock
[mysql]
prompt="\u@\h R:m:s [\d]>"
no-auto-rehash
port                           = 3366
socket                         = /home/mysql_cluster/my3366/socket/mysql3366.sock
default_character_set          = utf8mb4
[mysqladmin]
port                           = 3366
socket                         = /home/mysql_cluster/my3366/socket/mysql3366.sock
[mysqldump]
port                           = 3366
socket                         = /home/mysql_cluster/my3366/socket/mysql3366.sock
[xtrabackup]
port                           = 3366
socket                         = /home/mysql_cluster/my3366/socket/mysql3366.sock
[mysqlbackup]
port                           = 3366
socket                         = /home/mysql_cluster/my3366/socket/mysql3366.sock
safe_slave_backup_timeout      = 0
[mysqld]
# basic settings #
user                           = mysql
port			       = 3366
default_storage_engine         = InnoDB
server_id                      = 168603366
sql_mode                       = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
socket                         = /home/mysql_cluster/my3366/socket/mysql3366.sock
pid_file                       = /home/mysql_cluster/my3366/socket/mysql3366.pid
basedir                        = /usr/local/mysql8020
datadir                        = /home/mysql_cluster/my3366/data
character_set_server           = utf8mb4
default_time_zone = +08:00
back_log = 1024
thread_stack = 512K
external_locking = FALSE
open_files_limit               = 65535
max_allowed_packet             = 128M
lower_case_table_names         = 1
explicit_defaults_for_timestamp = 1
read_only                       = 0
super_read_only                 = 0
# connection #
lock_wait_timeout = 3600
skip_name_resolve              = 1
max_connect_errors             = 1000000
max_connections                = 5000
# table cache performance settings#
table_open_cache               = 4096
table_open_cache_instances     = 64
table_definition_cache         = 4096
# CACHES AND LIMITS #
tmp_table_size                 = 32M
max_heap_table_size            = 32M
bulk_insert_buffer_size        = 64M
# session memory settings #
sort_buffer_size               = 4M
join_buffer_size = 4M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
thread_cache_size              = 3000
# log settings #
log_error_verbosity = 3
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_error                      = /home/mysql_cluster/my3366/logs/mysql-error.log
log_timestamps                 = SYSTEM
log_queries_not_using_indexes  = 1
slow_query_log                 = 1
slow_query_log_file            = /home/mysql_cluster/my3366/logs/mysql-slow.log
long_query_time = 0.5
# innodb settings #
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_log_buffer_size = 32M
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
##机械盘设置为500,SSD盘设置为10000-20000##
innodb_io_capacity = 500
##机械盘设置为2000,SSD盘设置为10000-20000##
innodb_io_capacity_max = 1000
##机械盘设置为1,SSD盘设置为0##
innodb_flush_neighbors = 1
innodb_write_io_threads = 16
innodb_read_io_threads = 16
innodb_purge_threads = 4
innodb_page_cleaners = 16
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_lru_scan_depth = 4096
innodb_lock_wait_timeout = 10
innodb_checksum_algorithm = crc32
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_online_alter_log_max_size = 4G
innodb_stats_on_metadata = 0
innodb_flush_method            = O_DIRECT
innodb_log_files_in_group      = 3
innodb_log_file_size           = 1G
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table          = 1
innodb_buffer_pool_size        = 4G
innodb_buffer_pool_instances   = 4
# undo settings #
innodb_undo_directory           = /home/mysql_cluster/my3366/data
innodb_undo_tablespaces         = 95
innodb_undo_log_truncate        = 1
innodb_purge_rseg_truncate_frequency = 128
innodb_max_undo_log_size = 4G
innodb_status_file = 1
innodb_status_output = 0
innodb_status_output_locks = 0
# performance_schema #
performance_schema = 1
performance_schema_instrument = ‘%=on‘
# innodb monitor #
innodb_monitor_enable="module_innodb,module_server,module_dml,module_ddl,module_trx,module_os,module_purge,module_log,module_lock,module_buffer,module_index,module_ibuf_system,module_buffer_page,module_adaptive_hash"
# safe #
secure_file_priv              = /home/mysql_cluster/my3366/dump_dir
default_password_lifetime     = 0
# replication settings #
skip_slave_start               = 1
relay_log                      = /home/mysql_cluster/my3366/logs/relay-bin
slave_pending_jobs_size_max    = 128M
log_slave_updates = 1
log_bin                        = /home/mysql_cluster/my3366/logs/mysql-bin
expire_logs_days               = 7
sync_binlog                    = 1
gtid_mode                      = ON
enforce_gtid_consistency       = 1
binlog_cache_size              = 4M
max_binlog_size                = 512M
max_binlog_cache_size          = 2G
slave_preserve_commit_order= 1
binlog_format = row
relay_log_purge = 1
slave_parallel_type            = LOGICAL_CLOCK
slave_parallel_workers         = 16
master_info_repository         = TABLE
relay_log_info_repository      = TABLE
relay_log_recovery             = ON
binlog_gtid_simple_recovery     = 1
# group replication & innodb cluster #
disabled_storage_engines        = "MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY"
master_info_repository            = table
binlog_checksum                    = NONE
relay_log_info_repository        = table
gtid_mode                        = ON
enforce_gtid_consistency        = ON
binlog_checksum                    = NONE
log_slave_updates                = ON
binlog_format                    = ROW
transaction_write_set_extraction = XXHASH64
slave_parallel_workers             = 4
slave_preserve_commit_order        = 1
slave_parallel_type            = LOGICAL_CLOCK
binlog_transaction_dependency_tracking = WRITESET_SESSION
# clone #

  

 2.2 配置检查

  在tidb63主机上部署mysqlshell,下载后解压,配置环境变量即可使用,部署路径跟进实际环境即可。

  检查节点1:tidb60:3366实例

   

[root@tidb63 bin]# pwd
/home/jm/data/mysql-shell-8.0.20/bin
[root@tidb63 bin]# ./mysqlsh dba@tidb60:3366
Please provide the password for ‘dba@tidb60:3366‘: ***
MySQL Shell 8.0.20

Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.

Type ‘help‘ or ‘?‘ for help; ‘quit‘ to exit.
Creating a session to ‘dba@tidb60:3366‘
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 36698
Server version: 8.0.20 MySQL Community Server - GPL
No default schema selected; type use <schema> to set one.
 MySQL  tidb60:3366 ssl  JS > dba.checkInstanceConfiguration("dba@tidb60:3366");
Please provide the password for ‘dba@tidb60:3366‘: ***
Validating MySQL instance at tidb60.com:3366 for use in an InnoDB cluster...

This instance reports its own address as tidb60.com:3366
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.

Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected

Checking instance configuration...
Instance configuration is compatible with InnoDB cluster

The instance ‘tidb60.com:3366‘ is valid to be used in an InnoDB cluster.

{
    "status": "ok"
}
 MySQL  tidb60:3366 ssl  JS > 

 

检查节点2:tidb61:3366实例

 

  

 

以上是关于mysql8.0.20安装测试innodb cluster的主要内容,如果未能解决你的问题,请参考以下文章

源码安装mysql8.0.20

MySQL8.0.20安装

MySQL8.0.20安装详细图文教程,mysql安装教程

MySQL8.0.20安装详细图文教程,mysql安装教程

mysql8.0.20安装教程,mysql下载安装教程8.0.20

mysql8.0.20安装教程