部署mysql8_MySQL8 -- 安装部署

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz

xz -d mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz

tar -xvf mysql-8.0.20-linux-glibc2.12-x86_64.tar

mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql-8.0.20

groupadd mysql

useradd -d /home/mysql -g mysql -m mysql

echo "mysql@123" | passwd --stdin mysql

yum install -y libaio

mkdir -p mysql-8.0.20/{binlog,log,run,data}

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

sed -i '/^basedir=/cbasedir=\/data\/mysql-8.0.20' /etc/init.d/mysqld

sed -i '/^datadir=/cdatadir=\/data\/mysql-8.0.20\/data' /etc/init.d/mysqld

sed -i '/^mysqld_pid_file_path=/cmysqld_pid_file_path=\/data\/mysql-8.0.20\/run\/mysql.pid' /etc/init.d/mysqld

chown -R mysql:mysql /data/mysql-8.0.20

/data/mysql-8.0.20/bin/mysqld --initialize --user=mysql --basedir=/data/mysql-8.0.20 --datadir=/data/mysql-8.0.20/data

./bin/mysql -uroot -p

d:Lu)q9tK3/b

WgwOjkL!a2!F

uMCT_um>J3xz

alter user 'root'@'localhost' identified by 'Passwd12#$';

alter user 'root'@'localhost' identified WITH mysql_native_password by 'Passwd12#$';

flush privileges;

create user 'root'@'%' identified by 'Passwd12#$';

grant all privileges on *.* to 'root'@'%' with grant option;

alter user 'root'@'%' identified WITH mysql_native_password by 'Passwd12#$';

flush privileges;

create user 'reply'@'%' identified by 'reply123';

grant replication slave on *.* to 'reply'@'%';

alter user 'reply'@'%' identified WITH mysql_native_password by 'reply123';

flush privileges;

create user 'reply'@'172.26.%' identified by 'reply123';

grant replication slave on *.* to 'reply'@'172.26.%';

flush privileges;

echo -e "alias mysql='mysql -S /data/mysql-8.0.20/run/mysql.sock'" >> ~mysql/.bashrc

echo -e "export MYSQL_HOME=/data/mysql-8.0.20" >> ~mysql/.bashrc

echo -e "export PATH=\$MYSQL_HOME/bin:\$PATH" >> ~mysql/.bashrc

source ~mysql/.bashrc

双主配置:

登录195从库:

mysql> show master status;

+------------------+----------+--------------+------------------+-------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+------------------+----------+--------------+------------------+-------------------+

| mysql-bin.000004 | 1572 | | | |

+------------------+----------+--------------+------------------+-------------------+

1 row in set (0.00 sec)

登录224主库:

mysql> change master to master_host='172.26.170.195', master_port=31306, master_user='reply', master_password='reply123', master_log_file='mysql-bin.000011', master_log_pos=156, get_master_public_key=1;

mysql> start slave;

mysql> show slave status\G;

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

mysql> show master status;

+------------------+----------+--------------+------------------+-------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+------------------+----------+--------------+------------------+-------------------+

| mysql-bin.000007 | 1059 | | | |

+------------------+----------+--------------+------------------+-------------------+

1 row in set (0.00 sec)

登录195从库:

mysql> change master to master_host='172.26.98.224', master_port=31306, master_user='reply', master_password='reply123', master_log_file='mysql-bin.000007', master_log_pos=10312490, get_master_public_key=1;

mysql> start slave;

mysql> show slave status\G;

xtrabackup备份命令:

全量导出:

/mysql/percona-xtrabackup-8.0.12/bin/xtrabackup --user=root --password=Passwd12#$ --all-databases --backup --target-dir=/mysql/mysql_backup

导入:

xtrabackup --user=root --password=Passwd12#$ --datadir=/data/mysql-8.0.20/data/ --copy-back --target-dir=/data/mysql_backup

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值