[英]Google Cloud MySQL and Master-master replication
I have two servers in different regions ( eu
, us
) connected to the same mysql database, I've started with google cloud sql second generation but it's only available on us
region.我在不同的区域(两台服务器
eu
, us
连接到同一个MySQL数据库),我已经开始与谷歌Cloud SQL的第二代,但它仅适用于us
地区。
The idea is to add a second sql nodes in the new region eu
but I can't find any documentation about Master-Master replication so it is not supported at this time.这个想法是在新的区域
eu
添加第二个 sql 节点,但我找不到任何关于主-主复制的文档,因此目前不支持。 Is this correct?这样对吗?
ps.附: both of my servers need read/write access.
我的两台服务器都需要读/写访问权限。
With my operational google sql in us
, can I just:在我的操作谷歌SQL
us
,我能:
I create a new google sql cloud in eu
.我在
eu
创建了一个新的 google sql 云。
Configure eu
as an External Replicas for us
.将
eu
配置为us
的外部副本。
Configure eu
as External Masters for us
.将
eu
配置为us
外部主站。
I'm really confused!我真的很困惑! Any help will be appreciated.
任何帮助将不胜感激。
/Ouss /乌斯
Google Cloud SQL 不支持 Master-Master。
Solution from: https://www.ryadel.com/en/mysql-master-master-replication-setup-in-5-easy-steps/解决方案来自: https : //www.ryadel.com/en/mysql-master-master-replication-setup-in-5-easy-steps/
Successfully implemented on Linux Ubuntu 16.04 in google cloud platform MySql 5.7 will not load on Debian.在Linux Ubuntu 16.04 上成功实现在google 云平台MySql 5.7 上不会在Debian 上加载。
/// Install MySQL on 2 VMs /// 在 2 个虚拟机上安装 MySQL
A. On VMs sql1 & sql2 A. 在虚拟机上 sql1 和 sql2
apt update
apt install mysql-server -y
P@ssW0rd2020 P@ssW0rd2020
B. Comment bind-address to allow global access B. 注释 bind-address 以允许全局访问
cd /etc/mysql/mysql.conf.d/
nano /etc/mysql/mysql.conf.d/mysqld.cnf
C. Restart MySQL Service (cnf changed) C. 重启 MySQL 服务(cnf 更改)
systemctl restart mysql
systemctl status mysql
D. On sql1 D. 在 sql1 上
nano /etc/mysql/conf.d/mysql.cnf
[mysqld] // note: not [mysql]
server-id=1
log-bin="mysql-bin"
binlog-ignore-db=test
binlog-ignore-db=information_schema
replicate-ignore-db=test
replicate-ignore-db=information_schema
relay-log="mysql-relay-log"
auto-increment-increment = 2
auto-increment-offset = 1
-------------------------------------
systemctl restart mysql
systemctl status mysql
D. On sql2 D. 在 sql2 上
nano /etc/mysql/conf.d/mysql.cnf
[mysqld]
server-id=2
log-bin="mysql-bin"
binlog-ignore-db=test
binlog-ignore-db=information_schema
replicate-ignore-db=test
replicate-ignore-db=information_schema
relay-log="mysql-relay-log"
auto-increment-increment = 2
auto-increment-offset = 2
-------------------------------------
systemctl restart mysql (THIS WILL CREATE BIN LOG)
systemctl status mysql
again, flush privileges; ---supposed to
E. Create the Replicator User(s) E. 创建复制器用户
Configure on both sql1 & 2 (replicator password can be same for, or not)在 sql1 和 2 上配置(复制器密码可以相同,也可以不同)
mysql -u root -p mysql -u 根 -p
P@ssW0rd2020 P@ssW0rd2020
CREATE USER 'replicator'@'%' IDENTIFIED BY 'P@ssW0rd2020'; CREATE USER 'replicator'@'%' IDENTIFIED BY 'P@ssW0rd2020'; GRANT REPLICATION SLAVE ON .
授予复制从属。 TO 'replicator'@'%' IDENTIFIED BY 'P@ssW0rd2020';
TO 'replicator'@'%' 由 'P@ssW0rd2020' 识别; flush privileges;
刷新权限;
F. Start with fresh VMs with no databases (better) or mutual import/export databases into sql1 & 2 https://dev.mysql.com/doc/refman/8.0/en/copying-databases.html F. 从没有数据库(更好)或相互导入/导出数据库到 sql1 和 2 https://dev.mysql.com/doc/refman/8.0/en/copying-databases.html 的新 VM 开始
G. Configure replication from sql1 to sql2 (make sql2 slave of sql1) G.配置从sql1复制到sql2(使sql2成为sql1的slave)
On sql1在 sql1 上
SHOW MASTER STATUS;显示主状态;
example output: +------------------+----------+--------------+------------------+ |示例输出:+-----------------+---------+--------------+- -----------------+ | File |
档案 | Position |
职位 | Binlog_Do_DB |
Binlog_Do_DB | Binlog_Ignore_DB |
Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ |
+-----------------+----------+--------------+---- --------------+ | mysql-bin.000001 |
mysql-bin.000001 | 448 |
第448话example |
示例 | test, informatio |
测试,信息| +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
+-----------------+----------+--------------+---- --------------+ 1 行(0.00 秒)
On sql2在 sql2 上
STOP SLAVE;停止奴隶; CHANGE MASTER TO MASTER_HOST = '104.154.225.215', MASTER_USER = 'replicator', MASTER_PASSWORD = 'P@ssW0rd2020', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 448;
将 MASTER 更改为 MASTER_HOST = '104.154.225.215', MASTER_USER = 'replicator', MASTER_PASSWORD = 'P@ssW0rd2020', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER448LOG; START SLAVE;
启动从机; flush privileges;
刷新权限;
H. Repeat for sql2 (make sql1 slave of sql2) H. 对 sql2 重复(使 sql1 成为 sql2 的从属)
on sql2在 sql2 上
SHOW MASTER STATUS;显示主状态;
example output: +------------------+----------+--------------+------------------+ |示例输出:+-----------------+---------+--------------+- -----------------+ | File |
档案 | Position |
职位 | Binlog_Do_DB |
Binlog_Do_DB | Binlog_Ignore_DB |
Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ |
+-----------------+----------+--------------+---- --------------+ | mysql-bin.000001 |
mysql-bin.000001 | 448 |
第448话example |
示例 | test, informatio |
测试,信息| +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
+-----------------+----------+--------------+---- --------------+ 1 行(0.00 秒)
On sql1在 sql1 上
STOP SLAVE;停止奴隶; CHANGE MASTER TO MASTER_HOST = '35.198.195.130', MASTER_USER = 'replicator', MASTER_PASSWORD = 'P@ssW0rd2020', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 448;
将 MASTER 更改为 MASTER_HOST = '35.198.195.130', MASTER_USER = 'replicator', MASTER_PASSWORD = 'P@ssW0rd2020', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER4_8_POS; START SLAVE;
启动从机;
I. Test the Replication一、测试复制
SUCCESS IS SWEET!成功是甜蜜的! 🤓
🤓
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.