This article focuses on interviews. In interviews, you only need to answer the key points. You do not need to have a very in-depth answer to the framework. If you want to cope with the interview, it is enough. Grasp the key points.
Interviewer: Tell us about the MySQL master-slave replication model ?
The configuration steps for MySQL master-slave replication are as follows:
-
Configure on the main server:
- Open the configuration file my.cnf of the main server, enable the binary log function, configure parameters
log-bin
, and set a unique log file name, such aslog-bin=mysql-bin
. - Configure a unique server ID, you can use any integer, such as
server-id=1
. - Restart the main server to make the configuration take effect.
- Open the configuration file my.cnf of the main server, enable the binary log function, configure parameters
-
Configure on the slave server:
- Open the configuration file my.cnf of the slave server and configure a unique server ID that is different from the master server, such as
server-id=2
. - Configure the information for the slave server to connect to the master server, including the master server's IP address, replication account and password, such as:
master-host = 主服务器IP地址 master-user = 复制账户 master-password = 复制账户密码 master-port = 主服务器端口(默认为3306)
- Restart the slave
- Open the configuration file my.cnf of the slave server and configure a unique server ID that is different from the master server, such as