Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

Java1234官方群25:java1234官方群25
Java1234官方群25:838462530
     

GIT视频教程(结合github,码云)免费领取

BAT一线大厂笔试面试打包下载

领取国内优秀就业,加薪,跳槽项目课程源码-vue2+jwt+springboot+mybaits前后端分离通讯录系统课程

SpringBoot打造企业级进销存

Java1234 VIP课程

领取微信扫码登录Java实现视频教程

Java1234至尊VIP(特价活动)

mycat实现mysql数据库读写分离 PDF 下载


分享到:
时间:2020-06-30 17:27来源:http://www.java1234.com 作者:小锋  侵权举报
mycat实现mysql数据库读写分离 PDF 下载
失效链接处理
mycat实现mysql数据库读写分离 PDF 下载

本站整理下载:
提取码:1pun 
 
 
相关截图:
 
主要内容:

机器A:(linux)mycat:192.168.100.222 机器B:(windows)mysql master:192.168.100.192 机器C:(windows)mysql slave:192.168.100.193 软件下载和安装 jdk1.8 在A机器安装jdk,步骤略过;jdk安装路径为/usr/local/java/jdk1.8.0_161 mysql5.7 在B、C机器上安装免安装版MySQL:mysql-5.7.18-winX64,部署的步骤就是按照网上说的: 1:创建txt改名为my.ini,文件内容: ############################################################## # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # 安装路径 basedir = D:\mysql-5.7.18-winx64 #数据文件存放路径 #datadir = D:\mysql-5.7.18-winx64\data #端口号 port = 3306 # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M #MySQL服务器端的存储引擎 #sql_mode = ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES #服务端编码 character-set-server = utf8 [client] #客户端编码 loose-default-character-set = utf8 [WinMySQLAdmin] D:\mysql-5.7.18-winx64\bin\mysqld.exe #################################################### 2.把my.ini复制到安装目录D:\mysql-5.7.18-winx64下; 3.管理员运行cmd,输入:mysqld -install,显示安装成功; 4.在cmd到\bin目录,然后输入mysqld --initialize --user=mysql --console 执行此命令, 生成库. 注意有个临时密码, 要记下来; 5.启动服务net start mysql; 6.进入mysql命令下:mysql -uroot -p,输入刚刚的密码; 7.再输入set password = password('root') 修改root的登录密码;---备注(B机器:admin/admin;root/root;C机器:root/root;) Mycat-server-1.6.7.4-release-20200105164103-linux.tar.gz 在A机器上安装mycat: 1.解压文件夹; 2.拷贝mycat/致/usr/local/目录下; 3.新建操作系统用户mycat并设置密码 adduser mycat; passwd mycat;--此处设置密码为mycat.2017 4.修改mycat及子文件权限,chown mycat:mycat -R mycat/ 配置文件修改
jdk及mycat环境变量配置 [[email protected] mycat]# vi /etc/profile 在末尾添加以下几行: export JAVA_HOME=/usr/local/java/jdk1.8.0_161 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export MyCAT_HOME=/usr/local/mycat/ export PATH=$PATH:$MyCAT_HOME/bin:$JAVA_HOME/bin mysql主从库配置 B机器(master) 1. 修改Master的配置 D:\mysql-5.7.18-winx64\my.ini(linux版# /etc/my.cnf),并重启mysql server-id=1 log_bin=mysql-bin #service mysqld restart #重启 2. 使用root或者admin用户登录mysql,查记录File与Position的值,此处的查询结果,将在下面Slave建立与Master联系时用到。 -> show master status; 3.在master上为slave建立用户 ->grant replication slave, reload, super on . to ‘admin’@‘192.168.100.193’ identified by ‘admin’; --------------------增加访问权限后期检验使用: ->GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION; ->GRANT ALL PRIVILEGES ON . TO ‘admin’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION; 需要立即生效: -> flush privileges; #systemctl restart mysqld 到此Master配置完毕! C机器(slave) 1. 修改Slave的配置D:\mysql-5.7.18-winx64\my.ini(linux版# /etc/my.cnf),并重启mysql server-id=2 log_bin=mysql-bin #service mysqld restart #重启 2.Slave建立与Master联系 使用root用户登录mysql并执行以下语句 mysql> change master to -> master_host=‘192.168.100.192’, -> master_port=3306, -> master_user=‘admin’, -> master_password=‘admin’, -> master_log_file=‘mysql-bin.00000X’, -> master_log_pos=XXX; 其中X、XXX代表在B机器上执行-> show master status;的结果 --------------------增加访问权限后期检验使用: ->GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root’ WITH GRANT OPTION; 3. 启动Slave #start slave; #启动 #stop slave; #关

 
 
------分隔线----------------------------
锋哥公众号


锋哥微信号


关注公众号
回复 666
获取 java
从菜鸡到大神
全套视频教程