MySQL主從複製配置
Master
192.168.102.168
[mysql@fiona bin]$ mysqladmin -uroot -p version
Enter password:
mysqladmin Ver 8.42 Distrib 5.5.39, for Linux on x86_64
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Server version 5.5.39-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /usr/local/mysql/mysql.sock
Uptime: 44 min 15 sec
Threads: 1 Questions: 9 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.003
Slave
192.168.102.130
[root@fiona2 home]# mysqladmin -uroot -p version
mysqladmin Ver 8.42 Distrib 5.1.71, for redhat-linux-gnu on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Server version 5.5.39-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /usr/local/mysql/mysql.sock
Uptime: 5 min 2 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.006
Steps:
//檢視是否啟用了日誌
mysql> show variables like 'log_bin' ;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.01 sec)
//檢視master的status
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000019 | 107 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
//切換到data下面用mysqlbinlog檢視bin log
[root@fiona ~]# cd /usr/local/mysql/data
[root@fiona data]# mysqlbinlog mysql-bin.000002 | tail -20
SET TIMESTAMP=1408843507/*!*/;
COMMIT
/*!*/;
# at 1070530
#140824 9:25:07 server id 1 end_log_pos 1070549 Stop
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
mysql> use test
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table TEST(
-> ID bigint not null primary key,
-> NAME varchar(15) not null,
-> EMAIL varchar(128) not null);
Query OK, 0 rows affected (0.04 sec)
mysql> insert into TEST (ID,NAME,EMAIL) values ('001','AAA','aaa@163.com');
Query OK, 1 row affected (0.03 sec)
mysql> insert TEST (ID,NAME,EMAIL) values ('003','CCC','ccc@163.com'),('002','BBB','bbb@163.com');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
Reference:
Mysql5.5配置主從複製
http://ylw6006.blog.51cto.com/470441/888523
MYSQL啟動後報:ERROR! The server quit without updating PID file錯誤的問題解決
Reference:http://blog.csdn.net/faye0412/article/details/7038290
192.168.102.168
[mysql@fiona bin]$ mysqladmin -uroot -p version
Enter password:
mysqladmin Ver 8.42 Distrib 5.5.39, for Linux on x86_64
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Server version 5.5.39-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /usr/local/mysql/mysql.sock
Uptime: 44 min 15 sec
Threads: 1 Questions: 9 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.003
Slave
192.168.102.130
[root@fiona2 home]# mysqladmin -uroot -p version
mysqladmin Ver 8.42 Distrib 5.1.71, for redhat-linux-gnu on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Server version 5.5.39-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /usr/local/mysql/mysql.sock
Uptime: 5 min 2 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.006
Steps:
//檢視是否啟用了日誌
mysql> show variables like 'log_bin' ;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.01 sec)
//檢視master的status
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000019 | 107 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
//切換到data下面用mysqlbinlog檢視bin log
[root@fiona ~]# cd /usr/local/mysql/data
[root@fiona data]# mysqlbinlog mysql-bin.000002 | tail -20
SET TIMESTAMP=1408843507/*!*/;
COMMIT
/*!*/;
# at 1070530
#140824 9:25:07 server id 1 end_log_pos 1070549 Stop
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
mysql> use test
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table TEST(
-> ID bigint not null primary key,
-> NAME varchar(15) not null,
-> EMAIL varchar(128) not null);
Query OK, 0 rows affected (0.04 sec)
mysql> insert into TEST (ID,NAME,EMAIL) values ('001','AAA','aaa@163.com');
Query OK, 1 row affected (0.03 sec)
mysql> insert TEST (ID,NAME,EMAIL) values ('003','CCC','ccc@163.com'),('002','BBB','bbb@163.com');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
有個小技巧跟大家介紹下,我在準備轉換的時候發現日誌檔案有2G多,尋思著為什麼mysql為什麼不把日誌按日誌定期的分多個檔案放呢。結果發現mysql有個更好的方法,可以透過時間引數獲取某個時間段的資料,例子如下:mysqlbinlog --start-datetime="2010-11-20 00:00:00" --stop-datetime="2010-11-21 00:00:00"
Reference:
Mysql5.5配置主從複製
http://ylw6006.blog.51cto.com/470441/888523
MYSQL啟動後報:ERROR! The server quit without updating PID file錯誤的問題解決
Reference:http://blog.csdn.net/faye0412/article/details/7038290
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26477398/viewspace-1625815/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql複製--主從複製配置MySql
- MySql 主從複製配置MySql
- 配置mysql5.5主從複製、半同步複製、主主複製MySql
- MYSQL主從複製配置(整理)MySql
- MYSQL主從複製製作配置方案MySql
- mysql for linux 配置主從複製MySqlLinux
- mysql主從複製原理及配置MySql
- MySQL主從複製與主主複製MySql
- MySQL 主從複製安裝部署配置MySql
- Docker 教程十五配置MySQL 主從複製DockerMySql
- 簡單配置mysql的主從複製MySql
- Linux下配置MySQL主從複製LinuxMySql
- MySQL 主從複製的原理和配置MySql
- MySQL的主從複製與MySQL的主主複製MySql
- mysql5.7主從複製,主主複製MySql
- MySQL主從複製、半同步複製和主主複製MySql
- MySQL 主從複製MySql
- 【MySql】主從複製MySql
- MySQL主從複製MySql
- mysql主主複製(雙主複製)配置步驟MySql
- MySQL主從複製、半同步複製和主主複製概述MySql
- MySQL主從複製配置心跳功能介紹MySql
- MySQL基於binlog主從複製配置MySql
- mysql5.6.xGTID主從複製配置MySql
- MySQL主從複製_複製過濾MySql
- MySQL的主從複製、半同步複製、主主複製詳解MySql
- MySQL主從複製原理MySql
- MySQL的主從複製MySql
- mysql--主從複製MySql
- mysql主從複製搭建MySql
- mysql 8.4 主從複製MySql
- mysql主從複製配置與問題解決MySql
- MySQL主從複製之GTID複製MySql
- MySQL主從複製之半同步複製MySql
- MySQL主從複製之非同步複製MySql非同步
- MySQL主主複製(雙主複製)配置過程介紹MySql
- mysql主從複製(一):一主多從MySql
- MySQL++:Liunx - MySQL 主從複製MySql