20171124-凌晨操作184-185数据库主从同步

1.主184上操作

锁表备份,并且记录偏移量:

mysqldump -hlocalhost -uyxkj_mysql -p'密码' --default-character-set=utf8  --all-databases --lock-all-tables --master-data=1 >  /root/master20171123.sql
head -n30 /root/master20171123.sql
记录偏移量
master_log_file='{XXXXXX}',master_log_pos={XXXXXX}
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000038', MASTER_LOG_POS=88160710;

2.开启从数据库root远程登录、scp文件

# vi /etc/ssh/sshd_config
将 PermitRootLogin 值改yes
将 PasswordAuthentication 值改yes
#service sshd restart
/usr/bin/rsync -e 'ssh -p 60920' -ahqzt  /root/master20171123.sql root@192.168.20.185:/root/

3.在从数据库服务器上操作:

mysql -u yxkj_mysql -p  < /root/master20171123.sql
# mysql -u yxkj_mysql -p
MariaDB [(none)]> stop slave;
MariaDB [(none)]> reset slave;
MariaDB [(none)]> change master to master_host='192.168.20.184',master_user='yxkj_slave185',master_password='aFCWRP4B6vKhAB',master_port=61920,master_log_file='mysql-bin.000038',master_log_pos=88160710;
MariaDB [(none)]> start slave;
MariaDB [(none)]> show slave status\G

4关闭从数据库的root登录

# vi /etc/ssh/sshd_config
将 PermitRootLogin 值改no
将 PasswordAuthentication 值改no
#service sshd restart

结果,主从同步成功。

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.20.184
                  Master_User: yxkj_slave185
                  Master_Port: 61920
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000038
          Read_Master_Log_Pos: 143985964
               Relay_Log_File: yxkj_centos185-relay-bin.000002
                Relay_Log_Pos: 55825789
        Relay_Master_Log_File: mysql-bin.000038
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: m_7477_com,yxddz_7477_com
          Replicate_Ignore_DB: mysql,information_schema,performance_schema
           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: 143985964
              Relay_Log_Space: 55826095
              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
               Master_SSL_Crl:
           Master_SSL_Crlpath:
                   Using_Gtid: No
                  Gtid_IO_Pos:
1 row in set (0.00 sec)
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇