准备工作
因为MyCAT 2基于JDK 1.8开发。也需要在虚拟机中安装JDK(JDK官网就能下载,我这提供一个捷径)
jdk-8u401-linux-x64.rpmhttps://pan.baidu.com/s/1ywcDsxYOmfZONpmH9oDjfw?pwd=rhel下载对应的tar安装包,以及对应的jar包
安装程序包: http://dl.mycat.org.cn/2.0/install-template/mycat2-install-template-1.21.zip
Jar包:http://dl.mycat.org.cn/2.0/1.21-release/mycat2-1.21-release-jar-with-dependencies.jar
有能力的翻墙,偷懒的点链接就行
下载包和JDKhttps://pan.baidu.com/s/1SPIc5ZLF-6FYaZfGoyzXcQ?pwd=rhel
准备工作完毕就可以着手安装了
安装步骤
把下载好的MyCAT压缩包解压到/usr/local目录
[root@MyCAT ~]# unzip mycat2-install-template-1.21.zip -d /usr/local/
把所需的jar复制(也可以移动)到mycat/lib目录
[root@MyCAT ~]# mv mycat2-1.21-release-jar-with-dependencies.jar /usr/local/mycat/lib/
安装JDK
[root@MyCAT ~]# yum install jdk-8u401-linux-x64.rpm -y
修改文件夹及以下文件的权限
##/usr/local/mycat/bin 目录下都是命令或者可执行文件,所以要添加执行权限
[root@MyCAT bin]# chmod +x *
启动MySQL
因为mycat代理启动时需要一个默认的数据源,所以我们在启动时为其准备一个数据源。
openEuler自带mysql-server直接yum install安装就行
[root@MyCAT bin]# yum install -y mysql-server
[root@MyCAT bin]# systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@MyCAT bin]# mysqladmin -uroot password 'root'
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
配置物理库地址
[root@MyCAT bin]# vim /usr/local/mycat/conf/datasources/prototypeDs.datasource.json
{"dbType":"mysql","idleTimeout":60000,"initSqls":[],"initSqlsGetConnection":true,"instanceType":"READ_WRITE","maxCon":1000,"maxConnectTimeout":3000,"maxRetryCount":5,"minCon":1,"name":"prototypeDs","password":"root","type":"JDBC","url":"jdbc:mysql://localhost:3306/mysql?useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=UTF-8","user":"root", #这个和上面的password需要留意,你用上什么登录就填什么。要不会报错"weight":0
}
启动
[root@MyCAT bin]# ./mycat start
Starting mycat2...
[root@MyCAT bin]# ./mycat status
mycat2 is running (2675).
[root@MyCAT bin]# tail /usr/local/mycat/logs/wrapper.log
查看日志启动成功
测试
在本地使用MyCAT初始用户登录测试
登录成功,环境正常