主从复制主服务器标准配置my.cnf

[client]
port            = 3306

default-character-set = utf8
# The MySQL server

[mysqld]
port            = 3306
socket          = /tmp/mysql_smart.sock
user = mysql
server-id=171

#####################Standard Configuration########################

#Hugepage
#large-pages
skip-name-resolve
external-locking = FALSE

pid-file = /database/smart/data/smart.pid
datadir = /database/smart/data/
log-bin=/database/smart/binlog/smart_master-bin
log-bin-index=/database/smart/binlog/smart_master-bin.index
#delete binlog before 30 day
expire_logs_days =30

max_binlog_cache_size = 256M
max_binlog_size = 1G
binlog_cache_size = 64M
relay-log-index = /database/smart/relaylog/smart-relay-bin.index
relay-log-info-file = /database/smart/relaylog/smart-relay-bin
relay-log = /database/smart/relaylog/smart-relay-log.info

innodb_log_file_size = 200M
innodb_log_files_in_group=3
innodb_log_buffer_size = 128M


#tablespace 
innodb_file_per_table = 1
# first write log buffer ,secend write log file
innodb_flush_log_at_trx_commit = 2

innodb_lock_wait_timeout =50
innodb_thread_concurrency=8
innodb_read_io_threads=30 
innodb_write_io_threads=30

#event
event_scheduler = 1

#no lower and no upper
lower_case_table_names=1

#group_concat
group_concat_max_len=1M

# binary logging format - mixed recommended
binlog_format = mixed
init_connect='SET AUTOCOMMIT=0'
connect_timeout=600
wait_timeout=120
interactive_timeout=120
ft_min_word_len=1

default-storage-engine=INNODB
max_connections = 10000
max_connect_errors = 50000
max_user_connections=5000

max_allowed_packet=1024M

init-connect="SET NAMES utf8"
character-set-server =utf8


# apply to application
auto_increment_offset=1
auto_increment_increment=2

#slow_log
#must be restart
#log_slow_queries=1
log_output=table
long_query_time = 5
slow_query_log=1
#general_log_file=on
#log-queries-not-using-indexes

#####################Others Configuration########################

net_buffer_length = 8K
read_rnd_buffer_size = 8M

# cache
back_log = 512
key_buffer_size =256M
thread_stack = 256K
table_cache = 1024
sort_buffer_size = 128M
read_buffer_size = 4M
join_buffer_size = 8M
#record_buffer = 32M


myisam_sort_buffer_size = 128M
thread_cache = 32
thread_cache_size = 128
query_cache_size =256M
query_cache_type = 1
tmp_table_size = 20M
max_heap_table_size = 64M
thread_concurrency = 8
innodb_buffer_pool_size=2000M

binlog-do-db=smart 
binlog-do-db=firstdb
binlog-ignore-db=mysql 
replicate-do-db=smart 
replicate-ignore-db=mysql 
replicate-do-db=test
binlog-do-db=test


log-slave-updates
slave-skip-errors=all

[mysqldump]
quick
max_allowed_packet = 512M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
若要在 MySQL 8.0 的配置文件 my.cnf 中实现主从复制并使用 GTID 技术,可以按照以下方式进行配置: ``` [client] port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock server-id = 1 gtid-mode = ON enforce-gtid-consistency = ON log-bin = mysql-bin binlog-format = ROW binlog-checksum = NONE basedir = /usr/local/mysql datadir = /usr/local/mysql/data log_error = /var/log/mysql/error.log character_set_server = utf8mb4 collation_server = utf8mb4_unicode_ci default_authentication_plugin = mysql_native_password innodb_buffer_pool_size = 128M innodb_log_file_size = 64M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50 [mysql] default-character-set = utf8mb4 ``` 在 [mysqld] 部分,我们需要设置服务器的 ID (这里设置为 1),并开启 GTID 模式和强制 GTID 一致性。同时,我们需要开启二进制日志(log-bin),设置二进制格式为行格式(binlog-format)并关闭二进制日志校验(binlog-checksum)。 在服务器上,我们需要在每个事务提交时自动写入 GTID,以便从服务器可以按照 GTID 顺序进行复制。在从服务器上,我们需要启用 GTID,以便在从服务器获取数据时使用 GTID 进行同步。 此外,我们还可以根据实际情况配置 innodb_buffer_pool_size、innodb_log_file_size、innodb_flush_log_at_trx_commit、innodb_lock_wait_timeout 等参数,以优化数据库的性能。 需要注意的是,此配置文件只适用于主从复制的场景,如果您还需要配置其他的功能,可以根据具体需求进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值