mysql5.5.20複製配置

zhouwf0726發表於2019-06-17

#從庫
grant all on *.* to'root'@'172.28.14.114'identified by '123456';
#修改my.cnf
[client]
#password       = your_password
port            = 3306
socket          = /data/mysql/data/mysql.sock

[mysqld]
server_id=2
federated
binlog_ignore_db=mysql,information_schema,performance_schema

datadir=/data/mysql/data
tmpdir=/data/mysql/tmp

skip-external-locking
key_buffer_size = 256M
myisam_sort_buffer_size = 64M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 24

back_log = 1024
max_connections = 1200
table_definition_cache=120000 
table_open_cache =120000    
max_connect_errors = 300

max_allowed_packet = 24M
read_rnd_buffer_size = 4M
read_buffer_size = 4M
join_buffer_size = 4M
sort_buffer_size = 2M
query_cache_limit = 2M

query_cache_size = 1024M
query_cache_min_res_unit=2k
thread_cache_size = 1200
thread_stack = 128K
tmp_table_size = 256M
max_tmp_tables = 256
bulk_insert_buffer_size = 4M
binlog_cache_size = 2M
max_binlog_size = 128M
max_binlog_cache_size= 512M

# log
log-error=/data/mysql/log/log
log-bin=/data/mysql/log/mysql-bin

slow-query-log
slow-query-log-file=/data/mysql/log/slow.log
long_query_time=1
log-queries-not-using-indexes

# innodb
innodb_buffer_pool_size = 18432M
innodb_data_home_dir = /data/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_file_per_table= 1
innodb_log_group_home_dir = /data/mysql/log
innodb_log_files_in_group=3
innodb_log_file_size = 512M
innodb_log_buffer_size = 16M
#innodb_file_io_threads = 4
innodb_thread_concurrency = 24
innodb_lock_wait_timeout = 100
innodb_flush_method = 'O_DIRECT'
innodb_max_dirty_pages_pct = 75
# innodb_flush_log_at_trx_commit=2

# replication
replicate_wild_ignore_table=mysql.%,information_schema.%,performance_schema.%
relay_log=/data/mysql/log/relay-bin
log_slave_updates

[mysqldump]
quick
max_allowed_packet = 16M

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

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

#主庫
mysql>grant replication slave on *.* torep_user@172.28.14.115identified by 'repl_user';

###### INNODB
$ mysqldump -uroot -p123456 --quick --single-transaction --master-data=1 --default-character-set=utf8 zwf > zwf.sql
###### MyISAM
mysql>flush tables with read lock;
mysal>show master status;
$ mysqldump -uroot -p123456 --opt zwf | mysql zwf -uroot -p123456 -h 172.28.14.115
mysql>unlock tables;

# 從庫 INNODB拷貝zwf.sql並找到change master對應的bin log和pos
# 從庫 MyISAM根據show master status結果找到change master對應的bin log和pos
mysql>change master to master_host='172.28.14.114',master_user='rep_user',master_password='repl_user',master_log_file='mysql-bin.000001',master_log_pos=694;
mysql>start slave;
mysql>show slave status\G;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-715454/,如需轉載,請註明出處,否則將追究法律責任。

相關文章