master@localhost[(none)]> show variables like ‘server_id’;
±--------------±------+
| Variable_name | Value |
±--------------±------+
| server_id | 3406 |
±--------------±------+
#创建用于复制的账户
master@localhost[(none)]> grant replication slave,replication client on .
-> to repl@‘192.168.1.177’ identified by ‘repl’;
#初始化主库日志文件,生成环境慎用reset
master@localhost[(none)]> reset master;
Query OK, 0 rows affected (0.01 sec)
#查看主库的状态,日志初始化至000001,
master@localhost[(none)]> show master status,Position为120
±-------------------±---------±-------------±-----------------±------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
±-------------------±---------±-------------±-----------------±------------------+
| inst3406bin.000001 | 120 | | | |
±-------------------±---------±-------------±-----------------±------------------+
4、配置主从同步
#启动端口为3506的实例
[mysql@app ~]$ mysqld_safe --defaults-file=/data/inst3506/data3506/my3506.cnf &
[mysql@app ~]$ msyql -P3506
slave@localhost[(none)]> show variables like ‘server_id’;
±--------------±------+
| Variable_name | Value |
±--------------±------+
| server_id | 3506 |
±--------------±------+
1 row in set (0.00 sec)
#为从库添加指向主库的相关配置信息,该命令会生成及修改备库上的master.info及relay-log.info文件
slave@localhost[(none)]> CHANGE MASTER TO MASTER_HOST=‘192.168.1.177’,
-> MASTER_USER=‘repl’,
-> MASTER_PASSWORD=‘repl’,
-> MASTER_PORT=3406,
-> MASTER_LOG_FILE=‘inst3406bin.000001’,
-> MASTER_LOG_POS=0;
Query OK, 0 rows affected, 2 warnings (0.04 sec)
#出现了2个warnings,查看一下
slave@localhost[(none)]> show warnings \G
*************************** 1. row ***************************
Level: Note
Code: 1759
Message: Sending passwords in plain text without SSL/TLS is extremely insecure.
*************************** 2. row ***************************
Level: Note
Code: 1760
Message: Storing MySQL user name or password information in the master.info repository is not secure and is therefore not recommended.
Please see the MySQL Manual for more about this issue and possible alternatives.
2 rows in set (0.00 sec)
#此时查看从库的状态信息
slave@localhost[(none)]> show slave status \G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.177
Master_User: repl
Master_Port: 3406
Connect_Retry: 60
Master_Log_File: inst3406bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: inst3406bin.000001
Slave_IO_Running: No #IO线程没有运行
Slave_SQL_Running: No #SQL线程没有运行
…
Master_Info_File: /data/inst3506/data3506/master.info
slave@localhost[(none)]> start slave; #启动slave
Query OK, 0 rows affected (0.01 sec)
#含义如下
START SLAVE with no thread_type options starts both of the slave threads. The I/O thread reads
events from the master server and stores them in the relay log. The SQL thread reads events from the
relay log and executes them.
#再次查看slave的状态
robin@localhost[(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.177
Master_User: repl
Master_Port: 3406
Connect_Retry: 60
Master_Log_File: inst3406bin.000001
Read_Master_Log_Pos: 120
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 285
Relay_Master_Log_File: inst3406bin.000001
Slave_IO_Running: Yes #IO线程处于运行状态
Slave_SQL_Running: Yes #SQL线程处于运行状态
…
Exec_Master_Log_Pos: 120
Relay_Log_Space: 452
…
Master_Server_Id: 3406
Master_UUID: 32f53a0a-63ef-11e4-93d9-8c89a5d108ae
Master_Info_File: /data/inst3506/data3506/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it #重要的提示信息
#可以看到从库上的2个线程,一个是用于I/O线程,用于连接到主库请求主库发送binlog,一个是用于执行SQL的SQL线程。
slave@localhost[(none)]> show processlist\G
*************************** 1. row ***************************
Id: 4
User: system user
Host:
db: NULL
Command: Connect
Time: 510993
State: Waiting for master to send event
Info: NULL
*************************** 2. row ***************************
Id: 5
User: system user
Host:
db: NULL
Command: Connect
Time: 333943
State: Slave has read all relay log; waiting for the slave I/O thread to update it
Info: NULL
5、验证同步情况
#下面在主库上执行一些操作以检查从库的同步情况
master@localhost[(none)]> show variables like ‘server_id’;
±--------------±------+
| Variable_name | Value |
±--------------±------+
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数软件测试工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年软件测试全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上软件测试开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注软件测试)
一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
涵盖了95%以上软件测试开发知识点,真正体系化!**
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注软件测试)
[外链图片转存中…(img-AMZqPCwG-1712978262754)]
一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!