-
Notifications
You must be signed in to change notification settings - Fork 505
QuickStart
- core 所有工程相关的底层依赖
- redis
- redis-core redis 相关核心依赖
- redis-console 管理控制台
console主要负责整个系统元信息的管理,比如cluster、shard、redis、keeper。并且提供系统监控、报警等功能。 - redis-keeper Keeper 相关
keeper主要实现redis数据复制协议,向redis master请求数据,并且将数据传播至slave,用于缓存redis复制日志以及rdb数据。
Keeper container是keeper的容器,一个Keeper Container内部可以放多个逻辑的keeper。 - redis-meta MetaServer 相关
meta server主要有两部分功能,一部分是和console交互,当console配置信息变化时,meta server调用keeper container以及keeper相关的接口,执行这部分变化。
第二部分是管理单机房内的所有 keeper、Redis的 状态,并对异常状态进行纠正。 - redis-integration-test 集成测试相关用例
- package 负责项目打包
- services 此目录主要放置各个公司依赖的服务实现,其它公司的用户可以实现相关接口,将服务替换为公司内部服务
- ctrip-service 携程相关的服务实现,比如配置、SSO 等
- local-service 默认实现,支持本地文件配置、数据源配置
- 清空本地 maven 仓库的 com 和 org 目录
- XPipe 所有携程相关的 maven 依赖放置在项目 mvn_repo 分支下
git checkout mvn_repo - 在 xpipe 目录下, 运行
sh install.sh
, 自动将非公共 maven 仓库的依赖装载在本地 maven 系统中
-
在导入项目后,可能会发生某些类无法找到的现象
import com.ctrip.xpipe.redis.core.entity.ClusterMeta;
import com.ctrip.xpipe.redis.core.entity.KeeperMeta;
import com.ctrip.xpipe.redis.core.entity.RedisMeta;
-
问题原因
这些类是mvn编译时自动生成的,需要先执行命令:mvn install -DskipTests
生成类所在目录:
redis/redis-core/target/generated-sources/dal-model
redis/redis-console/target/generated-sources/dal-jdbc
XPipe 依赖 CAT 作为其监控系统,如果没有部署 CAT,请在启动时加入参数:
-Dcat.client.enabled=false
执行命令:mvn install -DskipTests
[INFO] xpipe-parent ....................................... SUCCESS [3.394 s]
[INFO] core ............................................... SUCCESS [5.566 s]
[INFO] redis-parent ....................................... SUCCESS [0.316 s]
[INFO] redis-core ......................................... SUCCESS [4.630 s]
[INFO] redis-keeper ....................................... SUCCESS [2.585 s]
[INFO] redis-meta ......................................... SUCCESS [1.204 s]
[INFO] redis-console ...................................... SUCCESS [19.111 s]
[INFO] redis-integration-test ............................. SUCCESS [1.554 s]
XPipe 支持单机调试模式,可以在本地启动所有服务,模拟双机房,进行调试,不妨将两个机房命名为 jq
,oy
启动文件:com.ctrip.xpipe.redis.console.AppTest
对应测试 Case:startConsole8080
Console 配置了一个集群:cluster1,主机房在 jq
,包含两个分片:shard1, shard2
在分片 shard1 中:
- 在金桥机房有两个 Redis: 127.0.0.1:6379, 127.0.0.1:6479
- 在金桥机房有两个 Redis: 127.0.0.1:6579, 127.0.0.1:6679
- 在本地
jq
机房启动两个 Redis,分别监听在端口: 6379 6479,其中 6479 的 Redis 是 6379 的 Redis 的 slave,模拟主机房 - 在本地
oy
机房启动两个 Redis,分别监听在端口: 6579 6679,模拟备机房
启动文件:com.ctrip.xpipe.redis.meta.server.AppTest
对应测试 Case:
启动文件:com.ctrip.xpipe.redis.keeper.AppTest
对应测试 Case:
Redis 6379 会有两个 slave,端口在 6000 的代表 Keeper
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=127.0.0.1,port=6479,state=online,offset=9275,lag=0
slave1:ip=127.0.0.1,port=6000,state=online,offset=9214,lag=1
master_repl_offset:9275
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:9274
Keeper 6000 有两个 slave,6001 是在当前 jq
机房的 ackup Keeper,6100 是在 oy
机房的 Keeper
127.0.0.1:6000> info replication
# Replication
role:slave
keeperrole:keeper
state:ACTIVE
master_host:127.0.0.1
master_port:6379
master_link_status:up
slave_repl_offset:13103
slave_priority:0
connected_slaves:2
slave0:ip=127.0.0.1,port=6100,state=online,offset=13042,lag=0,remotePort=52591
slave1:ip=127.0.0.1,port=6001,state=online,offset=13103,lag=0,remotePort=52653
master_replid:28181f6e3b2a66d637fa480bd003c546ca0c3a50
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:13103
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_first_byte_offset:10613
master_repl_offset:13103
repl_backlog_size:2491
repl_backlog_histlen:2491
Keeper 6100 有三个 slave,6101 是在当前 oy
机房的 Backup keeper,6579 和 6679 对应备机房 Redis
127.0.0.1:6100> info replication
# Replication
role:slave
keeperrole:keeper
state:ACTIVE
master_host:127.0.0.1
master_port:6000
master_link_status:up
slave_repl_offset:16612
slave_priority:0
connected_slaves:3
slave0:ip=127.0.0.1,port=6679,state=online,offset=16612,lag=0,remotePort=52618
slave1:ip=127.0.0.1,port=6101,state=online,offset=16612,lag=0,remotePort=52613
slave2:ip=127.0.0.1,port=6579,state=online,offset=16612,lag=0,remotePort=52617
master_replid:28181f6e3b2a66d637fa480bd003c546ca0c3a50
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:16612
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_first_byte_offset:13803
master_repl_offset:16612
repl_backlog_size:2810
repl_backlog_histlen:2810
- 方式一:启动dockerhub上的镜像
/bin/bash -c "$(curl -sSL https://raw.githubusercontent.com/ctripcorp/x-pipe/master/redis/dockerPackage/start-xpipe-container.sh)"
启动后的容器分布
执行命令:docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c885945d8f3 ctripcorpxpipe/xpipe-keeper:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:7181->8080/tcp, :::7181->8080/tcp keeperoy2
0e0f78ae096d ctripcorpxpipe/xpipe-keeper:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:7080->8080/tcp, :::7080->8080/tcp keeperjq1
16c5fdd14a5e ctripcorpxpipe/xpipe-keeper:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:7081->8080/tcp, :::7081->8080/tcp keeperjq2
1915292f3a7f ctripcorpxpipe/xpipe-keeper:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:7180->8080/tcp, :::7180->8080/tcp keeperoy1
0c6cb6dfe51f ctripcorpxpipe/xpipe-meta:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:9748->8080/tcp, :::9748->8080/tcp metaoy
aa0d109c7aae ctripcorpxpipe/xpipe-meta:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:9747->8080/tcp, :::9747->8080/tcp metajq
6694f9eff0ad ctripcorpxpipe/xpipe-console:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp consoleoy
1e77491414a9 ctripcorpxpipe/xpipe-console:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:8079->8080/tcp, :::8079->8080/tcp consolejq
d180471bb010 redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:6679->6379/tcp, :::6679->6379/tcp redis-6679
d0e811ea5d3d zookeeper "/docker-entrypoint.…" 3 days ago Up 3 days 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, :::2181->2181/tcp, 8080/tcp zoo1
15062ab45feb ctripcorpxpipe/xpipe-proxy:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:19079->80/tcp, :::19079->80/tcp, 0.0.0.0:19442->443/tcp, :::19442->443/tcp, 0.0.0.0:8092->8080/tcp, :::8092->8080/tcp proxyjq
ba2b64f10700 redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis-6379
180a2255d038 redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:7579->6379/tcp, :::7579->6379/tcp redis-7579
ed38daf8e71e ctripcorpxpipe/xpipe-proxy:1.0 "docker-entrypoint.sh" 3 days ago Up 3 days 0.0.0.0:19081->80/tcp, :::19081->80/tcp, 0.0.0.0:19444->443/tcp, :::19444->443/tcp, 0.0.0.0:8091->8080/tcp, :::8091->8080/tcp proxyoy
4539be899dd3 redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:7379->6379/tcp, :::7379->6379/tcp redis-7379
58cfdf41284a redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:6579->6379/tcp, :::6579->6379/tcp redis-6579
41381b5bd3a9 zookeeper "/docker-entrypoint.…" 3 days ago Up 3 days 2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:2182->2181/tcp, :::2182->2181/tcp zoo2
4687df7ac486 redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:6479->6379/tcp, :::6479->6379/tcp redis-6479
dcf1b8079c1e redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:7479->6379/tcp, :::7479->6379/tcp redis-7479
a877a83287b4 redis:4.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:7679->6379/tcp, :::7679->6379/tcp redis-7679
d5f85ee0360e ctripcorpxpipe/xpipe-mysql:2.0 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
- 方式二:根据最新代码编译本地镜像再启动 1.下载代码
git clone https://github.com/ctripcorp/x-pipe.git
1.执行redis/dockerPackage目录下start-xpipe-container-local.sh脚本
`cd x-pipe/redis/dockerPackage`
`bash start-xpipe-container-local.sh console-proxy`
console-proxy为参数mode,代表启动的模式
- 默认: console+metaserver+keepercontainer
- console-checker:console+checker+metaserver+keepercontainer
- console-proxy: console+metaserver+keepercontainer+proxy
进入localhost:8079 查看redis集群的相关信息及使用xpipe的相关功能
docker-compose down
XPipe