mycat双主高可用架构部署-MySQL5.7环境部署第一台

MySQL5.7服务器IP是192.168.31.209及192.168.31.210

1、192.168.31.209:3307实例部署

a、配置文件

mkdir -p /data/mysql/mysql3307/{data,logs} #创建MySQL数据及日志目录
vi /data/mysql/mysql3307/my3307.cnf #配置文件整理
[client]
#password       = your_password
port            = 3307
socket          = /data/mysql/mysql3307/mysql.sock
default-character-set=utf8
[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_cache_size=20M
thread_stack = 512K
join_buffer_size=20M
query_cache_type = 1
max_heap_table_size = 2048M
port=3307
socket=/data/mysql/mysql3307/mysql.sock
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3307/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
key_buffer_size = 1024M
max_allowed_packet=100G
table_open_cache = 4096
sort_buffer_size=4M
net_buffer_length = 4K
read_buffer_size = 4096K
read_rnd_buffer_size = 2048K
myisam_sort_buffer_size = 128M
thread_cache_size = 512
query_cache_size = 384M
tmp_table_size = 2048M
max_connections=1024
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server_id=2
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/mysql3307/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
log_error=/data/mysql/mysql3307/logs/error.log
log_bin=/data/mysql/mysql3307/logs/mysql-bin
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
wait_timeout=60
innodb_buffer_pool_size=8096M
innodb_log_file_size=256M
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_log_files_in_group=2
max_binlog_cache_size=512M
max_binlog_size=2048M
binlog_group_commit_sync_delay=100 #主库
binlog_group_commit_sync_no_delay_count=20 #主库
slave_parallel_type=logical_clock #从库配置
slave_parallel_workers=4 #从库配置
transaction_write_set_extraction=XXHASH64 #从库配置
binlog_transaction_dependency_tracking=writeset #从库配置
slave_preserve_commit_order=1 #从库配置
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 500M
[mysql]
no-auto-rehash
default-character-set=utf8
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 2M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

b、初始化及授权

chown -R mysql:mysql /data/mys* #更改数据权限组
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my3307.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3307/data #初始化数据库
mysqld --defaults-file=/data/mysql/mysql3307/my3307.cnf & #启动3307数据库
grep 'temporary password' /data/mysql/mysql3307/logs/error.log #获取临时密码
firewall-cmd --zone=public --add-port=3307/tcp --permanent #开启3307端口 
firewall-cmd --reload #刷新防火墙
mysql -uroot -p -S /data/mysql/mysql3307/mysql.sock #连接数据库
alter user root@'localhost' identified by '123456'; //第一次修改密码

2、192.168.31.209:3308实例部署

a、配置文件

mkdir -p /data/mysql/mysql3308/{data,logs} #创建MySQL数据及日志目录
vi /data/mysql/mysql3308/my3308.cnf #配置文件整理
[client]
#password       = your_password
port            = 3308
socket          = /data/mysql/mysql3308/mysql.sock
default-character-set=utf8
[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_cache_size=20M
thread_stack = 512K
join_buffer_size=20M
query_cache_type = 1
max_heap_table_size = 2048M
port=3308
socket=/data/mysql/mysql3308/mysql.sock
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3308/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
key_buffer_size = 1024M
max_allowed_packet=100G
table_open_cache = 4096
sort_buffer_size=4M
net_buffer_length = 4K
read_buffer_size = 4096K
read_rnd_buffer_size = 2048K
myisam_sort_buffer_size = 128M
thread_cache_size = 512
query_cache_size = 384M
tmp_table_size = 2048M
max_connections=1024
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server_id=3
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/mysql3308/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
log_error=/data/mysql/mysql3308/logs/error.log
log_bin=/data/mysql/mysql3308/logs/mysql-bin
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
wait_timeout=60
innodb_buffer_pool_size=8096M
innodb_log_file_size=256M
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_log_files_in_group=2
max_binlog_cache_size=512M
max_binlog_size=2048M
binlog_group_commit_sync_delay=100 #主库
binlog_group_commit_sync_no_delay_count=20 #主库
slave_parallel_type=logical_clock #从库配置
slave_parallel_workers=4 #从库配置
transaction_write_set_extraction=XXHASH64 #从库配置
binlog_transaction_dependency_tracking=writeset #从库配置
slave_preserve_commit_order=1 #从库配置
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 500M
[mysql]
no-auto-rehash
default-character-set=utf8
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 2M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

b、初始化及授权

chown -R mysql:mysql /data/mys* #更改数据权限组
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3308/my3308.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3308/data #初始化数据库
mysqld --defaults-file=/data/mysql/mysql3308/my3308.cnf & #启动3308数据库
grep 'temporary password' /data/mysql/mysql3308/logs/error.log #获取临时密码
firewall-cmd --zone=public --add-port=3308/tcp --permanent #开启3308端口 
firewall-cmd --reload #刷新防火墙
mysql -uroot -p -S /data/mysql/mysql3308/mysql.sock #连接数据库
alter user root@'localhost' identified by '123456'; //第一次修改密码

3、192.168.31.209:3309实例部署

a、配置文件

mkdir -p /data/mysql/mysql3309/{data,logs} #创建MySQL数据及日志目录
vi /data/mysql/mysql3309/my3309.cnf #配置文件整理
[client]
#password       = your_password
port            = 3309
socket          = /data/mysql/mysql3309/mysql.sock
default-character-set=utf8
[mysqld]
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
binlog_cache_size=20M
thread_stack = 512K
join_buffer_size=20M
query_cache_type = 1
max_heap_table_size = 2048M
port=3309
socket=/data/mysql/mysql3309/mysql.sock
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3309/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
key_buffer_size = 1024M
max_allowed_packet=100G
table_open_cache = 4096
sort_buffer_size=4M
net_buffer_length = 4K
read_buffer_size = 4096K
read_rnd_buffer_size = 2048K
myisam_sort_buffer_size = 128M
thread_cache_size = 512
query_cache_size = 384M
tmp_table_size = 2048M
max_connections=1024
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format=mixed
server_id=4
expire_logs_days=7
slow_query_log=on
slow_query_log_file=/data/mysql/mysql3309/logs/slow.log
long_query_time=0.5
log_queries_not_using_indexes=1
log_error=/data/mysql/mysql3309/logs/error.log
log_bin=/data/mysql/mysql3309/logs/mysql-bin
gtid_mode=on
enforce_gtid_consistency=true
log_slave_updates=1
wait_timeout=60
innodb_buffer_pool_size=8096M
innodb_log_file_size=256M
innodb_log_buffer_size=64M
innodb_flush_log_at_trx_commit=1
innodb_log_files_in_group=2
max_binlog_cache_size=512M
max_binlog_size=2048M
binlog_group_commit_sync_delay=100 #主库
binlog_group_commit_sync_no_delay_count=20 #主库
slave_parallel_type=logical_clock #从库配置
slave_parallel_workers=4 #从库配置
transaction_write_set_extraction=XXHASH64 #从库配置
binlog_transaction_dependency_tracking=writeset #从库配置
slave_preserve_commit_order=1 #从库配置
sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 500M
[mysql]
no-auto-rehash
default-character-set=utf8
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 2M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

b、初始化及授权

chown -R mysql:mysql /data/mys* #更改数据权限组
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3309/my3309.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3309/data #初始化数据库
mysqld --defaults-file=/data/mysql/mysql3309/my3309.cnf & #启动3309数据库
grep 'temporary password' /data/mysql/mysql3309/logs/error.log #获取临时密码
firewall-cmd --zone=public --add-port=3309/tcp --permanent #开启3309端口 
firewall-cmd --reload #刷新防火墙
mysql -uroot -p -S /data/mysql/mysql3309/mysql.sock #连接数据库
alter user root@'localhost' identified by '123456'; //第一次修改密码

第一台mysql服务器已经配置好

相关推荐
苹果醋32 小时前
React源码02 - 基础知识 React API 一览
java·运维·spring boot·mysql·nginx
盛派网络小助手3 小时前
微信 SDK 更新 Sample,NCF 文档和模板更新,更多更新日志,欢迎解锁
开发语言·人工智能·后端·架构·c#
别致的影分身4 小时前
使用C语言连接MySQL
数据库·mysql
过过过呀Glik4 小时前
在 Ubuntu 上安装 MySQL 的详细指南
mysql·ubuntu
zquwei4 小时前
SpringCloudGateway+Nacos注册与转发Netty+WebSocket
java·网络·分布式·后端·websocket·网络协议·spring
Sunyanhui17 小时前
牛客网 SQL36查找后排序
数据库·sql·mysql
老王笔记7 小时前
MHA binlog server
数据库·mysql
快乐非自愿7 小时前
分布式系统架构2:服务发现
架构·服务发现
2401_854391087 小时前
SSM 架构中 JAVA 网络直播带货查询系统设计与 JSP 有效实现方法
java·开发语言·架构
264玫瑰资源库7 小时前
从零开始C++棋牌游戏开发之第二篇:初识 C++ 游戏开发的基本架构
开发语言·c++·架构