cetus/doc/cetus-profile.md
2018-03-06 17:51:33 +08:00

144 lines
5.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 配置文件说明
配置文件包括用户配置文件users.json、变量处理配置文件variables.json、分库版本的分片规则配置文件sharding.json、读写分离版本的启动配置文件proxy.conf和分库版本的启动配置文件shard.conf具体说明如下
## 1.users.json
```
{
"users": [{
"user": "dbtest",
"client_pwd": "123456",
"server_pwd": "123456"
}, {
"user": "root",
"client_pwd": "123",
"server_pwd": "123456"
}]
}
```
其中user是用户名client_pwd是前端登录Cetus的密码server_pwd是Cetus登录后端的密码。
## 2.variables.json
Cetus支持部分会话级系统变量的设置可以通过配置允许发送的值和静默处理的值如下
```
{
"variables": [
{
"name": "sql_mode",
"type": "string-csv",
"allowed_values":
["STRICT_TRANS_TABLES",
"NO_AUTO_CREATE_USER",
"NO_ENGINE_SUBSTITUTION"
]
},
{
"name": "connect_timeout",
"type": "string",
"allowed_values": ["*"],
"silent_values": ["10", "100"]
}
]
}
```
其中name是变量名称type是变量类型stringstring-csv逗号分隔的字符串值目前尚未支持int类型allowed_values是指定允许设定的值可以使用通配符\*表示此变量设任意值都允许silent_values是指定静默处理的值可以使用通配符\*表示此变量设任意值都静默处理前提配置过allowed_values才能走到静默处理流程。
## 3.sharding.json
```
{
"vdb": [
{
"id": 1,
"type": "int",
"method": "hash",
"num": 8,
"partitions": {"data1": [0,1], "data2": [2,3], "data3": [4,5], "data4": [6,7]}
},
{
"id": 2,
"type": "int",
"method": "range",
"num": 0,
"partitions": {"data1": 124999, "data2": 249999, "data3": 374999,"data4": 499999}
}
],
"table": [
{"vdb": 1, "db": "employees_hash", "table": "dept_emp", "pkey": "emp_no"},
{"vdb": 1, "db": "employees_hash", "table": "employees", "pkey": "emp_no"},
{"vdb": 1, "db": "employees_hash", "table": "titles", "pkey": "emp_no"},
{"vdb": 2, "db": "employees_range", "table": "dept_emp", "pkey": "emp_no"},
{"vdb": 2, "db": "employees_range", "table": "employees", "pkey": "emp_no"},
{"vdb": 2, "db": "employees_range", "table": "titles", "pkey": "emp_no"}
],
"single_tables": [
{"table": "regioncode", "db": "employees_hash", "group": "data1"},
{"table": "countries", "db": "employees_range", "group": "data2"}
]
}
```
其中vdb是逻辑db包含属性有id、type、method、num和partitionsid是逻辑db的idtype是分片键的类型method是分片方式num是hash分片的底数range分片的num为0partitions是分组名和分片范围的键值对table是分片表包含属性有vdb、db、table和pkeyvdb是逻辑db的iddb是物理db名table是分片表名pkey是分片键single_tables是未分片表包含属性有table、db和grouptable是表名db是物理db名group是分组名。
## 4.proxy.conf
```
[cetus]
# Loaded Plugins
plugins=proxy,admin
# Proxy Configuration
proxy-address=proxy-ip:proxy-port
proxy-backend-addresses=rw-ip:rw-port
proxy-read-only-backend-addresses=ro-ip:ro-port
# Admin Configuration
admin-address=admin-ip:admin-port
admin-username=admin
admin-password=admin
# Backend Configuration
default-db=test
default-username=dbtest
# File and Log Configuration
log-file=cetus.log
log-level=debug
```
其中plugins是加载插件的名称读写分离版本需加载的插件为proxy和adminproxy-address是Proxy监听的IP和端口proxy-backend-addresses是读写后端(主库)的IP和端口可多项proxy-read-only-backend-addresses是只读后端(从库)的IP和端口可多项admin-address是管理模块的IP和端口admin-username是管理模块的用户名admin-password是管理模块的密码明文default-db是默认数据库当连接未指定db时使用的默认数据库名称default-username是默认用户名在Proxy启动时自动创建连接使用的用户名log-file是日志文件路径log-level是日志记录级别可选 info | message | warning | error | critical(default);其他可选性能配置详见[Cetus 启动配置选项说明](https://github.com/Lede-Inc/cetus/blob/master/doc/cetus-configuration.md)。
## 5.shard.conf
```
[cetus]
# Loaded Plugins
plugins=shard,admin
# Proxy Configuration
proxy-address=proxy-ip:proxy-port
proxy-backend-addresses=ip1:port1@data1,ip2:port2@data2,ip3:port3@data3,ip4:port4@data4
# Admin Configuration
admin-address=admin-ip:admin-port
admin-username=admin
admin-password=admin
# Backend Configuration
default-db=test
default-username=dbtest
# Log Configuration
log-file=cetus.log
log-level=debug
```
其中其中plugins是加载插件的名称分库sharding版本需加载的插件为shard和adminproxy-address是Proxy监听的IP和端口proxy-backend-addresses是后端的IP和端口需要同时指定group@group其他选项与proxy.conf含义相同其他可选性能配置详见[Cetus 启动配置选项说明](https://github.com/Lede-Inc/cetus/blob/master/doc/cetus-configuration.md)。
**注:以上配置文件中.json文件名称不可变.conf文件可自定义名称并利用命令行加载**