您的位置:首页 > 娱乐 > 八卦 > day33(mysql57主从从+mycat读写分离+java项目结合mycat数据库+lvs_dr轮询调用java项目)

day33(mysql57主从从+mycat读写分离+java项目结合mycat数据库+lvs_dr轮询调用java项目)

2024/12/31 1:27:10 来源:https://blog.csdn.net/weixin_68368034/article/details/141462079  浏览:    关键词:day33(mysql57主从从+mycat读写分离+java项目结合mycat数据库+lvs_dr轮询调用java项目)

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标签

(4)启动服务

7.客户端测试mycat

8.部署java17环境

(1)java01

(2)浏览器访问:192.168.2.12:8080

(3)java02

(4)浏览器访问:192.168.2.12:8080

9.部署LVS-nat模式

(1)lvs

(2) java01

(3) java02

(4)浏览器访问:192.168.2.150:8080(外网地址)

版权声明:

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

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