您的位置:首页 > 健康 > 养生 > 网版制作过程_网络服务器无响应改进措施或应对策略_赵阳竞价培训_口碑最好的it培训机构

网版制作过程_网络服务器无响应改进措施或应对策略_赵阳竞价培训_口碑最好的it培训机构

2024/12/23 13:59:42 来源:https://blog.csdn.net/qq_59671942/article/details/142705763  浏览:    关键词:网版制作过程_网络服务器无响应改进措施或应对策略_赵阳竞价培训_口碑最好的it培训机构
网版制作过程_网络服务器无响应改进措施或应对策略_赵阳竞价培训_口碑最好的it培训机构

一、机器准备

机器

主机名

ip地址

角色

软件

mic-master

192.168.252.148

主节点

mysql8.0.23 mysql-shell-8.0.23

mic-node1

192.168.252.142

node1

mysql8.0.23

mic-node2

192.168.252.145

node2

mysql8.0.23

关闭防火墙

systemctl stop firewalld
setenforce 0

二、环境准备

安装mysql8.0.23

官方地址:MySQL :: Begin Your Download

三台机器均安装

1.安装工具
yum -y install perl-JSON perl-Test-Simple
2.获取安装包
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-server-8.0.23-1.el7.x86_64.rpm
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-client-8.0.23-1.el7.x86_64.rpm
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-devel-8.0.23-1.el7.x86_64.rpm
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-common-8.0.23-1.el7.x86_64.rpm
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-libs-8.0.23-1.el7.x86_64.rpm 
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-libs-compat-8.0.23-1.el7.x86_64.rpm
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-embedded-compat-8.0.23-1.el7.x86_64.rpm
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-test-8.0.23-1.el7.x86_64.rpm
3.安装
rpm -ivh mysql-community-common-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.23-1.el7.x86_64.rpm
rpm -ivh mysql-community-test-8.0.23-1.el7.x86_64.rpm

修改配置文件

所有节点修改进行修改配置文件

添加配置的模版
server_id=[id]  #每一台的都不一样,要唯一
report_host=[当前服务器ip]
report_port=[mysql端口号]
loose-group_replication_ip_whitelist="[ip1],[ip2],[ip3]"

进行修改

vim /etc/my.cnf

192.168.252.148:

server-id=1
report_host=192.168.252.148
report_port=3306
loose-group_replication_ip_whitelist="192.168.252.148,192.168.252.142,192.168.252.145"

192.168.252.142:

server-id=2
report_host=192.168.252.142
report_port=3306
loose-group_replication_ip_whitelist="192.168.252.148,192.168.252.142,192.168.252.145"

192.168.252.145:

server-id=3
report_host=192.168.252.145
report_port=3306
loose-group_replication_ip_whitelist="192.168.252.148,192.168.252.142,192.168.252.145"

启动并修改密码

systemctl start mysqld

192.168.252.148:

cat /var/log/mysqld.log | grep "password"
mysqladmin -uroot -p'Cu)ghjzfK3_J' password @Syh2025659

192.168.252.142:

cat /var/log/mysqld.log | grep "password"
mysqladmin -uroot -p'*qywTIZHh8-j' password '@Syh2025659'

192.168.252.145:

cat /var/log/mysqld.log | grep "password"
mysqladmin -uroot -p'Z+Ly31m>Y#sy' password '@Syh2025659'

主服务器安装mysql-shell-8.0.23

下载链接:https://downloads.mysql.com/archives/get/p/43/file/mysql-shell-8.0.23-linux-glibc2.12-x86-64bit.tar.gz

wget https://downloads.mysql.com/archives/get/p/43/file/mysql-shell-8.0.23-linux-glibc2.12-x86-64bit.tar.gz
解压:
tar -xzf mysql-shell-8.0.23-linux-glibc2.12-x86-64bit.tar.gz -C /usr/local/
cd /usr/local	
mv mysql-shell-8.0.23-linux-glibc2.12-x86-64bi mysql-shell

三、终端操作

MySQL操作

创建用户并授权

三台机器均添加

1.创建用户
create user syh identified by '@Syh2025659';
2.授权给用户
GRANT BACKUP_ADMIN, CLONE_ADMIN, CREATE USER, EXECUTE, FILE, PERSIST_RO_VARIABLES_ADMIN, PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SELECT, SHUTDOWN, SUPER, SYSTEM_VARIABLES_ADMIN ON *.* TO 'syh'@'%' WITH GRANT OPTION;
GRANT DELETE, INSERT, UPDATE ON mysql.* TO 'syh'@'%' WITH GRANT OPTION;
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, LOCK TABLES, REFERENCES, SHOW VIEW, TRIGGER, UPDATE ON mysql_innodb_cluster_metadata.* TO 'syh'@'%' WITH GRANT OPTION;
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, LOCK TABLES, REFERENCES, SHOW VIEW, TRIGGER, UPDATE ON mysql_innodb_cluster_metadata_bkp.* TO 'syh'@'%' WITH GRANT OPTION;
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, INDEX, INSERT, LOCK TABLES, REFERENCES, SHOW VIEW, TRIGGER, UPDATE ON mysql_innodb_cluster_metadata_previous.* TO 'syh'@'%' WITH GRANT OPTION;
GRANT ALL ON *.* to 'syh'@'%';
GRANT ALL PRIVILEGES on *.* to 'syh'@'%' WITH GRANT OPTION;
3.刷新权限
FLUSH PRIVILEGES;

192.168.252.148:

192.168.252.142:

192.168.252.145:

MySQL-Shell操作

进入mysql-shell

/usr/local/mysql-shell/bin/mysqlsh   #启动

连接主库信息

\c syh@192.168.252.148:3306     

配置集群

dba.configureInstance('syh@192.168.252.148:3306');
dba.configureInstance('syh@192.168.252.142:3306');
dba.configureInstance('syh@192.168.252.145:3306');

创建一个集群

var cluster=dba.createCluster('mysqlcluster');

查看主机群状态

dba.getCluster().status();

添加两个从节点

var cluster=dba.getCluster();
cluster.addInstance('syh@192.168.252.142:3306');
cluster.addInstance('syh@192.168.252.145:3306');

查看节点

cluster.status();

清空集群

dba.dropMetadataSchema(); 清除所有集群

四、故障恢复

安装mysql-router

192.168.252.148:

wget https://downloads.mysql.com/archives/get/p/41/file/mysql-router-8.0.23-linux-glibc2.12-x86_64.tar.xz
tar xf mysql-router-8.0.23-linux-glibc2.12-x86_64.tar.xz -C /usr/local
cd /usr/local
mv mysql-router-8.0.23-linux-glibc2.12-x86_64 mysql-router

修改配置文件

首次启动

192.168.252.148:

cd /usr/local/mysql-router/bin
./mysqlrouter --bootstrap syh@192.168.252.148:3306 --user=root

修改配置文件

vim /usr/local/mysql-router/mysqlrouter.conf
#dynamic_state=/usr/local/mysql-router/bin/../var/lib/mysqlrouter/state.json
bootstrap_server_addresses=mysql://192.168.252.148:3306,mysql://192.168.252.142:3306,mysql://192.168.252.145:3306

启动

192.168.252.148:

cd /usr/local/mysql-router/bin
./mysqlrouter -c ../mysqlrouter.conf &
netstat -tnpl

停掉主库

192.168.252.148:

systemctl stop mysqld

操作mysql-shell

192.168.252.148:

/usr/local/mysql-shell/bin/mysqlsh
\c syh@192.168.252.145:3306
var cluster=dba.getCluster();
cluster.status();

192.168.252.148:

systemctl start mysqld

再次查看

恢复!

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com