MySQL主从复制配置部署
配置前准备:安装MySQL
? MySQL在centOS上的安装传送门:https://www.cnblogs.com/zhqin/p/12239142.html
1、集群规划
hadoop105 hadoop106 hadoop107 MySQL(master) MySQL(slave)
2、修改hadoop106中MySQL的/usr/my.cnf配置文件。
[ ~]$ sudo vim /usr/my.cnf
[mysqld] #开启binlog log_bin = mysql-bin #binlog日志类型 binlog_format = row #MySQL服务器唯一id server_id = 1
3、重启hadoop106的MySQL服务
[ ~]$ sudo service mysql restart
4、在hadoop106进入mysql客户端,执行以下命令,查看master状态
mysql> show master status;
显示如下:
+------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 120 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
这样说明master状态已经是开启的。
5、配置hadoop107中MySQL的/usr/my.cnf配置文件。
[ ~]$ sudo vim /usr/my.cnf
[mysqld] #开启binlog log_bin = mysql-bin #binlog日志类型 binlog_format = row #MySQL服务器唯一id server_id = 2
6、重启hadoop107的MySQL服务
[ ~]$ sudo service mysql restart
7、进入hadoop107的mysql客户端
执行以下命令
mysql> CHANGE MASTER TO MASTER_HOST='hadoop106', MASTER_USER='root', MASTER_PASSWORD='123', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=120;
8、启动slave
mysql> start slave;
9、查看slave状态
mysql> show slave status\G;
10、配置完毕
测试:
在hadoop106的MySQL中创建个数据库,在hadoop107中看是否可以查询的到。
相关推荐
emmm00 2020-11-17
暗夜之城 2020-11-11
疯狂老司机 2020-09-08
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
CoderToy 2020-11-16
ribavnu 2020-11-16