当前位置:网站首页>Configure two databases in master-slave database mode (master and slave)
Configure two databases in master-slave database mode (master and slave)
2022-06-23 20:33:00 【kenvie】
subject
Use VMWare Create two centos7 The system's virtual machine , Install database services , The two databases are configured in the master-slave database mode (master and slave). When the configuration is complete , At the slave node , perform show status slave\G View the replication status of the slave node . Submit the returned result of viewing the service status from the node to the answer box in the form of text .( Database user name root, password 000000; All commands about the database use lowercase )
Node planning
IP | Host name | node |
|---|---|---|
192.168.200.11 | mysql1 | Master database |
192.168.200.12 | mysql2 | From database |
Get ready
Turn off the server firewall 、SELINUX
The network configuration
Host name | Pattern | IP |
|---|---|---|
mysql1 | Host only | 192.168.100.11 |
NAT | 192.168.200.11 | |
mysql2 | Host only | 192.168.100.12 |
NAT | 192.168.200.12 |
Configure host name
1、 Configure the first host name as mysql1
[[email protected] ~]# hostnamectl set-hostname mysql1 [[email protected] ~]# bash [[email protected] ~]#
2、 Configure the second host name as mysql2
[[email protected] ~]# hostnamectl set-hostname mysql2 [[email protected] ~]# bash [[email protected] ~]#
add to host
1、 To configure mysql1 Of host, Add the following to /etc/hosts
[[email protected] ~]# vi /etc/hosts 192.168.200.11 mysql1 192.168.200.12 mysql2
2、 Using remote replication will mysql1 Of hosts File replacement mysql2 Medium hosts file
[[email protected] ~]# scp /etc/hosts 192.168.200.12:/etc/hosts The authenticity of host '192.168.200.12 (192.168.200.12)' can't be established. ECDSA key fingerprint is 14:57:da:84:0b:98:67:83:88:d7:c4:62:bf:87:60:f6. Are you sure you want to continue connecting (yes/no)? #yes Warning: Permanently added '192.168.200.12' (ECDSA) to the list of known hosts. [email protected]'s password: # Input password hosts 100% 202 0.2KB/s 00:00
To configure yum Source (mysql1)
1、 Back up the original yum Source
[[email protected] ~]# mkdir /etc/yumback [[email protected] ~]# mv /etc/yum.repos.d/* /etc/yumback
2、 Mount the image
[[email protected] ~]# mkdir /opt/centos [[email protected] ~]# vi /etc/fstab # Add the following command to the last line /root/CentOS-7-x86_64-DVD-1511.iso /opt/centos/ iso9660 defaults,loop 0 0 # Don't restart yet , Run the following command to verify that the mount is successful [[email protected] ~]# mount -a
3、 To configure yum
[[email protected] ~]# vi /etc/yum.repos.d/local.repo [centos] name=centos baseurl=file:///opt/centos gpgcheck=0 enabled=1
4、 Clean cache , Build cache
[[email protected] ~]# yum clean all [[email protected] ~]# yum makecache
install FTP(mysql1)
Installation configuration ftp
[[email protected] ~]# yum install -y vsftpd [[email protected] ~]# vi /etc/vsftpd/vsftpd.conf # Add the following line in the last line anon_root=/opt [[email protected] ~]# systemctl start vsftpd [[email protected] ~]# systemctl enable vsftpd Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
To configure yum(mysql2)
1、 Back up the original yum Source
[[email protected] ~]# mkdir /opt/yumback [[email protected] ~]# mv /etc/yum.repos.d/* /opt/yumback
2、 To configure yum
[[email protected] ~]# vi /etc/yum.repos.d/ftp.repo [mysql1] name=mysql1 baseurl=ftp://192.168.100.11/centos gpgcheck=0 enabled=1
3、 Clean cache , Build cache
[[email protected] ~]# yum clean all [[email protected] ~]# yum makecache
Primary node installation mariadb
install mariadb And mariadb service
[[email protected] ~]# yum install mariadb mariadb-server -y [[email protected] ~]# systemctl start mariadb [[email protected] ~]# systemctl enable mariadb # Initialize database #!!!!!!!!! Be sure to start mariadb Service reinitialization !!!!!!!!! [[email protected] ~]# mysql_secure_installation
Install from node mariadb
install mariadb And mariadb service
[[email protected] ~]# yum install mariadb mariadb-server -y [[email protected] ~]# systemctl start mariadb [[email protected] ~]# systemctl enable mariadb # Initialize database #!!!!!!!!! Be sure to start mariadb Service reinitialization !!!!!!!!! [[email protected] ~]# mysql_secure_installation
Master node configuration database
1、 Modify the database configuration file
[[email protected] ~]# vi /etc/my.cnf # stay [mysqld] To add the following ( You don't need to add what you already have ): [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log_bin = mysql-bin # Open the log ( The host needs to be turned on ), This mysql-bin Customizable , You can also add paths binlog_ignore_db = mysql # Libraries that do not give slave synchronization ( Write multiple lines ) server_id = 11 [[email protected] ~]# systemctl restart mariadb
2、 to open up mysql1 Database permissions
[[email protected] ~]# mysql -uroot -p000000 MariaDB [(none)]> grant all privileges on *.* to [email protected]'%' identified by "000000"; MariaDB [(none)]> grant replication slave on *.* to 'user'@'mysql2' identified by '000000'; MariaDB [(none)]> exit
Configure the database from the node
1、 Modify the database configuration file
[[email protected] ~]# vi /etc/my.cnf stay [mysqld] To add the following ( You don't need to add what you already have ): [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log_bin = mysql-bin # Open the log ( The host needs to be turned on ), This mysql-bin Customizable , You can also add paths binlog_ignore_db = mysql # Libraries that do not give slave synchronization ( Write multiple lines ) server_id = 12 [[email protected] ~]# systemctl restart mariadb
2、 to open up mysql2 Database permissions
[[email protected] ~]# mysql -uroot -p000000 MariaDB [(none)]> change master to master_host='mysql1',master_user='user',master_password='000000'; MariaDB [(none)]> start slave; MariaDB [(none)]> show slave status\G;
Submission
MariaDB [(none)]> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: mysql1
Master_User: user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 529
Relay_Log_File: mariadb-relay-bin.000002
Relay_Log_Pos: 813
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 529
Relay_Log_Space: 1109
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 11
1 row in set (0.00 sec)边栏推荐
- Ugeek's theory 𞓜 application and design of observable hyperfusion storage system
- 20 provinces and cities announce the road map of the meta universe
- Deep learning of handlebar handwriting (15): building your own corpus on hugging face
- Hardware development notes (6): basic process of hardware development, making a USB to RS232 module (5): creating USB package library and associating principle graphic devices
- 深入理解和把握数字经济的基本特征
- Real topic of the 13th National Competition of single chip microcomputer in the Blue Bridge Cup
- 【Golang】快速复习指南QuickReview(一)——字符串string
- 墨天轮访谈 | IvorySQL王志斌—IvorySQL,一个基于PostgreSQL的兼容Oracle的开源数据库
- [golang] quick review guide quickreview (VIII) -- goroutine
- 【Golang】使用Go语言操作etcd——配置中心
猜你喜欢

Yaokui tower in Fengjie, Chongqing, after its completion, will be the safety tower for Sichuan river shipping with five local scholars in the company

八大误区,逐个击破(终篇):云难以扩展、定制性差,还会让管理员失去控制权?

I came from a major, so I didn't want to outsource

FPGA based electromagnetic ultrasonic pulse compression detection system paper + source file

35岁危机?内卷成程序员代名词了…

Use of the vs2022scanf function. An error is reported when using scanf - the return value is ignored: Solutions

Daily question brushing record (II)

「开源摘星计划」Containerd拉取Harbor中的私有镜像,云原生进阶必备技能

墨天轮访谈 | IvorySQL王志斌—IvorySQL,一个基于PostgreSQL的兼容Oracle的开源数据库

The "open source star picking program" container pulls private images from harbor, which is a necessary skill for cloud native advanced technology
随机推荐
How to install SSL certificates in Microsoft Exchange 2010
Making CSR file for face core
[golang] quick review guide quickreview (I) -- string
Deep learning of handlebar handwriting (15): building your own corpus on hugging face
Shell Scripting
同花顺网上开户安全吗,佣金高不高
测试的重要性及目的
[golang] type conversion summary
Use of the vs2022scanf function. An error is reported when using scanf - the return value is ignored: Solutions
Strokeit- the joy of one handed fishing you can't imagine
CPS 22 January additional incentive rules
SAP实施项目上的内部顾问与外部顾问,相互为难还是相互成就?
Teach you how to develop desktop applications with web pages
Want to open an account, is it safe to open an account on the stock Internet? Will the funds be cheated away?
How is the picture mosaic clear? What is mosaic for?
SQL聯合查詢(內聯、左聯、右聯、全聯)的語法
Rstudio 1.4 software installation package and installation tutorial
[vernacular technology] QR code
券商选哪个比较好尼?本人小白不懂,在线开户安全么?
[golang] quick review guide quickreview (IV) -- functions