mysql集羣搭建,主主複製

1:mysql搭建遠程鏈接html

http://www.javashuo.com/article/p-ykvwfkdm-dq.htmlmysql

2: 兩臺主機可以相互通訊 ,使用pinglinux

C:\Users\lenovo>ping 192.168.100.91

正在 Ping 192.168.100.91 具備 32 字節的數據:
來自 101.4.112.14 的回覆: TTL 傳輸中過時。
來自 101.4.112.14 的回覆: TTL 傳輸中過時。
來自 101.4.112.14 的回覆: TTL 傳輸中過時。
來自 101.4.112.14 的回覆: TTL 傳輸中過時。

192.168.100.91 的 Ping 統計信息:
    數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),

 3:mysql複製,備份web

liyafei OEM:~$ mysqldump -hlocalhost -uroot -p1367356 test>test.sqlspring

4: 配置主從複製sql

https://blog.csdn.net/wepe12/article/details/53086032ubuntu

http://www.javashuo.com/article/p-xcrglajm-cw.htmlwindows

   4.1: 配置主服務器,服務器

         a:  ubuntu 14.04,ip 192.168.100.91  做爲主服務器ide

           在/etc/mysql/my.cnf 文件裏面  mysqld下面添加

            log-bin=mysql-bin

            server-id=1  #惟一

         b: windows 10  ,192.168.100.31做爲從服務器

             在my.ini中修改

             log-bin=mysql-bin
             server-id=160 

     4.2:在主服務上面授予從服務器權限。              

# mysql> create user 'repl'@'192.168.100.31' identified by 'slavepass'; 
Query OK, 0 rows affected (0.00 sec) 
# mysql> grant replication slave on *.* to 'repl'@'192.168.100.31';   -- 權限授予了192.168.100.31   root,  因此這兩步能夠不用了
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; 
Query OK, 0 rows affected (0.00 sec) 
mysql> show master status;
 | File                     | Position | Binlog_Do_DB | Binlog_Ignore_DB | +--
| mysql-bin.000006 | 592 | | | +--------------- 1 row in set (0.00 sec)

4.3:  從服務器指向主服務器,和mysql-bin二進制文件和位置position。 

mysql> change master to
    -> master_host='192.168.100.91',
    -> master_user='root',
    -> master_password='1367356',
    -> master_log_file='mysql-bin.000006',
    -> master_log_pos=592;
Query OK, 0 rows affected (0.06 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status;    # 查看從服務器狀態, io-running和 sql-running爲yes
+----------------------------------+----------------+-------------+-------------+---------------+------------------+---------------------+----------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+
| Slave_IO_State                   | Master_Host    | Master_User | Master_Port | Connect_Retry | Master_Log_File  | Read_Master_Log_Pos | Relay_Log_File                   | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error | Replicate_Ignore_Server_Ids | Master_Server_Id |
+----------------------------------+----------------+-------------+-------------+---------------+------------------+---------------------+----------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+
| Waiting for master to send event | 192.168.100.91 | root        |        3306 |            60 | mysql-bin.000006 |                 592 | LAPTOP-HBRSJQ2D-relay-bin.000002 |           253 | mysql-bin.000006      | Yes              | Yes               |                 |                     |                    |                        |                         |                             |          0 |            |            0 |                 592 |             419 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |             0 |               |              0 |                |                             |               64 |
+----------------------------------+----------------+-------------+-------------+---------------+------------------+---------------------+----------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+
1 row in set (0.00 sec)

4.4在主服務器上面建立表

 mysql> create database linux1; 
Query OK, 1 row affected (0.02 sec) 
mysql> use linux1;

4.5 從服務器自動改變

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| autocreatetable    |
| cms_boot           |
| crm                |
| dbsc               |
| forum              |
| labweb             |
| learner            |
| mysql              |
| ni                 |
| nihoa              |
| performance_schema |
| sakila             |
| shrio              |
| springsecurity     |
| xyz                |
| youhuigou          |
+--------------------+
17 rows in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| autocreatetable    |
| cms_boot           |
| crm                |
| dbsc               |
| forum              |
| labweb             |
| learner            |
| linux1             |
| mysql              |
| ni                 |
| nihoa              |
| performance_schema |
| sakila             |
| shrio              |
| springsecurity     |
| xyz                |
| youhuigou          |
+--------------------+
18 rows in set (0.00 sec)

 5:windows  開啓mysql端口號,防火牆

https://jingyan.baidu.com/article/4b07be3c9f959448b380f302.html

相關文章
相關標籤/搜索