网易cetus数据库中间件安装-读写分离版本

2018/11/19 14:05
阅读数 94
安装前提:1、数据库主从关系要做好;2、授权用户登录要做好;3、mysql最大连接数设置好,不然会报连接错误;4、版本最好是5.6以上。

1、安装依赖

yum install cmake gcc glib2-devel flex libevent-devel mysql-devel gperftools-libs -y

2、下载源码

cd /root/tools && git clone https://github.com/Lede-Inc/cetus.git

3、编译安装

   cd cetus/ && mkdir build/ && cd build/
   cmake ../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local/cetus -DSIMPLE_PARSER=ON && make install

4、配置文件

cd /usr/local/cetus/conf/ &&  cp -rp proxy.conf.example  proxy.conf &&cp users.json.example  users.json && chmod 660 conf/proxy.conf

vim users.json

{
	"users":	[{
			"user":	"用于登录mysql的账户",
			"client_pwd":	"用于登录mysql的密码",
			"server_pwd":	"用于登录mysql的密码"
		}]
}

vim proxy.conf

[cetus]
# For mode-switch
daemon = true

# Loaded Plugins
plugins=proxy,admin

# Defines the number of worker processes.
worker-processes=4

# Proxy Configuration, For example: MySQL master and salve host ip are both 192.0.0.1
proxy-address=10.10.1.133:3308
proxy-backend-addresses=主库ip:prot
proxy-read-only-backend-addresses=从库ip:port,从库ip:port

# Admin Configuration
admin-address=10.10.1.133:3309
admin-username=admin
admin-password=admin

# Backend Configuration, use test db and username created
default-db=bbc
default-username=center
default-pool-size=100
max-resp-size=10485760
long-query-time=100

# File and Log Configuration, put log in /data and marked by proxy port, /data/cetus needs to be created manually and has rw authority for cetus os user
max-open-files = 65536
pid-file = cetus6001.pid
plugin-dir=lib/cetus/plugins
log-file=/usr/local/cetus/logs/cetus_6001.log
log-level=debug

# Check salve delay
disable-threads=false
check-slave-delay=true
slave-delay-down=5
slave-delay-recover=1

# For trouble
keepalive=true
verbose-shutdown=true
log-backtrace-on-crash=true

5 主库创建心跳表

create database if not exists proxy_heart_beat; use proxy_heart_beat;
CREATE TABLE if not exists tb_heartbeat ( p_id varchar(128) NOT NULL , p_ts timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY (p_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

6、启动

/usr/local/cetus/bin/cetus --defaults-file=/usr/local/cetus/conf/proxy.conf ;tailf logs/cetus_6001.log
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部