MySQL双主(主主)架构方案(2)

mkdir -p /data/packages/src cd /data/packages/ wget http://distfiles.macports.org/cmake/cmake-3.2.3.tar.gz wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.34.tar.gz

1.4 创建mysql数据目录

mkdir -p /usr/local/mysql/data

1.5 解压编译安装cmake、MySQL

cd /data/packages/src tar -zxvf ../cmake-3.2.3.tar.gz cd cmake-3.2.3/ ./bootstrap gmake make install cd ../ tar xf mysql-5.6.34.tar.gz cd mysql-5.6.34 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc \ -DWITH_SSL=bundled -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/usr/local/mysql/data make && make install

1.6 添加开机启动脚本

cp support-files/mysql.server /etc/rc.d/init.d/mysqld

1.7 添加masterA配置文件/etc/my.cnf

[client] port = 3306 socket = /tmp/mysql.sock [mysqld] basedir = /usr/local/mysql port = 3306 socket = /tmp/mysql.sock datadir = /usr/local/mysql/data pid-file = /usr/local/mysql/data/mysql.pid log-error = /usr/local/mysql/data/mysql.err server-id = 1 auto_increment_offset = 1 auto_increment_increment = 2 #奇数ID log-bin = mysql-bin #打开二进制功能,MASTER主服务器必须打开此项 binlog-format=ROW binlog-row-image=minimal 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=0 sync_binlog=0 binlog-checksum=CRC32 master-verify-checksum=1 slave-sql-verify-checksum=1 binlog-rows-query-log_events=1 #expire_logs_days=5 max_binlog_size=1024M #binlog单文件最大值 replicate-ignore-db = mysql #忽略不同步主从的数据库 replicate-ignore-db = information_schema replicate-ignore-db = performance_schema replicate-ignore-db = test replicate-ignore-db = zabbix max_connections = 3000 max_connect_errors = 30 skip-character-set-client-handshake #忽略应用程序想要设置的其他字符集 init-connect='SET NAMES utf8' #连接时执行的SQL character-set-server=utf8 #服务端默认字符集 wait_timeout=1800 #请求的最大连接时间 interactive_timeout=1800 #和上一参数同时修改才会生效 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #sql模式 max_allowed_packet = 10M bulk_insert_buffer_size = 8M query_cache_type = 1 query_cache_size = 128M query_cache_limit = 4M key_buffer_size = 256M read_buffer_size = 16K skip-name-resolve slow_query_log=1 long_query_time = 6 slow_query_log_file=slow-query.log innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout [mysqldump] quick max_allowed_packet = 16M [mysqld_safe]

1.8 特别参数说明

log-slave-updates = true #将复制事件写入binlog,一台服务器既做主库又做从库此选项必须要开启

#masterA自增长ID auto_increment_offset = 1 auto_increment_increment = 2 #奇数ID

#masterB自增加ID auto_increment_offset = 2 auto_increment_increment = 2 #偶数ID

1.9 添加masterB配置文件/etc/my.cnf

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/132a89a801930aead12b3f77c3ca8f11.html