Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of building mysql5.6 master and slave?

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the method of building mysql5.6 master and slave". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

System: centos6.6

Master: 192.168.142.129 mysql-5.6.30.tar.gz

From: 192.168.142.130 192.168.142.131 mysql-5.6.30.tar.gz

First, the principle of mysql master-slave replication

(1) master records changes in the binary log (binary log)

(2) slave copies the binary log events of master to its relay log (relay log); the I / O thread of slave reads events from the binary log of master and writes to the relay log

(3) slave redoes the events in the relay log and changes the data that reflects itself. Slave's SQL thread reads events from the relay log and replays the events locally to make them consistent with the data in master.

The steps of mysql master-slave implementation:

1. Use the mysqldump command to back up the database

2. View the binary location points of the primary node

3. Create a backup user and authorize it (replication client.replication slave)

4. To modify the server-id from the server, it must be different from the server-id of the master mysql. Enable the relay date and close the binary date.

5. From the database, pour in the data, and use the authorized user to connect to the master mysql

6 、 start slave

SQL language is divided into the following categories: query language DQL, control language DCL, manipulation language DML, definition language DDL. Transaction control TCL.

DQL (Data QUERY Languages) statement: the database definition statement, which is used to query the query block composed of SELECT clause, FROM clause and WHERE clause, such as select-from-where-grouop by-having-order by-limit

DDL (Data Definition Languages) statement: the database definition statement, which is used to create tables, indexes, views, stored procedures, triggers and so on in the database. The commonly used statement keyword is CREATE,ALTER,DROP,TRUNCATE,COMMENT,RENAME. Add, delete and change the structure of the table

DML (Data Manipulation Language) statement: that is, data manipulation statement, used to query, add, update, delete, etc., commonly used statement keywords are: SELECT,INSERT,UPDATE,DELETE,MERGE,CALL,EXPLAIN PLAN,LOCK TABLE, including universal additions, deletions, modifications and queries. Add, delete and modify the data of the table

DCL (Data Control Language) statement: a data control statement that authorizes / revokes permissions on a database and its fields (DCL is short name of Data Control Language which includes commands such as GRANT and mostly concerned with rights, permissions and other controls of the database system.). The commonly used sentence keywords are: GRANT,REVOKE.

TCL (Transaction Control Language) statement: transaction control statement, used to control transactions, commonly used statement keywords are: COMMIT,ROLLBACK,SAVEPOINT,SET TRANSACTION.

2. Mysql compilation and installation #! / bin/bashyum-y install make gcc gcc-c++ openssl openssl-devel pcre-devel gd cmake ncurses ncurses-develid-u mysqlif [`echo $? `- ne 0]; thengroupadd mysqluseradd-M-g mysql-s / sbin/nologin mysqlfiif [!-d "/ usr/local/mysql"] Then mkdir-p / usr/local/mysqlfimkdir-p / data/mysqlchown-R mysql:mysql / data/mysqlcd / home/soft/ # Software storage directory tar zxvf mysql-5.6.30.tar.gzcd mysql-5.6.30cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DSYSCONFDIR=/etc-DMYSQL_DATADIR=/data/mysql/data-DINSTALL_MANDIR=/usr/share/man-DMYSQL_TCP_PORT=3306-DMYSQL_UNIX_ADDR=/ Tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DEXTRA_CHARSETS=all-DDEFAULT_COLLATION=utf8_general_ci-DWITH_READLINE=1-DWITH_SSL=system-DWITH_EMBEDDED_SERVER=1-DENABLED_LOCAL_INFILE=1-DWITH_INNOBASE_STORAGE_ENGINE=1make & & make installchown-R mysql:mysql .chmod + x scripts/mysql_install_db./scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/data/mysqlcp. / support-files/mysql.server / etc/rc.d/init.d/mysqldchmod 755 / Etc/init.d/mysqldchkconfig mysqld oncat > / etc/rc.d/init.d/mysqld

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report