In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The first technical article shared by the blog; the main construction of the project: the master database is built in a highly available cluster. The database is the master and standby of each other, and the application technology: MM+keepalived uses a virtual machine to build the experiment to show you: database 192.168.4.7 database 2:192.168.4.77VIP:192.168.4.68web1:192.168.4.69web2:192.168.4.70 one, install mysql, deploy the master and master synchronization structure. Direct yum installation and configuration master master synchronization: since data is stored in the main database 192.168.4.7, there are many ways to export data first. We take mysqldump:#mysqldump-uroot-p123456-- all-databases > / opt/all.sql and then need to copy the data to database 192.168.4.77. Database 2:1, Modify configuration file: database 192.168.4.7 [mysqld] server_id=7 # two hosts cannot repeat log-bin=master7 # enable binlog function log-bin-index=master7.indexdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockbinlog_format= "mixed" database 192.168.4.77 [mysqld] # vim/etc/ my.cnf [mysqld] log-bin=master77server_ Id=77binlog_format= "mixed" log_slave_updatesdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock:wq starts two databases in turn: systemctlstart mariadb2, Import database: import the database backed up from database 192.168.4.7 into database 192.168.4.77 In order to keep the data consistent on both sides, mysql-uroot-p123456
< all.sql3、配置用户授权并查看master信息:数据库192.168.4.7给用户授权:允许192.168.4.77的数据库用户slave拥有replication slave权限:mysql>Grant replication slave on *. * to slave@ "192.168.4.77" identified by "123456"; mysql > show master status; / / View status; Database 192.168.4.77 authorizes users: allow 192.168.4.7 database user slave to have replication slave permissions: mysql > grant replication slave on *. * to slave@ "192.168.4.7" identified by "123456"; mysql > show master status; / / View status 4. Configure each other as master and slave, and enable slave mode: database 192.168.4.7#mysql-uroot-p123456mysql > change master to master_host= "192.168.4.77", master_user= "slave", master_password= "123456", master_log_file= "master77.000001", master_log_pos=357 Mysql > start slave; / / launch slavemysql > show slave status\ G; / / View slave status database 192.168.4.77mysql > change master to master_host= "192.168.4.7", master_user= "slave", master_password= "123456", master_log_file= "master7.000001", master_log_pos=357 Mysql > start slave;mysql > show slave status\ G / / check that the slave status is yes is normal, otherwise the master master synchronization is abnormal, you need to further troubleshoot Slave_IO_Running: Yes Slave_SQL_Running: Yes master synchronization configuration, you can do some testing and testing of building database and table. Check whether the data on both sides are consistent. 2. Install keepalived and set up monitoring keepalived is installed on two MySQL servers. First, install keepalived and decompress it normally without explanation. 1. Modify the configuration file / etcswap keepalived.confessing configuration File for keepalivedglobal_defs {notification_email {acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc} notification_email_fromAlexandre.Cassen@firewall.loc smtp_server192.168.200.1 smtp_connect_timeout30 router_idLVS_DEVEL} vrrp_scriptcheck_mysql { Script "/ opt/mysql.sh" / / Monitoring the location of the script (finally, there is a reference script You can also write) interval 2 / / (detect the interval between script execution) weight 2} vrrp_instanceVI_1 {state MASTER / / change MASTER to BACKUP interface eth0 on the backup server Virtual_router_id 51 / / Master, The virtual_router_id of the standby must be the same priority 100 / / the master and standby must have different priorities. The host value is larger and the backup machine value is smaller Backup server is set to 99 advert_int 1 authentication {auth_type PASS auth_pass 1111 / / master, Standby like} track_script {check_mysql / / Detection script} virtual_ipaddress {192.168.4.68 / / VIP (virtual IP IP)}} Database 192.168.4.77 configuration file: VIMAGUPUP keepalived.confessing configuration File for keepalivedglobal_defs {notification_email {acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc} notification_email_fromAlexandre.Cassen@firewall.loc smtp_server192.168.200.1 smtp_connect_timeout30 router_idLVS_DEVEL} vrrp_scriptcheck_mysql {script "/ Opt/mysql.sh "interval 2 weight 2} vrrp_instanceVI_1 {state BACKUP interface eth0 virtual_router_id 51 priority 90 advert_int 1 authentication {auth_type PASS auth_pass 1111} track_script {check_mysql} virtual_ Ipaddress {192.168.4.68}} * the function of monitoring script is to switch between keepalived master and slave attached: monitor script vim/ Opt/ mysql.shallop eq binbinapash basha = `ps-C mysqld-- no-header | wc-l`if [$a-eq 0] Then systemctlstart mariadb sleep3b= `ps-C mysqld-- no-header | wc-l` if [$b-eq 0]; then killallkeepalived fifi
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.