亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3812 | 回復: 0
打印 上一主題 下一主題

MySQL主從異步復制【轉】 [復制鏈接]

論壇徽章:
1
子鼠
日期:2014-05-04 13:59:31
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2011-07-06 00:15 |只看該作者 |倒序瀏覽
修杰_JIANG
                                                                                                www.geeux.com



目標:       實現(xiàn)MySQL主從復制,達到實時備份的目的
系統(tǒng)概況:   系統(tǒng):CentOS;內(nèi)核版本:2.6.18-194.el5 MySQL: 5.1.54
網(wǎng)絡地址:   master:192.168.85.101 slave:192.168.85.102


                       
                        一、安裝MySQL
                        二、配置
                        三、驗證、測試





一、安裝mysql(主從相同)
  1. #useradd mysql -s /sbin/nologin
  2. #tar zxvf mysql-5.1.54.tar.gz
  3. #cd mysql-5.1.54
  4. #./configure --prefix=/usr/local/mysql --localstatedir=/opt/data --with-extra-charsets=utf8,gb2312,gbk --with-pthread --enable-thread-safe-client
  5. #make
  6. #make install
  7. #cp support-files/my-large.cnf /etc/my.cnf
  8. #cd /usr/local/mysql
  9. # chgrp -R mysql .
  10. #/usr/local/mysql/bin/mysql_install_db --user=mysql
  11. # chown -R mysql:mysql /opt/data
  12. # /usr/local/mysql/bin/mysqld_safe --user=mysql &
  13. #/usr/local/mysql/bin/mysqladmin -u root password sairl
  14. #echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &" >>/etc/rc.local
  15. #echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
  16. #source /etc/profile
復制代碼
二、配置

1)、修改slav服務器的server-id(master服務器不變)
  1. 56 # required unique id between 1 and 2^32 - 1
  2. 57 # defaults to 1 if master-host is not set
  3. 58 # but will not function as a master if omitted
  4. 59 server-id       = 10
  5. 60
  6. 61 # Replication Slave (comment out master section to use this)
復制代碼
2)、授權(在master服務器上操作)
  1. mysql> GRANT REPLICATION SLAVE ON *.*
  2. -> TO 'backup'@'192.168.85.102' IDENTIFIED BY 'testpwd';
  3. Query OK, 0 rows affected (0.00 sec)

  4. mysql> show master status;      //主數(shù)據(jù)庫狀態(tài)
  5. +------------------+----------+--------------+------------------+
  6. | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
  7. +------------------+----------+--------------+------------------+
  8. | mysql-bin.000003 |      409 |              |                  |
  9. +------------------+----------+--------------+------------------+
復制代碼
3)、配置slave服務器
  1. mysql> change master to
  2. -> master_host='192.168.85.101',
  3. -> master_user='backup',
  4. -> master_password='testpwd',
  5. -> master_log_file='mysql-bin.000003',
  6. -> master_log_pos=409;
  7. Query OK, 0 rows affected (0.00 sec)
  8. mysql> start slave;
  9. Query OK, 0 rows affected (0.00 sec)
復制代碼
查看一下同步狀態(tài)
  1. mysql> show slave status\G
  2. *************************** 1. row ***************************
  3.                Slave_IO_State: Waiting for master to send event
  4.                   Master_Host: 192.168.85.101
  5.                   Master_User: replication
  6.                   Master_Port: 3306
  7.                 Connect_Retry: 60
  8.               Master_Log_File: mysql-bin.000003
  9.           Read_Master_Log_Pos: 720
  10.                Relay_Log_File: sairl-DB-2-relay-bin.000008
  11.                 Relay_Log_Pos: 251
  12.         Relay_Master_Log_File: mysql-bin.000003
  13.              Slave_IO_Running: Yes
  14.             Slave_SQL_Running: Yes
  15.               Replicate_Do_DB:
  16.           Replicate_Ignore_DB:
  17.            Replicate_Do_Table:
  18.        Replicate_Ignore_Table:
  19.       Replicate_Wild_Do_Table:
  20.   Replicate_Wild_Ignore_Table:
  21.                    Last_Errno: 0
  22.                    Last_Error:
  23.                  Skip_Counter: 0
  24.           Exec_Master_Log_Pos: 720
  25.               Relay_Log_Space: 556
  26.               Until_Condition: None
  27.                Until_Log_File:
  28.                 Until_Log_Pos: 0
  29.            Master_SSL_Allowed: No
  30.            Master_SSL_CA_File:
  31.            Master_SSL_CA_Path:
  32.               Master_SSL_Cert:
  33.             Master_SSL_Cipher:
  34.                Master_SSL_Key:
  35.         Seconds_Behind_Master: 0
  36. Master_SSL_Verify_Server_Cert: No
  37.                 Last_IO_Errno: 0
  38.                 Last_IO_Error:
  39.                Last_SQL_Errno: 0
  40.                Last_SQL_Error:
  41. 1 row in set (0.00 sec)
復制代碼
PS:slave_IO進程及slave_SQL進程都必須正常運行  
三、驗證、測試
主從復制測試:在master數(shù)據(jù)庫服務器上創(chuàng)建庫和表,然后再插入記錄,再登陸到slave服務器,看是否也建立相一致的庫和表以及記錄。
  1. mysql> create database test_db;
  2. Query OK, 1 row affected (0.00 sec)

  3. mysql> use test_db;
  4. Database changed
  5. mysql> create table test_table(id int(5),name char(10));
  6. Query OK, 0 rows affected (0.00 sec)

  7. mysql> insert into test_table
  8.     -> values(01,'xiujie');
  9. Query OK, 1 row affected (0.00 sec)

  10. 現(xiàn)在登錄slave數(shù)據(jù)庫服務器,看是否成功同步。
  11. mysql> show databases;
  12. +--------------------+
  13. | Database           |
  14. +--------------------+
  15. | information_schema |
  16. | mysql              |
  17. | test               |
  18. | test_db            |
  19. +--------------------+
  20. 4 rows in set (0.02 sec)

  21. mysql> use test_db;
  22. Database changed
  23. mysql> show tables;
  24. +-------------------+
  25. | Tables_in_test_db |
  26. +-------------------+
  27. | test_table        |
  28. +-------------------+
  29. 1 row in set (0.00 sec)

  30. mysql> select * from test_table;
  31. +------+--------+
  32. | id   | name   |
  33. +------+--------+
  34. |    1 | xiujie |
  35. +------+--------+
  36. 1 row in set (0.00 sec)
復制代碼
OK,配置到此結束
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP