Java Tour

 

mysql 主从库环境搭建 手记

环 境 
a.下载 BeanSoft的绿色版mysql (Copy 成两份 ,master,slave) 取mysql\mysql50green下内容复制
b. 在cmd命令行模式下进入master \bin  执行mysqld install  master命令。作用是为Mysql安装一个服务,服务名是 master 。同理操作slave 。(注意 mysqld =mysqld-nt

c. 在运行里运行REGEDIT,打开WINDOWS注册表编辑器,
在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\master 打开,
修改下面的ImagePath数值: "X:\ master \bin\mysqld" --defaults-file="D:\master\my.ini"  master 
确定,退出注册表编辑器。 (同理操作slave)
d.定义my.ini拷贝到 X:\ master  下面
[client]
   port = 3308
   [mysqld]
    port           =3308
    server-id    = 1
    binlog-do-db=test1  ##要同步的数据库名为test1 
    log-bin    =mysql-bin
e.定义my.ini拷贝到x:\slave下面
[client]
   port        = 3309

   [mysqld]
   port        = 3309
   server-id       = 2

   master-host     =   127.0.0.1

   master-user     =   slaver1

   master-password =   slaver1pwd

   master-port     =  3308

   replicate-do-db=test1  ##要同步的数据库
f.  

然后在master 
Console 执行: GRANT FILE,SELECT,REPLICATION SLAVE ON *.* TO 'slaver1'@'127.0.0.1' IDENTIFIED BY 'slaver1pwd';
开一个新账号(用户名:slaver1 密码:slaver1pwd)并赋于权限 
运行Mysqld.exe,并创建新数据库test1,可在Console下输入:show master status\G查看状态!

   *************************** 1. row*****************
            File: mysql-bin.000305
            Position: 98
            Binlog_Do_DB: test1
            Binlog_Ignore_DB:

g.

 运行Slaver 的Mysqld.exe,在Console窗口执行 show slave status\G  查看状态,如下:

mysql> show slave status\G
*************************** 1. row ***************************
             Slave_IO_State: Waiting for master to send event
                Master_Host: 127.0.0.1
                Master_User: slaver1
                Master_Port: 3308
              Connect_Retry: 60
            Master_Log_File: mysql-bin.000002
        Read_Master_Log_Pos: 2495
             Relay_Log_File: 2012-0416-1022-relay-bin.000007
              Relay_Log_Pos: 235
      Relay_Master_Log_File: mysql-bin.000002
           Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
            Replicate_Do_DB: test1
        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: 2495
            Relay_Log_Space: 235
            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.00 sec)



posted on 2012-11-11 17:10 花滿樓 阅读(160) 评论(0)  编辑  收藏

导航

统计

常用链接

留言簿

随笔档案

友情链接

搜索

最新评论

阅读排行榜

评论排行榜