1.设置主从从mysql57服务器
(1)配置主数据库
[root@msater_5 ~]# systemctl stop [root@msater_5 ~]# setenforce 0
[root@msater_5 ~]# systemctl disable Removed symlink /etc/systemd/system/multi-user.target.wants/# ls
anaconda-ks.cfg mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
[root@msater_5 ~]# tar -xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
[root@msater_5 ~]# ls
anaconda-ks.cfg mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
mysql-5.7.44-linux-glibc2.12-x86_64
[root@msater_5 ~]# cp -r mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql
[root@msater_5 ~]# rm -rf /etc/my.cnf
[root@msater_5 ~]# mkdir /usr/local/mysql/mysql-[root@msater_5 ~]# useradd -r -s /sbin/nologin mysql
[root@msater_5 ~]# chown mysql:mysql /usr/local/mysql/mysql-[root@msater_5 ~]# chown 750 /usr/local/mysql/mysql-[root@msater_5 ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql
2024-08-21T09:39:14.991434Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -
-explicit_defaults_for_timestamp server option (see documentation for more details).
2024-08-21T09:39:15.126969Z 0 [Warning] InnoDB: New log LSN=45790
2024-08-21T09:39:15.150963Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-08-21T09:39:15.214887Z 0 [Warning] No existing UUID has been found, so we assume that this is the
2024-08-21T09:39:15.215926Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed'
cannot be opened.
2024-08-21T09:39:16.034519Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or
higher.
2024-08-21T09:39:16.034537Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or
higher.
2024-08-21T09:39:16.036321Z 0 [Warning] CA certi2024-08-21T09:39:16.384066Z 1 [Note] A temporary password is generated for root@localhost: RV3DtuxCi;A-
[root@msater_5 ~]# cp /usr/local/mysql/support-[root@msater_5 ~]# vim /usr/local/mysql/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3306
log-error=/usr/local/mysql/data/db01-master.err
log-bin=/usr/local/mysql/data/binlog
server-id=10
character_set_server=utf8mb4
(2)配置slave01数据库
(3)配置slave02数据库
(4)同步data
(5)修改slave01配置文件
(6)修改slave02配置文件
(7)主服务器锁表
(8)配置主从服务
(9)配置主从从服务
2.在mysql中添加eleme数据库并设置为utf8mb4
3.添加表t_user(master)
4.添加2行记录(master)
5.远程登录工具查看表数据
6.使用mycat为三台数据库设置负载均衡(读写分离)
(1)前期环境部署
(2)修改server.xml配置文件
[root@mycat ~]# vim /usr/local/mycat/conf/server.xml
(3)修改schema.xml配置文件
1.设置schema标签 添加dataNode="xxx" name=eleme
2.修改dataHost标签