mysql集群搭建,主主复制

1:mysql搭建远程连接

https://www.cnblogs.com/davidgu/p/3706663.html

2: 两台主机能够相互通信 ,使用ping

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复制,备份

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

4: 配置主从复制

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

https://www.cnblogs.com/gl-developer/p/6170423.html

4.1: 配置主服务器,

a:  ubuntu 14.04,ip 192.168.100.91  作为主服务器

在/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, rows affected (0.00 sec)
# mysql> grant replication slave on *.* to 'repl'@'192.168.100.31'; -- 权限授予了192.168.100.31 root, 所以这两步可以不用了
Query OK, rows affected (0.00 sec)
mysql> flush privileges;
Query OK, rows affected (0.00 sec)
mysql> show master status;
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +--
| mysql-bin. | | | | +---------------
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='',
-> master_log_file='mysql-bin.000006',
-> master_log_pos=;
Query OK, rows affected (0.06 sec) mysql> start slave;
Query OK, 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 | | | mysql-bin. | | LAPTOP-HBRSJQ2D-relay-bin. | | mysql-bin. | Yes | Yes | | | | | | | | | | | | None | | | No | | | | | | | No | | | | | | |
+----------------------------------+----------------+-------------+-------------+---------------+------------------+---------------------+----------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+-----------------------------+------------------+
row in set (0.00 sec)

4.4在主服务器上面创建表

 mysql> create database linux1;
Query OK, 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 |
+--------------------+
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 |
+--------------------+
rows in set (0.00 sec)

5:windows  开启mysql端口号,防火墙

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

上一篇:iPhone被盗后续更新二:被换机!已取机!没扣住新机!怎么找新机呢?事发半年后跟进...


下一篇:Ajax:后台jquery实现ajax无刷新删除数据及demo