当前位置:Gxlcms > mysql > Mysql5.6主从

Mysql5.6主从

时间:2021-07-01 10:21:17 帮助过:5人阅读

yum -y install make gcc-c++ cmake bison-devel ?ncurses-devel configure.sh: cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/data/mysql \-DSYSCONFDIR=/etc \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-D

yum -y install make gcc-c++ cmake bison-devel ?ncurses-devel

configure.sh:

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

useradd mysql

mkdir -p /data/mysql

./mysql_install_db –basedir=/usr/local/mysql –datadir=/data/mysql/ –user=mysql

ln -s /usr/local/mysql/bin/* /usr/sbin/

主从

Master:

配置:

[mysqld]

log-bin=master-bin

log-bin-index=master-bin.index

innodb_file_per_table = 1

max_connections = 3000

socket=/var/lib/mysql/mysql.sock

log-bin=

binlog-format=ROW

log-slave-updates=true

gtid-mode=on

enforce-gtid-consistency=true

master-info-repository=TABLE

relay-log-info-repository=TABLE

sync-master-info=1

slave-parallel-workers=2

binlog-checksum=CRC32

master-verify-checksum=1

slave-sql-verify-checksum=1

binlog-rows-query-log_events=1

report-port=3306

port=3306

report-host=125.210.*.*

server_id = 1

slow-query-log-file =/data/mysql/query-slow.log

long_query_time=5

explicit_defaults_for_timestamp = true

SLAVE:

配置:

[mysqld]

log-bin=master-bin

log-bin-index=master-bin.index

innodb_file_per_table = 1

relay-log = relay-log

relay-log-index = relay-log.index

binlog-format=ROW

log-slave-updates=true

gtid-mode=on

enforce-gtid-consistency=true

master-info-repository=TABLE

relay-log-info-repository=TABLE

sync-master-info=1

slave-parallel-workers=2

binlog-checksum=CRC32

master-verify-checksum=1

slave-sql-verify-checksum=1

binlog-rows-query-log_events=1

report-port=3306

port=3306

report-host=125.210.136.132

server_id = 10

控制台启动同步

change master to master_host=’125.210.*.*’,master_user=’repl’,master_password=’repl_pass’,master_auto_position=1;

Query OK, 0 rows affected, 2 warnings (0.15 sec)

start slave;

人气教程排行