基于Predixy和LB构建高可用Redis-cluster(3)predixy安装篇

/ Linux服务安装搭建 / 没有评论 / 511浏览

Download source code

下载源码,predixy 编译安装需要 C++11 版本的编译器,至少需要 CentOS 7及以上版本才能编译安装。对于 CentOS 6或更低版本,可以直接使用在 github release 中的二进制版本。

$ git clone https://github.com/joyieldInc/predixy.git
$ make -j `grep 'processor' /proc/cpuinfo | wc -l`

配置文件介绍

[root@ELK-proxy-0-253 predixy]# tree -L 2
.
├── conf
│   ├── auth.conf
│   ├── cluster.conf      #cluster模式下的示例文件
│   ├── command.conf
│   ├── dc.conf           # datacenter 示例文件
│   ├── latency.conf      # 监控配置示例文件,如有需要可以include
│   ├── predixy.conf      # 主配置文件,可以include其他文件
│   ├── sentinel.conf     # 哨兵模式下的示例文件,不过官网5.0版本上的Cluster超级抗造,基本没人用这个了
│   ├── standalone.conf   # 单实例配置示例文件,由predixy.conf去include
│   └── try.conf  # 默认include的redis实例文件,如果本地没有redis的实例的话,记得在主配置文件去注释,否则会报错
├── _config.yml
├── doc
│   ├── bench
│   ├── config_CN.md      # 核心配置文件中文版
│   ├── Config-description-for-Redis-cluster.md
│   └── wechat-cppfan.jpeg
├── LICENSE
├── Makefile
├── README_CN.md
├── README.md
├── src
│   ├── predixy         # 二进制文件
│   ├── AcceptConnection.h
│   ├── AcceptConnection.o
│   ├── AcceptSocket.cpp
│   ├── AcceptSocket.h
·············

移动目录

$ cp -rf ./predixy  /usr/local/predixy 

生产配置参数

我只用了这三个 predixy.conf cluster.conf latency.conf

predixy.conf

[root@ELK-proxy-0-253 conf]# cat predixy.conf |grep -v ^#|grep -v ^$
Name PredixyExample
Bind 0.0.0.0:7617
WorkerThreads 1
ClientTimeout 300
LogVerbSample 0
LogDebugSample 0
LogInfoSample 10000
LogNoticeSample 1
LogWarnSample 1
LogErrorSample 1
Include cluster.conf
Include latency.conf

latency.conf

因为不想开那么多机器,我这里实际只有2台,192.168.0.253单机跑了5个实例

[root@ELK-proxy-0-253 conf]# cat cluster.conf |grep -v ^#|grep -v ^$
ClusterServerPool {
    MasterReadPriority 60
    StaticSlaveReadPriority 50
    DynamicSlaveReadPriority 50
    RefreshInterval 1
    ServerTimeout 1
    ServerFailureLimit 10
    ServerRetryTimeout 1
    KeepAlive 120
    Servers {
        + 192.168.0.204:6379
        + 192.168.0.253:6379
        + 192.168.0.253:6380
        + 192.168.0.253:6381
        + 192.168.0.253:6382
        + 192.168.0.253:6383
    }
}

supervisor 守护进程配置文件

[program:predixy]
command = /usr/local/predixy/src/predixy /usr/local/predixy/conf/predixy.conf
user=fcloud
numprocs=1
stopsignal=TERM
startretries=0
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile = /opt/supervisord/var/log/predixy_stdout.log

启动正确的输出

supervisor> tail predixy
l.cpp:42 h 0 create server connection 192.168.0.253:6380 5
2020-01-14 05:28:49.691790 N ClusterServerPool.cpp:174 redis cluster create new group 4835a7c0de2f2a129957d86bf7d76ce887d7e089 192.168.0.204:6379@16379 master -
2020-01-14 05:28:49.691809 N ClusterServerPool.cpp:174 redis cluster create new group f1576ad4a8602b508fa9cea63e448eb3b4e53adc 192.168.0.253:6380@16380 myself,master -
2020-01-14 05:28:49.691822 N ClusterServerPool.cpp:174 redis cluster create new group c31d45ea31446086de3291071c1fa88654c60aac 192.168.0.253:6379@16379 master -
2020-01-14 05:28:51.695542 N Handler.cpp:454 h 0 create connection pool for server 192.168.0.204:6379
2020-01-14 05:28:51.695669 N ConnectConnectionPool.cpp:42 h 0 create server connection 192.168.0.204:6379 6
2020-01-14 05:28:53.700287 N Handler.cpp:454 h 0 create connection pool for server 192.168.0.253:6379
2020-01-14 05:28:53.700404 N ConnectConnectionPool.cpp:42 h 0 create server connection 192.168.0.253:6379 7
2020-01-14 05:28:57.709503 N Handler.cpp:454 h 0 create connection pool for server 192.168.0.253:6381
2020-01-14 05:28:57.709592 N ConnectConnectionPool.cpp:42 h 0 create server connection 192.168.0.253:6381 8
2020-01-14 05:28:58.711500 N Handler.cpp:454 h 0 create connection pool for server 192.168.0.253:6383
2020-01-14 05:28:58.711579 N ConnectConnectionPool.cpp:42 h 0 create server connection 192.168.0.253:6383 9
2020-01-14 05:29:01.718062 N Handler.cpp:454 h 0 create connection pool for server 192.168.0.253:6382
2020-01-14 05:29:01.718176 N ConnectConnectionPool.cpp:42 h 0 create server connection 192.168.0.253:6382 10

下一篇讲如何服务可用性压力测试

https://www.blog.lijinghua.club/article/predixy_redis_cluster_4