mysql 5.7配置小記

常配置MySQL服務的一些設置記錄mysql

[client]
port = 3306
default-character-set = utf8
sql

[mysqld]
port = 3306
user = mysql
character-set-server = utf8
skip-external-locking
skip_name_resolve = ON
bind_address=
ide

max_connections = 5000
max_connect_errors = 10
max_allowed_packet = 64M
ui

default-storage-engine = INNODB
innodb_file_per_table = 1
innodb_buffer_pool_size = 16G
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 60
innodb_flush_method = O_DIRECT
spa

default-time-zone = '+8:00'
event_scheduler = ON
open_files_limit = 51200
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 16M
orm

thread_cache_size = 64
query_cache_type = 1
query_cache_size = 256M
query_cache_limit = 10M
server

transaction_isolation = READ-COMMITTED
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
ip

server-id = 1
log_bin = mysql-bin
binlog_format = mixed
binlog_ignore_db = mysql
expire_logs_days = 90
it

log_error =/var/log/mysql-error.log
innodb_print_all_deadlocks = 1
slow_query_log = 1
long_query_time = 5
log_queries_not_using_indexes = 1
slow_query_log_file =/var/log/mysql-slow.log
io

[mysqldump]
quick
max_allowed_packet = 500M

 

systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld
grep "temporary password" /var/log/mysqld.log
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Uiop!789';

grant replication slave on *.* to 'repuser'@'slaveip' identified by 'Ei:saH0u9ys<';
flush privileges;
show master status;

slave的配置
server-id=18
log-bin = mysql-bin
sync_binlog=1
binlog_format=row
binlog_ignore_db=mysql
expire_logs_days = 30

change master to master_host='masterip',master_port=3306,master_user='repuser',master_password='Ei:saH0u9ys<',master_log_file='bin-log.000005',master_log_pos=120;
start slave;
show slave status\G

主庫設置binlog_group_commit_sync_delay=1

在MySQL5.7中,開啓enhanced multi-threaded slave,從庫具體配置參數以下: slave-parallel-type=LOGICAL_CLOCK slave-parallel-workers=8 master_info_repository=TABLE relay_log_info_repository=TABLE relay_log_recovery=ON

相關文章
相關標籤/搜索