腾讯云安装mysql,并配置主从
yum install mysql
yum install mysql-server
sudo yum list installed | grep mysql-server
service mysqld start
service mysqld stop
yum install mysql-devel
mysqld --initialize
systemctl start mysqld
systemctl enable mysqld
sudo mysql_secure_installation
vim /etc/my.cnf.d/mysql-server.cnf
vim mysql-server.cnf ////////////////////////////////////////////////////////////////////// 主
default_storage_engine=innodb
innodb_buffer_pool_size=10G
max_connections=1000
innodb_buffer_pool_instances=8
default_authentication_plugin=mysql_native_password
replicate-ignore-db = mysql
binlog-ignore-db=mysql
server-id=111
log_bin=mysql-bin
binlog_format=row
gtid_mode=ON
从
default_storage_engine=innodb
innodb_buffer_pool_size=10G
max_connections=1000
innodb_buffer_pool_instances=8
default_authentication_plugin=mysql_native_password
replicate-ignore-db = mysql
binlog-ignore-db=mysql
server-id=222
relay-log = relay-bin
binlog_format=row
gtid_mode=ON
//////////////////////////////////////////////////////////////////
service mysqld start
mysql -u root -p
主
CREATE USER 'replicator'@'%' IDENTIFIED BY 'your_password';
GRANT REPLICATION SLAVE ON . TO 'replicator'@'%';
FLUSH PRIVILEGES;
SHOW MASTER STATUS;
获取信息保存
从your_master_log_file,your_master_log_pos主的值
CHANGE MASTER TO
MASTER_HOST='master_ip',
MASTER_USER='replicator',
MASTER_PASSWORD='your_password',
MASTER_LOG_FILE='your_master_log_file',
MASTER_LOG_POS=your_master_log_pos;
START SLAVE;
SET GLOBAL sql_slave_skip_counter = 1;
START SLAVE;
SHOW SLAVE STATUS\G;
Slave_IO_Running和Slave_SQL_Running两个字段,它们都应该是Yes