错误:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.10
Master_User: slave001
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000018
Read_Master_Log_Pos: 107
Relay_Log_File: localhost3308-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000018
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 107
Relay_Log_Space: 107
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 1593
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
哎,经过几个小时的琢磨,终于看到庐山真面目了!以下是成功启动的效果;
[root@mysql ~]# mysqld_multi --defaults-extra-file=/etc/my.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running
[root@mysql ~]# mysqld_multi --defaults-extra-file=/etc/my.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running
[root@mysql ~]# mysqld_multi --defaults-extra-file=/etc/my.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running
[root@mysql ~]# mysqld_multi --defaults-extra-file=/etc/my.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running
[root@mysql ~]#
其实,在我配置muti的时候有些参数没有做好设置,到时server-id服务启动不起来,我把所有的muti的mysqld【1-4】全部放到我们的配置文件内/etc/my.cnf,包括我们的3306端口的实例库,在启动的时候一起跑即可!以下是我my.cnf的配置文件信心,请查阅;
# The following options will be passed to all MySQL clients
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = root
# Here follows entries for some specific programs
# The MySQL server
[mysqld1]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql
old_passwords=1
port=3306
skip-name-resolve
server_id=1
log-bin=mysql-bin
max_connections=1000
key_buffer_size=218348
query_cache_size=10
read_rnd_buffer_size=134228
table_cache=10000
tmp_table_size=5362
log-slow-queries=slow.log
long_query_time=1
concurrent_insert=2
thread_cache_size=300
#log=/usr/local/mysql/data/mysql1.log
pid-file=/usr/local/mysql/data/mysql1.pid
log-error=/usr/local/mysql/data/log.1
log-slave-updates
slave-skip-errors=ALL
[mysqld2]
datadir=/usr/local/mysql/data3307
socket=/tmp/mysql3307.sock
user=mysql
old_passwords=1
skip-name-resolve
server_id=222
log-bin=mysql-bin
max_connections=1000
key_buffer_size=218348
query_cache_type=0
read_rnd_buffer_size=1342128
table_cache=10000
tmp_table_size=5368912
log-slow-queries=slow.log
long_query_time=1
concurrent_insert=2
thread_cache_size=300
port=3307
pid-file=/usr/local/mysql/data3307/localhost3307.pid
log-error=/usr/local/mysql/data3307/log.2
[mysqld3]
datadir=/usr/local/mysql/data3308
socket=/tmp/mysql3308.sock
user=mysql
old_passwords=1
skip-name-resolve
server_id=223
log-bin=mysql-bin
max_connections=1000
key_buffer_size=218348
query_cache_type=0
read_rnd_buffer_size=1342128
table_cache=10000
tmp_table_size=5368912
log-slow-queries=slow.log
long_query_time=1
concurrent_insert=2
thread_cache_size=300
port=3308
pid-file=/usr/local/mysql/data3308/localhost3308.pid
log-error=/usr/local/mysql/data3308/log.3
[mysqld4]
datadir=/usr/local/mysql/data3309
socket=/tmp/mysql3309.sock
user=mysql
old_passwords=1
skip-name-resolve
server_id=224
log-bin=mysql-bin
max_connections=1000
key_buffer_size=218348
query_cache_type=0
read_rnd_buffer_size=1342128
table_cache=10000
tmp_table_size=5368912
log-slow-queries=slow.log
long_query_time=1
concurrent_insert=2
thread_cache_size=300
port=3309
pid-file=/usr/local/mysql/data3309/localhost3309.pid
log-error=/usr/local/mysql/data3309/log.4
以上就是配置的启动服务内容,我把server-id分到每个mysqld内部,并保持唯一即可,实现我们要做的单台服务器做主从复制的基本配置要求;配置主从的步骤很简单我就不在这里说了,有不了解如何做主从的可以随时留言即可,以下为我配置成功后主从的启动参数的效果;
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.10
Master_User: backup
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000032
Read_Master_Log_Pos: 893
Relay_Log_File: localhost3307-relay-bin.000003
Relay_Log_Pos: 253
Relay_Master_Log_File: mysql-bin.000032
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 893
Relay_Log_Space: 1194
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
ERROR:
No query specified
mysql>