MySQL8.0InnodbCluster部署⽂档(内含基于MGR使⽤mysqlshell。。。⽂章⽬录
⼀、环境说明
1.1 版本说明
软硬件信息参数
配置2C4G
操作系统版本CentOS Linux release 7.7.1908 (Core)
内核版本  3.10.0-1062.el7.x86_64
MySQL版本MySQL 8.0.20
MySQL Shell版本MySQL Shell 8.0.20
MySQL Router版本MySQL Router 8.0.20
1.2 服务器规划
服务器IP端⼝⾓⾊
node1192.168.137.863306Master,shell,router
node2192.168.137.873306Slave
node3192.168.137.883306Slave
1.3 配置⽬录规划
软件⽬录
MySQL软件安装⽬录/usr/local/mysql/mysqlserver
MySQL数据⽂件⽬录/data/mysql/data
MySQL⽇志⽂件⽬录/data/mysql/logs
MySQLbinlog⽇志⽬录/data/mysql/binlog
MySQL配置⽂件⽬录/etc/myf
MySQL Shell安装⽬录/usr/local/mysql
MySQL Router安装⽬录/usr/local/mysql/mysqlserver
⼆、基础配置
所有3个节点都执⾏下述操作
2.1 关闭selinux和防⽕墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0 && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
2.2 配置IP域名映射
cat /etc/hosts
127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
:
:1        localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.137.86 node1
192.168.137.87 node2
192.168.137.88 node3
2.3 更改I/O调度模式
echo deadline > /sys/block/sda/queue/scheduler
cat /sys/block/sda/queue/scheduler
2.4 ⽂件系统选择
  ⽂件系统最好选择xfs,它⽐ext4更⽅便管理。
2.5 操作系统调优
cat>>/f <<EOF
vm.swappiness = 0
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
EOF
cat>>/etc/f <<EOF
mysql soft nproc 65536
mysql hard nproc 65536
mysql soft nofile 65536
mysql hard nofile 65536
EOF
cat>>/etc/profile<<EOF
if [ $USER = "mysql" ]; then
ulimit -u 16384 -n 65536
fi
EOF
2.6 关闭numa
# sed -i 's/GRUB_CMDLINE_LINUX.*/GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos\/root rd.lvm.lv=centos\/swap rhgb quiet numa=off"/g' /e tc/default/grub
# grub2-mkconfig -o /etc/grub2.cfg
# cat /etc/grub2.cfg
# reboot
# cat /proc/cmdline
# dmesg | grep -i numa
三、部署MySQL
3.1 创建MySQL⽤户组和⽤户
groupadd mysqlmysql帮助文档
useradd -g mysql mysql -s /sbin/nologin
id mysql
3.2 配置⽬录
mkdir -pv /data/mysql/{data,logs,binlog,tmp,redo}
chown -R mysql:mysql /data/mysql/
2.3 解压安装包
mkdir /usr/local/mysql/program -pv
tar xf mysql-8.0.20-el7-x86_64.tar -C /usr/local/mysql/program/
cd /usr/local/mysql/program/
tar xf mysql-8.0.20-el7-x86_ -C /usr/local/mysql/
tar xf mysql-test-8.0.20-el7-x86_  -C /usr/local/mysql/
tar xf mysql-router-8.0.20-el7-x86_ -C /usr/local/mysql/
2.4 软链接程序⽬录并配置环境变量
ln -s /usr/local/mysql/mysql-8.0.20-el7-x86_64/ /usr/local/mysql/mysqlserver
ln -s /usr/local/mysql/mysql-router-8.0.20-el7-x86_64/ /usr/local/mysql/mysqlrouter
export PATH=/usr/local/mysql/mysqlserver/bin:/usr/local/mysql/mysqlrouter/bin:$PATH
echo 'export PATH=/usr/local/mysql/mysqlserver/bin:/usr/local/mysql/mysqlrouter/bin:$PATH' >> /etc/profile source /etc/profile
2.5 修改配置⽂件
[client]
port    = 3306
socket  = /data/mysql/data/mysql.sock
[mysql]
prompt="\u@mysql \R:\m:\s [\d]> "
no-auto-rehash
[mysqld]
user=mysql
port=3306
default_authentication_plugin=mysql_native_password
basedir=/usr/local/mysql/mysqlserver
datadir=/data/mysql/data
tmpdir =/data/mysql/tmp
socket=/data/mysql/data/mysql.sock
innodb_doublewrite=1
pid-file=mysql.pid
character-set-server = utf8mb4
skip_name_resolve = 1
default_time_zone = "+8:00"
open_files_limit= 65535
back_log = 1024
max_connections = 256
max_user_connections = 64
max_connect_errors = 10000
autocommit = 1
table_open_cache = 1024
table_definition_cache = 1024
table_open_cache_instances = 4
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 4M
join_buffer_size = 4M
join_buffer_size = 4M
innodb_sort_buffer_size = 64M
thread_cache_size = 384
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
log_timestamps = SYSTEM
slow_query_log_file = /data/mysql/logs/slow.log
log-error = /data/mysql/logs/error.log
long_query_time = 0.1
log_queries_not_using_indexes =1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 0
log_slow_admin_statements = 1
log_slow_slave_statements = 1
server-id = 33061
log-bin = /data/mysql/binlog/binlog
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
auto_increment_offset=1
auto_increment_increment=1
expire_logs_days = 7
master_info_repository = TABLE
relay_log_info_repository = TABLE
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN' binlog_format = row
relay_log = /data/mysql/binlog/relaylog
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
lock_wait_timeout = 3600
explicit_defaults_for_timestamp = 1
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
transaction_isolation = READ-COMMITTED
innodb_buffer_pool_size = 2048M
innodb_buffer_pool_instances = 2
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_log_group_home_dir = /data/mysql/redo/
innodb_data_file_path = ibdata1:1G:autoextend
innodb_temp_data_file_path=ibtmp1:500M:autoextend innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
innodb_log_file_size = 2G
innodb_log_files_in_group = 2
innodb_max_undo_log_size = 4G
innodb_undo_directory = /data/mysql/data
innodb_undo_tablespaces = 2
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_sync = 0
innodb_flush_sync = 0
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_checksum_algorithm = crc32
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 4G
innodb_stats_on_metadata = 0
innodb_undo_log_truncate = 1
slave_preserve_commit_order=1
log_error_verbosity = 3
innodb_print_ddl_logs = 1
binlog_expire_logs_seconds = 604800
innodb_status_file = 1
innodb_status_output = 0
innodb_status_output_locks = 0
performance_schema = 1
performance_schema_instrument = '%memory%=on'
performance_schema_instrument = '%lock%=on'
innodb_monitor_enable="module_innodb"
innodb_monitor_enable="module_server"
innodb_monitor_enable="module_dml"
innodb_monitor_enable="module_ddl"
innodb_monitor_enable="module_trx"
innodb_monitor_enable="module_os"
innodb_monitor_enable="module_purge"
innodb_monitor_enable="module_log"
innodb_monitor_enable="module_lock"
innodb_monitor_enable="module_buffer"
innodb_monitor_enable="module_index"
innodb_monitor_enable="module_ibuf_system"
innodb_monitor_enable="module_buffer_page"
innodb_monitor_enable="module_adaptive_hash"
slave_parallel_type=LOGICAL_CLOCK
slave_parallel_workers=2
binlog_group_commit_sync_no_delay_count=10
innodb_redo_log_archive_dirs=/back/redo
log-slave-updates=1
binlog_transaction_dependency_tracking=writeset_session
binlog_checksum=NONE
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = 'e88cd6a7-8a12-4368-aeea-21d6b68b2982'
loose-group_replication_start_on_boot = OFF
loose-group_replication_local_address = '192.168.137.86:33061'
loose-group_replication_group_seeds = '192.168.137.86:33061,192.168.137.87:33061,192.168.137.88:33061' loose-group_replication_bootstrap_group = OFF
[mysqldump]

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。