Gtid Primary Master
====================configured as follows====================[Client]port=3306Socket=/tmp/My3306.sock[mysql]no-auto-Rehash[mysqld]user=Mysqlport=3306bind_address= *Socket=/tmp/My3306.sockcharacter_set_server=Utf8log-error =/home/mysql/3306/logs/My3306_error.logpid-file=/home/mysql/3306/logs/My3306.pidhomedir=/home/mysql/3306/Databasedir=/opt/MySQLdefault-storage-engine=InnoDB #MyISAMopen_files_limit=10240autocommit=1Sql_mode="Strict_trans_tables,no_engine_substitution,no_zero_date,no_zero_in_date,error_for_division_by_zero,no_auto _create_user"Secure_file_priv="'Lower_case_table_names=1Skip-Grantskip-name-resolve =on# Description: The main library must be configured with the parameters #server-id(master-slave server-id must be different), Log_bin, log-slave- updates, Gtid_mode, enforce_gtid_consistencyserver -id=1921685533gtid_mode=On #开启gtid模式enforce_gtid_consistency =On #强制gtid一致性, log is not supported for a specific CREATE table after opening-slave-updates=1#slave Whether the update is logged in Skip_slave_start=1#复制进程就不会随着数据库的启动而启动 (you want to start commenting out with the database)relay -log =/home/mysql/3306/binlog/ relayrelay_log_purge=onlog -bin =/home/mysql/3306/binlog/ binlogbinlog_cache_size=32mbinlog_format=ROW #MIXEDbinlog_row_image=fullmax_binlog_cache_size=2048mmax_binlog_size=512mexpire_logs_days= -key_buffer_size=1024mmax_allowed_packet=1024mtable_open_cache=1024x768sort_buffer_size=8mread_buffer_size=8mread_rnd_buffer_size=8mjoin_buffer_size=8mmyisam_sort_buffer_size=128mthread_cache_size= -query_cache_size=128mthread_concurrency=8Interactive_timeout=1800Wait_timeout=1800max_connections= +max_user_connections= +max_connect_errors=6000Back_log= -Long_query_time=3Slow_query_log=1Slow_query_log_file=/home/mysql/3306/logs/my3306-slow-query.logskip_external_locking=1innodb_file_per_table=oninnodb_buffer_pool_size=2048M innodb_thread_concurrency=8Innodb_flush_log_at_trx_commit=1Note: Except for server_id, the others are the same. parameters that the main library must configure : Server-id (master and slave Server-id must be different), Log_bin, log-slave-updates, Gtid_mode, enforce_gtid_consistency parameters that must be configured from the Library : dual-Master read-only is a server that does not need to be configured-id, Log_bin, Relay-log, Read-only, log-slave-Updates===============================================1. Start the database2. Create a Sync account grant replication slave on*. * To'slave'@'%'Identified by'123123';3. Back up the database (-a back up all libraries, the backup file will contain a statement that requires attentionSet@ @global. gtid_purged="a57a3eb0-5d40-11e6-9609-080027f7e774:1-3") mysqldump-uroot--default-character-Set=utf8-p-R--opt--triggers--hex-blob--single-transaction-a-s/tmp/my31306.sock >/tmp/Back.sql4. Another recovery database MySQL-uroot--default-character-Set=utf8-p </data/Tmp.sql (Specify character set recovery) the following actions are required for both units. 5. Stop slavestop Slave;6. Synchronize change to Operation () change Master to Master_host="192.168.1.100", master_port=3306, master_user='Repl', Master_password='Repl4slave', master_auto_position=1; #参数解释: master_host: Set the IP address of the primary server to be connected Master_user: Set the user name of the primary server to connect to Master_port: Set the port Master_password of the primary server to which you want to connect: Set the password Master_auto_position:gtid mode for the primary server to be connected, copy based on transaction ID7. Start Slavestart slave8. View Slave status (Slave_io_running:yes and Slave_sql_running:yes) show Slave status\g;
Slave common Commands
Show Master status;show slave status\g;stop Slave;start slave;
MySQL Gtid replication