log-error = /media/raid10/mysql/3306/mysql_error.log
pid-file = /media/raid10/mysql/3306/mysql.pid
open_files_limit = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 16M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 20M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 20M
max_heap_table_size = 20M
long_query_time = 3
log-slave-updates
log-bin = /media/raid10/mysql/3306/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 20M
relay-log-index = /media/raid10/mysql/3306/relaylog/relaylog
relay-log-info-file = /media/raid10/mysql/3306/relaylog/relaylog
relay-log = /media/raid10/mysql/3306/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 10M
read_buffer_size = 1M
read_rnd_buffer_size = 6M
bulk_insert_buffer_size = 4M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 20M
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
skip-name-resolve
#master-connect-retry = 60
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
#master-host=172.29.141.112
#master-user = admin
#master-password = 12345678
#master-port = 3306
server-id = 2
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 20M
innodb_data_file_path = ibdata1:56M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 20M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
#log-slow-queries = /media/raid10/mysql/3306/slow.log
#long_query_time = 10
[mysqldump]
quick
max_allowed_packet = 32M
六.通过查看master的状态(在master上查看),为配置slave做准备
mysql> show master status/G;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 13
Current database: blog
*************************** 1. row ***************************
File: binlog.000005
Position: 592
Binlog_Do_DB: blog
Binlog_Ignore_DB: mysql
1 row in set (0.01 sec)
ERROR:
No query specified
从上面的信息,可以看出,master现在使用的binlog是binlog.000005,position是592,那么下面的slave配置必须与这个对应。
其实binlog.000005是当前master使用的binlog日志文件
position是当前master使用的binlog.000005日志文件的位置
简单理解为master正在使用哪个binlog的哪个数据行(位置)。
七.如果是5.5.3-m3版本mysql,需要启动slave后,配置与master相关对应的信息(在slave上配置)
注意,这个与第六步相对应
mysql> stop slave ;
mysql> change master to master_host='172.29.141.112', master_user='admin', master_password='12345678', master_log_file='binlog.000005', master_log_pos=488;
mysql> CHANGE MASTER TO MASTER_CONNECT_RETRY=60;
这个与5.0的配置my.cnf作用是一样的,配置成与master相对应的内容
主要是配置slave,让slave知道从master的哪个binlog上的哪个位置复制数据。所以需要知道master的ip,user_name,user_passwd,binlog,binlog_position以及多长时间连接一次master
八.开启slave
mysql> start slave;
九.解除master只读限制,并做测试
mysql> unlock tables;
mysql> use blog;
mysql> create longxibendi ( a int, b int );
十.从slave上查看
mysql> use blog;
mysql> show tables;
+---------------