当前位置:网站首页>Build MySQL master-slave server under Ubuntu 14.04
Build MySQL master-slave server under Ubuntu 14.04
2022-07-01 14:49:00 【Brother Xing plays with the clouds】
MySQL The master-slave replication of is asynchronous , branch master/slave, stay master There is a IO Threads , And in the slave There is IO And Sql Threads .
The most important thing to build an environment is to mysql The binary log function of is enabled , I didn't pay attention to one detail in the process of building , It's been a long time .
Environmental Science :
My two virtual machines use bridge mode to access the Internet , Not recommended nat. First, set the fixed for the two virtual machines ip Address , And your physical machine ip Address in one segment , In this way, your virtual machine is very similar to the physical machine of a LAN .
Setting up ip Address :
$ sudo vim /etc/network/interfaces
as follows :
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.252
netmask 255.255.255.0
gateway 192.168.1.1
$ sudo /etc/init.d/networking restart
My virtual machine addresses are set to :192.168.1.251 192.168.1.252 gateway IP:192.168.1.1
After setting up , First, interact with each other in the virtual machine ping, It must be ensured that .
When the environment is ready , We can start , I didn't take rpm The way ,ubuntu Install directly online mysql It's very convenient , A lot of steps are saved .
$ sudo apt-get install mysql-server
By default, it automatically opens after installation , So use netstat -tap|grep mysql See if it's true mysql Services exist
Then check mysql Running state ,service mysql status, Again , There are other orders ,service mysql start/stop/restart.
If the following message appears , It means success .
mysql start/running, process 1199
Arrive first before landing /etc/mysql/my.cnf Next take bind-address Comment out , Because it can only be accessed locally by default .
land mysql
mysql -u root -p
grant replication slave,reload,super on *.* to slave @192.168.1.152 identified by '1234'
And then on the other Ubuntu Under the remote test
mysql -u slave -h 192.168.1.151 -p
The preliminary work is ready , Now start configuring :
stay master 192.168.1.251 Your machine is right my.cnf modify , Remember that the following configuration information must be added to 【mysqld】 Module , Placing it elsewhere in the file will cause master Configuration failed .
server-id=1
log_bin=/var/log/mysql/mysql-bin.log
binlog_do_db=student
binlog_ignore_db=mysql
Restart the mysql
sudo /etc/init.d/mysql restart
If during restart failed, It's suggested to take a look at my.cnf Of log-error Corresponding error log file location , then cat Look at the error message
After entering master Of mysql, First, check whether the binary function on.
show variables like 'log%'
If off It means that it is not turned on , Then return to check my.cnf file , Is it placed in the [mysqld] That piece is medium . Whether the file path is correct
show master status; Then you can see the corresponding file position Information , These are used when setting the slave .
The last to salve 192.168.1.252 Of /etc/mysql/my.cnf The configuration :
server-id=2
log_bin=/var/log/mysql/mysql-bin.log
replicate_do_db=student
Restart the mysql
sudo /etc/init.d/mysql restart
slave Get into mysql:
stop slave
Then set from master Copy log configuration
change master to master_host='192.168.1.151' ,master_user='slave',master_password='1234',
master_log_file='log.000004',master_log_pos=94;
log_file log_pos It is in master Next show master status What you see file position Information .
start slave;
show slave status\G
Find in the message that appears Slave_IO_Running/Slave_SQL_Running , All for YES It's a success .
If it does NO, Then check log-error Log files , It will be described clearly .
边栏推荐
- 关于重载运算符的再整理
- En utilisant le paquet npoi de net Core 6 c #, lisez Excel.. Image dans la cellule xlsx et stockée sur le serveur spécifié
- Opencv mat class
- Pat 1065 a+b and C (64bit) (20 points) (16 points)
- [zero basic IOT pwn] reproduce Netgear wnap320 rce
- [15. Interval consolidation]
- Pat 1121 damn single (25 points) set
- Leetcode (69) -- square root of X
- Research Report on the development trend and competitive strategy of the global diamond suspension industry
- Ubuntu 14.04下搭建MySQL主从服务器
猜你喜欢
![[leetcode 324] swing sorting II thinking + sorting](/img/cb/26d89e1a1f548b75a5ef9f29eebeee.png)
[leetcode 324] swing sorting II thinking + sorting

JVM第二话 -- JVM内存模型以及垃圾回收

Vnctf2022 open web gocalc0

2022-2-15 learning the imitation Niuke project - Section 3 post details

Today, with the popularity of micro services, how does service mesh exist?

JVM second conversation -- JVM memory model and garbage collection

Music player development example (can be set up)

How to view the state-owned enterprises have unloaded Microsoft office and switched to Kingsoft WPS?
![[dynamic programming] p1004 grid access (four-dimensional DP template question)](/img/3a/3b82a4d9dcc25a3c9bf26b6089022f.jpg)
[dynamic programming] p1004 grid access (four-dimensional DP template question)

【牛客网刷题系列 之 Verilog快速入门】~ 多功能数据处理器、求两个数的差值、使用generate…for语句简化代码、使用子模块实现三输入数的大小比较
随机推荐
Some thoughts on software testing
It's suitable for people who don't have eloquence. The benefits of joining the China Video partner program are really delicious. One video gets 3 benefits
问题随记 —— Oracle 11g 卸载
使用net core 6 c# 的 NPOI 包,讀取excel..xlsx單元格內的圖片,並存儲到指定服務器
C 语言基础
Day-02 database
如何看待国企纷纷卸载微软Office改用金山WPS?
NPDP能给产品经理带来什么价值?你都知道了吗?
Salesforce、约翰霍普金斯、哥大 | ProGen2: 探索蛋白语言模型的边界
[14. Interval sum (discretization)]
JVM performance tuning and practical basic theory part II
[leetcode 324] swing sorting II thinking + sorting
Basic operation of database
Opencv interpolation mode
Problem note - Oracle 11g uninstall
户外LED显示屏应该考虑哪些问题?
三十之前一定要明白的职场潜规则
Build your own website (14)
Rearrangement of overloaded operators
QT capture interface is displayed as picture or label