Codis服务搭建成功案例Word文档格式.docx

上传人:b****5 文档编号:21645737 上传时间:2023-01-31 格式:DOCX 页数:10 大小:798.97KB
下载 相关 举报
Codis服务搭建成功案例Word文档格式.docx_第1页
第1页 / 共10页
Codis服务搭建成功案例Word文档格式.docx_第2页
第2页 / 共10页
Codis服务搭建成功案例Word文档格式.docx_第3页
第3页 / 共10页
Codis服务搭建成功案例Word文档格式.docx_第4页
第4页 / 共10页
Codis服务搭建成功案例Word文档格式.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

Codis服务搭建成功案例Word文档格式.docx

《Codis服务搭建成功案例Word文档格式.docx》由会员分享,可在线阅读,更多相关《Codis服务搭建成功案例Word文档格式.docx(10页珍藏版)》请在冰豆网上搜索。

Codis服务搭建成功案例Word文档格式.docx

mvzookeeper-3.4.6/usr/local/zookeeper

mkdir-p/data/zookeeper/{data,logs}

配置zoo.cfg

vim/usr/local/zookeeper/conf/zoo.cfg

tickTime=2000

initLimit=5

syncLimit=2

dataDir=/data/zookeeper/data

dataLogDir=/data/zookeeper/logs

clientPort=2181

server.1=zookeeper-1:

2888:

3888

server.2=zookeeper-2:

server.3=zookeeper-2:

上述配置内容说明,可以参考

http:

//zookeeper.apache.org/doc/trunk/zookeeperStarted.html#sc_RunningReplicatedZooKeeper

设置myid

在我们配置的dataDir指定的目录下面,创建一个myid文件,里面内容为一个数字,用来标识当前主机,conf/zoo.cfg文件中配置的server.X中X为什么数字,则myid文件中就输入这个数字

[root@zookeeper-1~]#echo1>

/data/zookeeper/data/myid

[root@zookeeper-2~]#echo2>

[root@zookeeper-3~]#echo3>

设置环境变量

vim/etc/profile

exportZOOKEEPERPATH=/usr/local/zookeeper

GO_BIN=/usr/local/go/bin

exportGOROOT=/usr/local/go

exportCODISPATH=/usr/local/codis

exportGOPATH=/data/gopath

exportGO15VENDOREXPERIMENT=1

exportPATH=$PATH:

$GOROOT/bin:

$ZOOKEEPERPATH/bin:

$CODISPATH/bin:

$GOPATH/bin

source/etc/profile

测试zoopkeeper

启动顺序zookeeper-1>

zookeeper-2>

zookeeper-3

[root@zookeeper-1zookeeper]#zkServer.shstart

JMXenabledbydefault

Usingconfig:

/usr/local/zookeeper/bin/../conf/zoo.cfg

Startingzookeeper...STARTED

[root@zookeeper-1zookeeper]#zkServer.shstatus

Mode:

leader

可以看到最先开始启动的是leader,其他两个是follower

注意关闭防火墙:

systemctlstopfirewalld.service

3、安装go语言环境

(参考:

cd/home/deploy/

wgetgo1.5.2.linux-amd64.tar.gz

tar-zxvfgo1.5.2.linux-amd64.tar.gz

4、安装codis

安装git

[root@vm-82-39-buy01-hp~]#yuminstall-ygit

配置环境变量

[root@vm-82-39-buy01-hp~]#vim/etc/profile

exportGOPATH=/home/deploy/gopath

exportCODISPATH=/usr/local/codis

exportPATH=/bin:

$PATH:

$GOPATH/bin:

$CODISPATH/bin

[root@vm-82-39-buy01-hp~]#source/etc/profile

[root@vm-82-39-buy01-hp~]#goget-u-d#这个需要几分钟下载共30M文件

cd$GOPATH/src/

make

makegotest

没有错误后

mkdir-p/home/deploy/codis/data/codis_server/{logs,conf,data}

mkdir-p/usr/local/codis/{logs,conf,scripts}

cp./config.ini/usr/local/codis/conf/

cp-rfbin/usr/local/codis/

5、配置运行codis

这是一个灰常麻烦的过程,要有心里准备

建立codis配置文件

viusr/local/codis/conf/config.ini(zookeeper-1配置)

coordinator=zookeeper

zk=10.154.82.106:

2181,10.154.82.107:

2181,10.154.82.108:

2181

product=codis-proxy

dashboard_addr=10.154.82.39:

18087

password=

backend_ping_period=5

session_max_timeout=1800

session_max_bufsize=131072

session_max_pipeline=1024

zk_session_timeout=30000

proxy_id=proxy_1

viusr/local/codis/conf/config.ini(zookeeper-2配置)

product=codis-proxy

dashboard_addr=10.154.82.107:

proxy_id=proxy_2

viusr/local/codis/conf/config.ini(zookeeper-3配置)

dashboard_addr=10.154.82.108:

proxy_id=proxy_3

建立codis-server服务配置文件

cdusr/local/codis/conf/

viredis.conf

daemonizeyes

pidfile/var/run/redis_6379.pid

port6379

tcp-backlog511

timeout300

tcp-keepalive0

loglevelnotice

logfile"

/data/codis_server/logs/redis_6379.log"

databases16

stop-writes-on-bgsave-erroryes

rdbcompressionyes

rdbchecksumyes

dbfilename6379.rdb

dir/data/codis_server/data

slave-serve-stale-datayes

repl-disable-tcp-nodelayno

slave-priority100

maxclients10000

maxmemory3gb

maxmemory-policyallkeys-lru

appendonlyyes

appendfilename"

6379_appendonly.aof"

appendfsynceverysec

no-appendfsync-on-rewriteno

auto-aof-rewrite-percentage100

auto-aof-rewrite-min-size64mb

lua-time-limit5000

slowlog-log-slower-than10000

slowlog-max-len128

latency-monitor-threshold0

notify-keyspace-events"

"

hash-max-ziplist-entries512

hash-max-ziplist-value64

list-max-ziplist-entries512

list-max-ziplist-value64

set-max-intset-entries512

zset-max-ziplist-entries128

zset-max-ziplist-value64

hll-sparse-max-bytes3000

activerehashingyes

client-output-buffer-limitnormal000

client-output-buffer-limitslave256mb64mb60

client-output-buffer-limitpubsub32mb8mb60

hz10

aof-rewrite-incremental-fsyncyes

将redis.conf配置文件到其他codis集群机器上

6、启动顺序(三台服务器都需要启动)

A、启动zk

zkServer.shstart

B、启动codis

a、启动dashboard

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.inidashboard&

b、初始化slots

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.inislotsinit

c、启动codisredis

/usr/local/codis/bin/codis-server/data/codis_server/conf/6379.conf

/usr/local/codis/bin/codis-server/data/codis_server/conf/6380.conf

/usr/local/codis/bin/codis-server/data/codis_server/conf/6389.conf

/usr/local/codis/bin/codis-server/data/codis_server/conf/6390.conf

d、添加RedisServerGroup

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd0zookeeper-1:

6379master&

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd1zookeeper-1:

6380master&

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd2zookeeper-1:

6389master&

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd3zookeeper-1:

6390master&

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd0zookeeper-2:

6379slave&

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd1zookeeper-2:

6380slave&

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd2zookeeper-2:

6389slave&

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniserveradd3zookeeper-2:

6390slave&

e、分配slot

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.inislotrange-set03411online

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.inislotrange-set3426822online

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.inislotrange-set68310233online

f、启动codis-proxy

/usr/local/codis/bin/codis-proxy-c/usr/local/codis/conf/config.ini-L/data/log/codis-proxy.log--cpu=1--addr=0.0.0.0:

19000--http-addr=0.0.0.0:

11000&

g、上线proxy

/usr/local/codis/bin/codis-config-c/usr/local/codis/conf/config.iniproxyonlineproxy_1

h、测试

//192.168.1.221:

18087/admin/

redis-cli-h192.168.11.231-p19000

setpwd123456

getpwd

setpwd2123456

getpwd2

redis-cli-h192.168.11.232-p19000

redis-benchmark-h192.168.1.221-p19000-q-d100

SET/GET100bytes检测host为192.168.1.221端口为19000的redis服务器性能

 

redis-benchmark-h192.168.1.222-p19000-c500-n10000

500个并发连接,10000个请求,检测host为192.168.1.222端口为19000的redis服务器性能

============================okcodis搭建完成=======================

参考文档:

文/鑫哥学会了沉默(简书作者)

原文链接:

著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 农学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1