MySQL5.7服务器IP是192.168.31.209及192.168.31.210

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

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服务器已经配置好

09-12 04:03