LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 4522|回复: 4

mysql 同步成功了

[复制链接]
发表于 2006-1-5 22:39:58 | 显示全部楼层 |阅读模式
A:
mysql -V
mysql  Ver 12.22 Distrib 4.0.18, for mandrake-linux-gnu (i586)
B:
mysql -V
mysql  Ver 12.22 Distrib 4.0.20, for mandrake-linux-gnu (i586)

A: 192.168.1.112
B: 192.168.7.169

A: master
B: slave

A:
/etc/my.cnf

log-bin
server-id       = 1
sql-bin-update-same
binlog-do-db=synca

B:
/etc/my.cnf

server-id       = 2
master-host     = 192.168.1.112
master-user     = userab
master-password = apasswd
replicate-do-db = syncb
log-slave-updates
master-connect-retry = 10

B:
mysql -h 192.168.1.112 -u auser -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12 to server version: 4.0.18-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>use async ;
show tables ;
+------------------------+
| Tables_in_adeptechsync |
+------------------------+
| emp                    |


A:
mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 4.0.18-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show master status ;
+-----------------+----------+--------------+------------------+
| File            | Position | Binlog_do_db | Binlog_ignore_db |
+-----------------+----------+--------------+------------------+
| a-bin.014 | 404      | async |                  |
+-----------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> show databases ;
+--------------+
| Database     |
+--------------+
| database     |
async


B:
mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11 to server version: 4.0.20-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show slave status ;
| 192.168.1.112 | b      | 3306        | 10            | a-bin.014 | 404                 | b-relay-bin.031 | 46            | a-bin.014       | Yes              | Yes               | bsync      |                     | 0          |            | 0            | 404                 | 46              |
mysql> show databases ;
+--------------+
| Database     |
+--------------+
| database     |
bsync



NOTE:
A电脑192.168.1.112有async数据库为master,其中有一用户userab的权限可在B登入A用mysql所有权限
B电脑192.168.7.169有bsync数据库为slave,其中有一用户userab有本地所有权限

每一次对A中async有改变的时候,在B上运行
show slave status ;
会发现与A的
show master status ;
中的position是一样的在增变...

A:

less /var/lib/mysql/a.err
60105 21:38:58  mysqld started
060105 21:38:58  InnoDB: Started
/usr/sbin/mysqld: ready for connections.
Version: '4.0.18-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306

A:
mysql> show processlist ;
| 45 | userab | b:43118 | NULL         | Binlog Dump | 1748 | Has sent all binlog to slave; waiting for binlog to be updated | NULL  

B:
060105 23:10:07  mysqld started
060105 23:10:07  InnoDB: Started
060105 23:10:07  Found an entry in the 'db' table with empty database name; Skipped
060105 23:10:07  Slave SQL thread initialized, starting replication in log 'a-bin.015' at position 79, relay log
'./b-relay-bin.032' position: 692
/usr/sbin/mysqld: ready for connections.
Version: '4.0.20-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306
060105 23:10:07  Slave I/O thread: connected to master 'userabl@192.168.1.112:3306',  replication started in log a-bin.015' at position 79





但是数据没有改变为什么>>>>>>>>>>>

也就是最终没成功,兄弟指点一下下啰.





谢谢
 楼主| 发表于 2006-1-6 10:07:24 | 显示全部楼层

今天多出来的提示

060106  7:35:04  Aborted connection 3 to db: 'syncb' user: 'userab' host: `localhost' (Got timeout reading com
munication packets)
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-1-6 21:59:34 | 显示全部楼层
只要让两边的数据库名是一样的就可以了,这是为什么...

成功验证OK了..

分别将自己和其它电脑设为master,slave就可以同步了...
晚安
回复 支持 反对

使用道具 举报

发表于 2006-4-29 09:36:09 | 显示全部楼层
哈哈. 谢谢分享.. 收藏..
回复 支持 反对

使用道具 举报

发表于 2008-9-25 13:45:45 | 显示全部楼层

我想问下你的A:master B:slave是什么?

那个名字是如何来的??
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表