MyCAT realizes the separation of reading and writing of MySQL (1)-MyCAT installation

MyCAT realizes the separation of reading and writing of MySQL (1)-MyCAT installation

Mycat is an open source distributed database system. It is a server that implements the MySQL protocol. Front-end users can regard it as a database proxy, which can be accessed with MySQL client tools and command lines. The back-end can use MySQL native protocol. Communicate with multiple MySQL servers, or use the JDBC protocol to communicate with most mainstream database servers. Its core function is table and database partitioning, that is, a large table is horizontally divided into N small tables, which are stored in the back-end MySQL server or other In the database.
The Mycat backend can support mainstream databases such as MySQL, SQL Server, Oracle, DB2, and PostgreSQL, as well as MongoDB, a new type of NoSQL storage. From the end user's point of view, no matter what kind of storage method, in Mycat, it is a traditional database table that supports standard SQL statements for database operations.

1. System environment

操作系统: CentOS Linux release 7.8.2003 (Core)
MyCat 节点 IP: 192.168.1.14  主机名: mycat
MySQL 版本: mysql-5.7.23
主节点 IP: 192.168.1.11   主机名: mysql11
从节点1 IP: 192.168.1.12   主机名: mysql12
从节点2 IP: 192.168.1.13   主机名: mysql13

2. Install JDK on MyCAT node

MyCAT is written and developed in JAVA language. JAVA runtime environment (JRE) needs to be installed before use. Since MyCAT uses some features in JDK7, it must be run on JDK7 or above.

1. Download the JDK package and unzip it

## 查看下载的压缩包
[root@localhost soft]# ll
总用量 181168
-rw-r--r--. 1 root root 185515842 8月   9 14:27 jdk-8u144-linux-x64.tar.gz
## 解压缩文件
[root@localhost soft]# tar zxf jdk-8u144-linux-x64.tar.gz 
## 查看解压缩后的文件夹
[root@localhost soft]# ll
总用量 181168
drwxr-xr-x. 8   10  143       255 7月  22 2017 jdk1.8.0_144
-rw-r--r--. 1 root root 185515842 8月   9 14:27 jdk-8u144-linux-x64.tar.gz
## 把解压缩后的 jdk 目录移动到 /usr/local 目录
[root@localhost soft]# mv ./jdk1.8.0_144 /usr/local
[root@localhost soft]# ll
总用量 181168
-rw-r--r--. 1 root root 185515842 8月   9 14:27 jdk-8u144-linux-x64.tar.gz
[root@localhost soft]# cd /usr/local/jdk1.8.0_144/
[root@localhost jdk1.8.0_144]# ll
总用量 25828
drwxr-xr-x. 2 10 143     4096 7月  22 2017 bin
-r--r--r--. 1 10 143     3244 7月  22 2017 COPYRIGHT
drwxr-xr-x. 4 10 143      122 7月  22 2017 db
drwxr-xr-x. 3 10 143      132 7月  22 2017 include
-rwxr-xr-x. 1 10 143  5097973 6月  27 2017 javafx-src.zip
drwxr-xr-x. 5 10 143      185 7月  22 2017 jre
drwxr-xr-x. 5 10 143      245 7月  22 2017 lib
-r--r--r--. 1 10 143       40 7月  22 2017 LICENSE
drwxr-xr-x. 4 10 143       47 7月  22 2017 man
-r--r--r--. 1 10 143      159 7月  22 2017 README.html
-rw-r--r--. 1 10 143      526 7月  22 2017 release
-rw-r--r--. 1 10 143 21111510 7月  22 2017 src.zip
-rwxr-xr-x. 1 10 143    63933 6月  27 2017 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r--. 1 10 143   145180 7月  22 2017 THIRDPARTYLICENSEREADME.txt
[root@localhost jdk1.8.0_144]# pwd
/usr/local/jdk1.8.0_144

2. Configure environment variables

[root@localhost jdk1.8.0_144]# vim /etc/profile
###  在 /etc/profile 文件结尾添加以下内容
export JAVA_HOME=/usr/local/jdk1.8.0_144
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/rt.jar
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

[root@localhost lib]# source /etc/profile

3. Test

[root@localhost soft]# javac
用法: javac <options> <source files>
其中, 可能的选项包括:
  -g                         生成所有调试信息
  -g:none                    不生成任何调试信息
  -g:{
    
    lines,vars,source}     只生成某些调试信息
  -nowarn                    不生成任何警告
  -verbose                   输出有关编译器正在执行的操作的消息
  -deprecation               输出使用已过时的 API 的源位置
  -classpath <路径>            指定查找用户类文件和注释处理程序的位置
  -cp <路径>                   指定查找用户类文件和注释处理程序的位置
  -sourcepath <路径>           指定查找输入源文件的位置
  -bootclasspath <路径>        覆盖引导类文件的位置
  -extdirs <目录>              覆盖所安装扩展的位置
  -endorseddirs <目录>         覆盖签名的标准路径的位置
  -proc:{
    
    none,only}          控制是否执行注释处理和/或编译。
  -processor <class1>[,<class2>,<class3>...] 要运行的注释处理程序的名称; 绕过默认的搜索进程
  -processorpath <路径>        指定查找注释处理程序的位置
  -parameters                生成元数据以用于方法参数的反射
  -d <目录>                    指定放置生成的类文件的位置
  -s <目录>                    指定放置生成的源文件的位置
  -h <目录>                    指定放置生成的本机标头文件的位置
  -implicit:{
    
    none,class}     指定是否为隐式引用文件生成类文件
  -encoding <编码>             指定源文件使用的字符编码
  -source <发行版>              提供与指定发行版的源兼容性
  -target <发行版>              生成特定 VM 版本的类文件
  -profile <配置文件>            请确保使用的 API 在指定的配置文件中可用
  -version                   版本信息
  -help                      输出标准选项的提要
  -A关键字[=]                  传递给注释处理程序的选项
  -X                         输出非标准选项的提要
  -J<标记>                     直接将 <标记> 传递给运行时系统
  -Werror                    出现警告时终止编译
  @<文件名>                     从文件读取选项和文件名

Three, install Mycat

1. Create a mycat user and set a password

[root@localhost soft]# useradd mycat
[root@localhost soft]# passwd mycat
更改用户 mycat 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。

2. Download the Mycat installation package and unzip it

## 解压缩 Mycat 安装包
[root@localhost soft]# tar zxf Mycat-server-1.4-release-20151019230038-linux.tar.gz 
## 查看解压缩后的文件
[root@localhost soft]# ll
总用量 189132
-rw-r--r--. 1 root root 185515842 8月   9 14:27 jdk-8u144-linux-x64.tar.gz
drwxr-xr-x. 7 root root        85 8月   9 14:44 mycat
-rw-r--r--. 1 root root   8152178 11月  3 2015 Mycat-server-1.4-release-20151019230038-linux.tar.gz
## 把 Mycat 移动到 /usr/local/ 目录
[root@localhost soft]# mv ./mycat /usr/local/
[root@localhost soft]# cd /usr/local/mycat
[root@localhost mycat]# ll
总用量 12
drwxr-xr-x. 2 root root  145 8月   9 14:44 bin
drwxrwxrwx. 2 root root    6 6月  17 2015 catlet
drwxrwxrwx. 2 root root 4096 8月   9 14:44 conf
drwxr-xr-x. 2 root root 4096 8月   9 14:44 lib
drwxrwxrwx. 2 root root    6 6月  17 2015 logs
-rwxrwxrwx. 1 root root  217 10月 19 2015 version.txt
[root@localhost mycat]# pwd
/usr/local/mycat

3. Modify the owner of the mycat directory to the mycat user

[root@localhost mycat]# chown -R mycat:mycat /usr/local/mycat
[root@localhost mycat]# ll
总用量 12
drwxr-xr-x. 2 mycat mycat  145 8月   9 14:44 bin
drwxrwxrwx. 2 mycat mycat    6 6月  17 2015 catlet
drwxrwxrwx. 2 mycat mycat 4096 8月   9 14:44 conf
drwxr-xr-x. 2 mycat mycat 4096 8月   9 14:44 lib
drwxrwxrwx. 2 mycat mycat    6 6月  17 2015 logs
-rwxrwxrwx. 1 mycat mycat  217 10月 19 2015 version.txt

4. Configure environment variables

[root@localhost mycat]# vim /etc/profile
###  在 /etc/profile 文件结尾添加以下内容

export MYCAT_HOME=/usr/local/mycat
export PATH=$PATH:$MYCAT_HOME/bin

[root@localhost mycat]# source /etc/profile

5. Test-successful installation

[root@localhost mycat]# mycat start
Starting Mycat-server...
[root@localhost mycat]# mycat stop
Stopping Mycat-server...
Stopped Mycat-server.

Guess you like

Origin blog.csdn.net/weixin_44377973/article/details/107894184