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 ![](https://i-blog.csdnimg.cn/direct/b2fffd72bb2a495a95e63af90df092da.png) ### (3)修改schema.xml配置文件 1.设置schema标签 添加dataNode="xxx" name=eleme 2.修改dataHost标签 ![](https://i-blog.csdnimg.cn/direct/37d76dcebf0c4cefb05dcb2f60f4089a.png) ![](https://i-blog.csdnimg.cn/direct/312b2ccfa31246589b45d57643c6d2b4.png) ### (4)启动服务 ![](https://i-blog.csdnimg.cn/direct/c1089746e13940e19247a16d4de5fda9.png) ## 7.客户端测试mycat ![](https://i-blog.csdnimg.cn/direct/48d0fca4b55e4442a63c1f08627f0bb1.png) ![](https://i-blog.csdnimg.cn/direct/4d9fea54c0e84ee7a919e807a497c0fd.png) ![](https://i-blog.csdnimg.cn/direct/1bb06bf03a0741cc9bfebd9f08041da7.png) ## 8.部署java17环境 ### (1)java01 ![](https://i-blog.csdnimg.cn/direct/99a86571f5574150bc897051c6ae741c.png) ![](https://i-blog.csdnimg.cn/direct/18e4e0b7b40b4bcb992ef20e63c74d47.png) ![](https://i-blog.csdnimg.cn/direct/9483a653ba60471ea4d9188927e6bd8c.png) ### (2)浏览器访问:192.168.2.12:8080 ![](https://i-blog.csdnimg.cn/direct/29205e86bfbe4950b28e25275605f904.png) ![](https://i-blog.csdnimg.cn/direct/54cc12cca9474665a79b874be95789e1.png) ### (3)java02 ![](https://i-blog.csdnimg.cn/direct/117ffd4f2a414563b229e4cc18945f65.png) ![](https://i-blog.csdnimg.cn/direct/da4056d4cb20426b88c51bc931662ace.png) ### (4)浏览器访问:192.168.2.12:8080 ![](https://i-blog.csdnimg.cn/direct/82b1d378b49f40dd9532e31e4d9f994c.png) ![](https://i-blog.csdnimg.cn/direct/04c718a5b1c946439bf0cf7d115e7c82.png) ## 9.部署LVS-nat模式 ### (1)lvs ![](https://i-blog.csdnimg.cn/direct/251a93c4e0794fb2a657cbb5156b5cb5.png) ### (2) java01 ![](https://i-blog.csdnimg.cn/direct/b795bef57dd64831976a60306843433b.png) ### (3) java02 ![](https://i-blog.csdnimg.cn/direct/34a30898ccfb43859fda4faffb490a3f.png) ### (4)浏览器访问:192.168.2.150:8080(外网地址) ![](https://i-blog.csdnimg.cn/direct/fdf9fb848e6846e7b8a386c39777b1a3.png) ![](https://i-blog.csdnimg.cn/direct/9ed063dddf80408390a6bb32000dd59c.png)

相关推荐
沃夫上校4 分钟前
MySQL 中文拼音排序问题
java·mysql
要一起看日出4 分钟前
MVCC-多版本并发控制
数据库·mysql·mvcc
Hx__5 分钟前
MySQL InnoDB 的 MVCC 机制
数据库·mysql
速易达网络6 分钟前
ASP.NET MVC 连接 MySQL 数据库查询示例
数据库·asp.net·mvc
Dcs7 分钟前
用 Python UTCP 直调 HTTP、CLI、MCP……
java
玉衡子43 分钟前
MySQL基础架构全面解析
数据库·后端
快乐肚皮44 分钟前
fencing token机制
java·fencing token
梦中的天之酒壶1 小时前
Redis Stack扩展功能
数据库·redis·bootstrap
GreatSQL1 小时前
GreatSQL分页查询优化案例实战
数据库
叶落阁主1 小时前
Neovim 插件 i18n.nvim 介绍
java·vue.js·vim