CentOS5.3��mysql˫���ȱ�
���˴�������ʱ���о�mysql 5.0.* ���ο��˺ܶ��ĵ������㽫mysql��˫���ȱ����㶨�ˡ������ܺã�д�����¼���һ�¡���Ϊ�Ժ���ʵ���õ�������Ҳ�����±ʼǡ�
ʹ����̨��������nod1��nod2���ֱ����������������Žӵ����������ϡ�
nod1 eth0:192.168.145.162
eth1:192.168.254.1
nod2 eth0:192.168.145.168
eth1:192.168.254.2
1.������װmysql.
���ȸɾ���ϵͳ�����Ǹɾ���ϵͳ��Ҫ���������Լ����������ˡ���nod1�ϰ�װmysql.
yum -y install mysql-server
chkconfig mysqld on
service mysqld start
mysqladmin -uroot password’1q2w3e’��root���롣
nod2��ͬ����ʽ��װmysql���������ϲ�����
2.nod1��mysql�����á�
�������Ҿ���test���ݿ��������ԣ���test���ݿ����½�һ��data����������һЩ���ݣ������������£�
#mysql -uroot -p1q2w3e
mysql> create table data(name VARCHAR(20), address VARCHAR(50), phone VARCHAR(20));
mysql>insert into data(name,address,phone) values(‘johnson’,’shanghai’,'135000000′);mysql>select * from data;
+———+———-+———–+
| name | address | phone |
+———+———-+———–+
| johnson | shanghai | 135000000 |
+———+———-+———–+
1 row in set (0.01 sec)
�������ݿ�ͬ���ʻ���
mysql>GRANT REPLICATION SLAVE,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO ‘backup’@'192.168.254.2′ IDENTIFIED BY ‘qawsed’;
(������192.168.254.2�����ϵ�¼�û�backup���ݸ���Ȩ�ޣ�4.02�汾��ǰ�ã�GRANT FILE ON *.* TO [email protected] IDENTIFIED BY ‘qawsed’;)
mysql>flush privileges;
mysql> select user,host from user;
+——–+——————+
| user | host |
+——–+——————+
| root | 127.0.0.1 |
| backup | 192.168.254.2 |
| | localhost |
| root | localhost |
| | nod1.test.domain |
| root | nod1.test.domain |
+——–+——————+
6 rows in set (0.01 sec)
���������
ֹͣmysql����
service mysqld stop
��[mysqld]�����������
server-id=1 #���÷�������ID��
log-bin #����ͬ��log
binlog-do-db=test #����ͬ�����ݿ�
max_binlog_size=104857600
replicate-same-server-id
master-host=192.168.254.2 #����IP
master-user=backup
master-password=qawsed
master-port=3306
master-connect-retry=60 #�ϵ����Լ���Ϊ60��
replicate-do-db=test #��ʾͬ��test���ݿ�
binlog-ignore-db=mysql #��ͬ�������ݿ�
# service mysqld start //������mysql
# mysqldump -h localhost -u root -p1q2w3e test >test.sql
#scp test.sql [email protected]:/ //����test.sql���Ƶ�mysqlB��/Ŀ¼�£�
����nod1���������й�mysql�����������ɣ���һ����ʼ����nod2
����nod2
�������ݿ�ͬ���ʻ���
mysql>GRANT REPLICATION SLAVE,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO ‘backup’@'192.168.254.1′ IDENTIFIED BY ‘qawsed’;
(������192.168.254.1�����ϵ�¼�û�backup���ݸ���Ȩ�ޣ�4.02�汾��ǰ�ã�GRANT FILE ON *.* TO [email protected] IDENTIFIED BY ‘qawsed’;)
mysql>flush privileges;
���������
ֹͣmysql����
#service mysqld stop
����Mysql�����ļ�/etc/my.cnf
# vi /etc/my.cnf
server-id=2 #���÷�������ID��
log-bin #����ͬ��log
binlog-do-db=test #����ͬ�����ݿ�
max_binlog_size=104857600
replicate-same-server-id
master-host=192.168.254.1 #����IP
master-user=backup
master-password=qawsed
master-port=3306
master-connect-retry=60 #�ϵ����Լ���Ϊ60��
replicate-do-db=test #��ʾͬ��test���ݿ�
binlog-ignore-db=mysql #��ͬ�������ݿ�
��ԭ��mysqlA���ݹ���test.sql
#service mysqld start
# mysql -u root -p1q2w3e test
�������ߵ�mysql����
��ѯ����
Show Slave status:�˴�Slave_IO_Running ,Slave_SQL_Running ��Ӧ����yes,��ʾ�ӿ���I/O,Slave_SQL�̶߳���ȷ����.
��Mysql�п�ͨ�������������鿴����״̬
show master status �鿴master״̬
show slave status �鿴slave״̬
show processlist G �鿴��ǰ����
stop slave ��ʱֹͣslave����
start slave ��ʼslave����
��primary�������� MySQL�����������룺
mysql>show master status;
+——————-+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————-+———-+————–+——————+
| mysqld-bin.000001 | 196 | test | mysql |
+——————-+———-+————–+——————+
1 row in set (0.00 sec)
mysql>show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.254.1
Master_User: backup
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqld-bin.000001
Read_Master_Log_Pos: 235
Relay_Log_File: mysqld-relay-bin.000003
Relay_Log_Pos: 236
Relay_Master_Log_File: mysqld-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: test
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: 235
Relay_Log_Space: 236
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
1 row in set (0.01 sec)
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: test
��ʾ������
����mysql��˫�������ѻ������ɣ�����̨��������mysql���ݿ��������������ݣ�������ͬ�����Զ˷�������
- ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
- �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
- �������е���ɫ
- �������ж�IP��ַ��A��B���C��
- ������ϵ��Ц�� (ʷ����ȫ��
- ��Google���������ŵ���ͨv4.0
- ���ٶ�ͳ��URL��hm������utm�����Ķ�Ӧ��ϵ
- ��ƻ������MACbook Air���ݼ���ȫ
- ��Linux��ʹ��host��dig��nslookup��ѯDNS
- ���������ԡ���װ Windows XP ����ϵͳ��ͼ��ȫ����
- �����Լ���VPS�Google��������
- ��С�ڴ�VPS֮Nginx+PHP-fpm�߸����Ż���ѹ�����Է���