安装codis 以及遇到的一些问题

redis集群安装用的是codis ,由豌豆荚开源,相比较twemproxy的好处有很多,参考http://blog.csdn.net/hunci/article/details/51799468

不废话,搞起

下面的安装文档抄袭了小炒肉的,连接如下

https://www.kissni.com/2017/04/06/codis-redis/

但是部署中也遇到了一些问题

1,在codis make 的时候出现错误

go build -i -o bin/codis-dashboard ./cmd/dashboard

go build github.com/CodisLabs/codis/vendor/github.com/ugorji/go/codec: /opt/local/go/pkg/tool/linux_amd64/compile: signal: killed

make: *** [codis-dashboard] 错误 1

原因:我用的vps,内存本来就很小只有500M,查看日志 /var/log/message

May 16 09:30:06 vultr kernel: Out of memory: Kill process 10020 (compile) score 460 or sacrifice child

May 16 09:30:06 vultr kernel: Killed process 10020, UID 0, (compile) total-vm:383560kB, anon-rss:371776kB, file-rss:120kB

是因为 应用服务在启动的时候,触发的linux系统内存的调用机制,为了保证系统正常运行oom 杀掉了编译进程

解决:两个方法,调节内核,不推荐,会玩挂的(大神请无视)

第二个方法,增加内存就好了

2,编译过程中报错

zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1

undefined reference to `dladdr‘

两个错误

解决:

其实两个错误都是没有制定正确的连接库的位置

编译的时候 加上两个参数就好了

make MALLOC=libc LDFLAGS+=-ldl

环境配置

安装 git

yum install -y git autoconf

安装 golang,(使用 1.5.x 版本)

wget https://storage.googleapis.com/golang/go1.5.4.linux-amd64.tar.gz
tar zxvf go1.5.4.linux-amd64.tar.gz
mkdir /opt/local
mv go /opt/local/

配置环境变量

vi /etc/profile

# 添加如下:

# golang ENV
export GOROOT=/opt/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/opt/local/codis# 立即生效

source /etc/profile

# 检查版本

go version
go version go1.5.4 linux/amd64

echo $GOPATH
/opt/local/codis

安装 Codis

下载 Codis 源码

mkdir -p $GOPATH/src/github.com/CodisLabs

cd $GOPATH/src/github.com/CodisLabs

git clone https://github.com/CodisLabs/codis.git -b release3.1

编译 Codis 源码

cd $GOPATH/src/github.com/CodisLabs/codismake
make -j -C extern/redis-3.2.4/

# 输入如下信息:

go build -i -o bin/codis-dashboard ./cmd/dashboard
go build -i -o bin/codis-proxy ./cmd/proxy
go build -i -o bin/codis-admin ./cmd/admin
go build -i -o bin/codis-ha ./cmd/ha
go build -i -o bin/codis-fe ./cmd/fe

# 查看 安装以后的版本

cat bin/version

version = 2017-03-08 14:07:13 +0800 @b1919d11593dfd1f47a2461837233dfc8fc78002 @3.1.5-26-gb1919d1
compile = 2017-04-05 18:13:46 +0800 by go version go1.5.4 linux/amd64

# 复制文件,方便管理

mkdir -p /opt/local/codis/{bin,logs,data}/

cp -rf $GOPATH/src/github.com/CodisLabs/codis/bin/* /opt/local/codis/bin

cp -rf $GOPATH/src/github.com/CodisLabs/codis/config /opt/local/codis/

配置 Codis

Codis Dashboard

cd /opt/local/codis/config/

vim dashboard.toml
# 修改配置文件

##################################################
#                                                #
#                  Codis-Dashboard               #
#                                                #
##################################################

# Set Coordinator, only accept "zookeeper" & "etcd" & "filesystem".
coordinator_name = "zookeeper"
coordinator_addr = "127.0.0.1:2181"

# Set Codis Product Name/Auth.
product_name = "codis-demo"
product_auth = ""

# Set bind address for admin(rpc), tcp only.
admin_addr = "0.0.0.0:18080"

# Set configs for redis sentinel.
sentinel_quorum = 2
sentinel_parallel_syncs = 1
sentinel_down_after = "30s"
sentinel_failover_timeout = "5m"
sentinel_notification_script = ""
sentinel_client_reconfig_script = ""
# 启动 Dashboard

nohup /opt/local/codis/bin/codis-dashboard --ncpu=4 --config=/opt/local/codis/config/dashboard.toml     --log=/opt/local/codis/logs/dashboard.log --log-level=WARN &

Codis Proxy

cd /opt/local/codis/config/

vim proxy.toml
# 修改配置文件

##################################################
#                                                #
#                  Codis-Proxy                   #
#                                                #
##################################################

# Set Codis Product Name/Auth.
product_name = "codis-demo"
product_auth = ""

# Set bind address for admin(rpc), tcp only.
admin_addr = "0.0.0.0:11080"

# Set bind address for proxy, proto_type can be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
proto_type = "tcp4"
proxy_addr = "0.0.0.0:19000"

# Set jodis address & session timeout, only accept "zookeeper" & "etcd".
jodis_name = "zookeeper"
jodis_addr = "127.0.0.1:2181"
jodis_timeout = "20s"
jodis_compatible = false

# Set datacenter of proxy.
proxy_datacenter = ""

# Set max number of alive sessions.
proxy_max_clients = 1000

# Set max offheap memory size. (0 to disable)
proxy_max_offheap_size = "1024mb"

# Set heap placeholder to reduce GC frequency.
proxy_heap_placeholder = "256mb"

# Proxy will ping backend redis (and clear ‘MASTERDOWN‘ state) in a predefined interval. (0 to disable)
backend_ping_period = "5s"

# Set backend recv buffer size & timeout.
backend_recv_bufsize = "128kb"
backend_recv_timeout = "30s"

# Set backend send buffer & timeout.
backend_send_bufsize = "128kb"
backend_send_timeout = "30s"

# Set backend pipeline buffer size.
backend_max_pipeline = 1024

# Set backend never read replica groups, default is false
backend_primary_only = false

# Set backend parallel connections per server
backend_primary_parallel = 1
backend_replica_parallel = 1

# Set backend tcp keepalive period. (0 to disable)
backend_keepalive_period = "75s"

# If there is no request from client for a long time, the connection will be closed. (0 to disable)
# Set session recv buffer size & timeout.
session_recv_bufsize = "128kb"
session_recv_timeout = "30m"

# Set session send buffer size & timeout.
session_send_bufsize = "64kb"
session_send_timeout = "30s"

# Make sure this is higher than the max number of requests for each pipeline request, or your client may be blocked.
# Set session pipeline buffer size.
session_max_pipeline = 1024

# Set session tcp keepalive period. (0 to disable)
session_keepalive_period = "75s"

# Set session to be sensitive to failures. Default is false, instead of closing socket, proxy will send an error response to client.
session_break_on_failure = false

# Set metrics server (such as http://localhost:28000), proxy will report json formatted metrics to specified server in a predefined period.
metrics_report_server = ""
metrics_report_period = "1s"

# Set influxdb server (such as http://localhost:8086), proxy will report metrics to influxdb.
metrics_report_influxdb_server = ""
metrics_report_influxdb_period = "1s"
metrics_report_influxdb_username = ""
metrics_report_influxdb_password = ""
metrics_report_influxdb_database = ""
# 启动 codis-proxy

nohup /opt/local/codis/bin/codis-proxy --ncpu=4 --config=/opt/local/codis/config/proxy.toml     --log=/opt/local/codis/logs/proxy.log --log-level=WARN &

# 日志输出如下:

proxy waiting online ...

# 必须添加到集群中,才正常。
# 可使用 Codis-fe 界面添加 或者使用 Codis-admin 添加

Codis-Server

# 启动 server 与 启动 redis 方法相同

nohup /opt/local/codis/bin/codis-server /opt/local/codis/config/redis.conf &

# 启动 Codis-Server 以后需要使用 Codis-fe  或者 Codis-admin 添加到集群
# 配置文件

bind 127.0.0.1
protected-mode yes
port 6379
tcp-backlog 2048
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/opt/local/codis/logs/redis.log"
maxmemory 10gb
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis_dump.rdb
dir /opt/local/codis/data
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

Codis-FE

# 启动 codis-fe

nohup /opt/local/codis/bin/codis-fe --ncpu=4 --log=/opt/local/codis/logs/fe.log --log-level=WARN --zookeeper=127.0.0.1:2181 --listen=127.0.0.1:8080 &

Codis-admin

# 添加 codis-proxy

/opt/local/codis/bin/codis-admin --dashboard=127.0.0.1:18080 --create-proxy -x 127.0.0.1:11080

# 日志输入如下:
jodis create node /jodis/codis-demo/proxy-15fba3007f3c6ee0887749681cb82307
proxy is working ...
# 修复异常退出的 Codis-dashboard 
# dashboard 非正常退出,或者 kill -9 时使用

/opt/local/codis/bin/codis-admin --remove-lock --product=codis-demo --zookeeper=127.0.0.1:2181
# 修复异常退出的 Codis-proxy
# proxy 非正常退出,或者 kill -9 时使用

/opt/local/bin/codis-admin --dashboard=127.0.0.1:18080 --remove-proxy --addr=127.0.0.1:11080 --force


时间: 2024-08-24 12:42:52

安装codis 以及遇到的一些问题的相关文章

codis 新版本 CodisLabs 编译安装

codis 3.0 版本编译安装 # 首先安装 go 语言 wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz tar zxvf go1.4.2.linux-amd64.tar.gz mv go /opt/local/ # 配置环境变量 vi /etc/profile -------------------------------------- export GOROOT=/opt/local/go expo

Codis安装部署2台服务器没有HA版本

项目地址: https://github.com/wandoulabs/codis 中文说明文档: https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md 参考地址: http://0xffff.me/blog/2014/11/11/codis-de-she-ji-yu-shi-xian-part-2/ http://www.cnblogs.com/xuanzhi201111/p/4425194.html http:/

Codis安装部署全架构

前期规划 机器与应用列表: 操作系统:CentOS6.5 1,操作系统:CentOS6.5 192.168.88.106    codis-server1 192.168.88.107    codis-server2 192.168.88.108    codis-server3 192.168.88.111    codis-ha1 192.168.88.112    codis-ha2 192.168.88.113   zookeeper-1(codis-proxy-1) 192.168.

Redis集群方案,Codis安装测试

1,关于豌豆荚开源的Codis Codis是豌豆荚使用Go和C语言开发.以代理的方式实现的一个Redis分布式集群解决方案,且完全兼容Twemproxy.Twemproxy对于上一层的应用来说, 连接Codis Proxy(Redis代理服务)和连接原生的Redis服务器没有明显的区别,上一层应用能够像使用单机的 Redis一样对待.Codis底层会处理请求的转发.不停机的数据迁移等工作, 所有底层的一切处理, 对于客户端来说是透明的.总之,可以简单的认为后台连接的是一个内存无限大的Redis服

Codis的安装与使用

1背景 codis的github地址,里面很全,并且是中文的,但是按照他的步骤还是有些坑哈 https://github.com/CodisLabs/codis codis是一种基于高可用的redis集群的一种带来,使用go语言编写.被广泛使用到豌豆荚和其他公司. https://github.com/CodisLabs/codis/releases 可以下载各种版本 codis特点: 图形化操作和管理员工具 支持大部分redis命令,完全兼容Twemproxy 代理数据在zookeeper中,

Codis 是一个分布式 Redis 解决方案

Codis源码地址:https://github.com/wandoulabs/codis 关于Codis组件可以参考:https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md 今天分享的这篇文章纯属个人的一些理解和使用的一些心得体会,如果错误也请朋友指出. 更重要的是为了认识一些正在使用或将要使用Codis的朋友有或多或少的帮助. 关于Codis的整体架构和功能介绍官方文档给的在详细不过了,所以我也不想在画蛇添足. 由

codis

Codis2.0安装手册 1前言 1.1编写目的 Codis2.0介绍及安装规范. 1.2适用范围 Codis2.0.x版本. 1.3中间件版本 Codis:2.0.14 ZooKeeper:3.4.8 1.4github地址 https://github.com/CodisLabs/codis 2linux环境检查 2.1用户UID和GID检查 确认用户appman的UID和GID是否符合规范要求: cat /etc/passwd 内容: appman:x:500:500::/home/app

Redis集群解决方案-Codis

Codis由豌豆荚于2014年11月开源,基于go和c开发,是近期涌现的.国人开发的优秀开源软件之一,稳定性极高,性能更是改善了很多. Codis由四部分组成: codis-proxy:codis-proxy是客户端连接的Redis代理服务,codis-proxy本身实现了Redis协议,表现得和一个原生Redis没什么区别,对于一个业务来说,可以部署多个codis-proxy,codis-proxy本身是无状态的 codis-config:codis-config是Codis的管理工具,支持添

redis的分布式解决方式--codis (转)

codis是豌豆荚开源的分布式server.眼下处于稳定阶段. 原文地址:https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md Codis 是一个分布式 Redis 解决方式, 对于上层的应用来说, 连接到 Codis Proxy 和连接原生的 Redis Server 没有明显的差别 (不支持的命令列表), 上层应用能够像使用单机的 Redis 一样使用, Codis 底层会处理请求的转发, 不停机的数据迁移等工作