yum -y install libaio
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
cd /usr/local/soft/mysql/src
mkdir ../5.7.24_3306 &&tar -xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C ../5.7.24_3306 --strip-components 1
mkdir -p /usr/local/soft/mysql/5.7.24_3306/{run,data,logs,bin_log,sock,cert}
groupadd mysql &&useradd -r -g mysql -s /bin/false mysql
cd /usr/local/soft/mysql/5.7.24_3306/bin &&./mysqld --initialize
--explicit_defaults_for_timestamp
--user=mysql
--basedir=/usr/local/soft/mysql/5.7.24_3306
--datadir=/usr/local/soft/mysql/5.7.24_3306/data
--lc_messages_dir=/usr/local/soft/mysql/5.7.24_3306/share
--lc_messages=en_US
2018-12-01T09:56:45.934627Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-12-01T09:56:46.056837Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-12-01T09:56:46.127141Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 69d028f9-f54f-11e8-9c4a-00163e08e793.
2018-12-01T09:56:46.130249Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-12-01T09:56:46.131377Z 1 [Note] A temporary password is generated for root@localhost: sDdPx3>.,oBi
cd /usr/local/soft/mysql/5.7.24_3306/bin &&./mysql_ssl_rsa_setup --datadir=/usr/local/soft/mysql/5.7.24_3306/cert
修改证书权限为644
cd /usr/local/soft/mysql/5.7.24_3306/bin &&./mysql -uroot -S /usr/local/soft/mysql/5.7.24_3306/sock/mysql.sock
use mysql
update user set host = '%', authentication_string = password('123456') where user = 'root'
select host,user,authentication_string from user
flush privileges
grant all privileges on . to 'root'@'%'
flush privileges
cat >/etc/systemd/system/3306.service <<EOF
[Unit]
Description=MySQL 3306
Documentation= http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/soft/mysql/5.7.24_3306/run/mysql.pid
ExecStart=/usr/local/soft/mysql/5.7.24_3306/support-files/mysql.server start
ExecReload=/usr/local/soft/mysql/5.7.24_3306/support-files/mysql.server restart
ExecStop=/usr/local/soft/mysql/5.7.24_3306/support-files/mysql.server stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl enable 3306.service
1、
cd /usr/local/soft/mysql/5.7.24.3306/bin &&./mysqld_safe --skip-grant-tables &
cd /usr/local/soft/mysql/5.7.24.3306/bin &&./mysqld_safe --skip-grant-tables --skip-networking &
2、
./mysql -uroot -p -S /usr/local/soft/mysql/5.7.24.3306/sock/mysql.sock
3、
use mysql
update mysql.user set authentication_string=password('123456') where user='root'
flush privileges
mkdir -p /usr/local/soft/mysql/back/5.7.23_3306 &&cp -Rf /usr/local/soft/mysql/5.7.23_3306/* /usr/local/soft/mysql/back/5.7.23_3306
mkdir -p /usr/local/soft/mysql/back/5.7.24_3306 &&cp -Rf /usr/local/soft/mysql/5.7.24_3306/* /usr/local/soft/mysql/back/5.7.24_3306
CREATE USER 'sdyc'@'%' IDENTIFIED BY '123456'
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON sd_data.* TO 'sdyc'@'%'
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON card_data.* TO 'sdyc'@'%'
SHOW GRANTS FOR sdyc
CREATE USER 'back'@'localhost' IDENTIFIED BY '123456'
GRANT SELECT, RELOAD, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES, REPLICATION CLIENT ON . TO 'back'@'localhost'
SHOW GRANTS FOR back
REVOKE SELECT, INSERT, UPDATE, DELETE, EXECUTE ON sd_data.* FROM 'sdyc'@'%'
mysql 为什么设置了gtidserver_uuid是5.6的gtid特性引入的一个配置,把mysql5.7的rpl_slave.cc文件中get_master_uuid函数换成5.6对应的函数就可以了。
GTID 对于单源复制还是很方便,但是对于多源复制,这里就需要特别注意:
要先停止所有的从库 stop slave
然后清理本机所有的 GTID,reset master
再进行 SET @@GLOBAL.GTID_PURGED='xxxxx' gtid 设置
这里就会引入一个问题,如果是级联复制的情况下,reset master 的时候,会把本机的所有 binlog 清理掉。如果下一级的从库存在延迟,没有及时的把 binlog 传过去,就会造成主从中断,这里我们该怎么避免呢?看这里:做 reset master 的时候,先看看下游的从库是否存在很大的延迟。如果存在,把当前的 binlog 和后面未同步的 binlog 全部备份下;
待添加好从库的 channel 后,再把未同步的 binlog 文件手动拷贝到 binlog 目录;
更新下 mysql-bin.index 文件;
注意,binlog 不能同名,需要手动更新下文件。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)