redis集群安装部署Word格式.docx

上传人:b****6 文档编号:20289477 上传时间:2023-01-21 格式:DOCX 页数:48 大小:333.14KB
下载 相关 举报
redis集群安装部署Word格式.docx_第1页
第1页 / 共48页
redis集群安装部署Word格式.docx_第2页
第2页 / 共48页
redis集群安装部署Word格式.docx_第3页
第3页 / 共48页
redis集群安装部署Word格式.docx_第4页
第4页 / 共48页
redis集群安装部署Word格式.docx_第5页
第5页 / 共48页
点击查看更多>>
下载资源
资源描述

redis集群安装部署Word格式.docx

《redis集群安装部署Word格式.docx》由会员分享,可在线阅读,更多相关《redis集群安装部署Word格式.docx(48页珍藏版)》请在冰豆网上搜索。

redis集群安装部署Word格式.docx

redis.7003.conf内容

port7003

appendonly.7003.aof"

cluster-config-filenodes-7003.conf

redis.7004.conf内容

port7004

appendonly.7004.aof"

cluster-config-filenodes-7004.conf

redis.7005.conf内容

port7005

appendonly.7005.aof"

cluster-config-filenodes-7005.conf

redis.7006.conf内容

port7006

appendonly.7006.aof"

cluster-config-filenodes-7006.conf

启动服务

打开6个CMD命令行工具,切换到C:

\redis-64.3.0.503目录下,分别输入

Redis-server.exeredis.7001.conf

Redis-server.exeredis.7002.conf

Redis-server.exeredis.7003.conf

Redis-server.exeredis.7004.conf

Redis-server.exeredis.7005.conf

Redis-server.exeredis.7006.conf

启动成功后界面如下

3.Ruby安装

下载地址:

安装界面如下所示

安装完成后,打开命令输入ruby–v命令检查是否安装成功

4.安装redis的ruby运行库

打开命令行输入geminstallredis命令

5.下载redis-trib.rb脚本文件

redis-trib.rb文件是运行redis集群的脚本库,文件内容如下,可将下面的文件内容拷贝到记事本中另存为redis-trib.rb文件

然后将redis-trib.rb拷贝到C:

\redis-64.3.0.503目录下

#!

/usr/bin/envruby

#TODO(temporaryhere,we'

llmovethisintotheGithubissuesonce

#redis-tribinitialimplementationiscompleted).

#

#-Makesurethatiftherehashingfailsinthemiddleredis-tribwilltry

#torecover.

#-Whenredis-tribperformsaclustercheck,ifitdetectsaslotmovein

#progressitshouldprompttheusertocontinuethemovefromwhereit

#stopped.

#-GracefullyhandleCtrl+Cinmove_slottoprompttheuserifreallystop

#whilerehashing,andperformingthebestcleanuppossibleiftheuser

#forcesthequit.

#-Whendoing"

fix"

setaglobalFixtotrue,andprompttheuserto

#fixtheproblemifautomaticallyfixableeverytimethereissomething

#tofix.Forinstance:

#1)Ifthereisanodethatpretendtoreceiveaslot,ortomigratea

#slot,buthasnoentriesinthatslot,fixit.

#2)Ifthereisanodehavingkeysinslotsthatarenotownedbyit

#fixthisconditionmovingtheentriesinthesamenode.

#3)Performmorepossiblyslowtestsaboutthestateofthecluster.

#4)Whenabortedslotmigrationisdetected,fixit.

require'

rubygems'

redis'

ClusterHashSlots=16384

defxputs(s)

cases[0..2]

when"

>

"

color="

29;

1"

[ER"

31;

[OK"

32"

[FA"

"

***"

33"

else

color=nil

end

color=nilifENV['

TERM'

]!

="

xterm"

print"

\033[#{color}m"

ifcolor

prints

\033[0m"

\n"

end

classClusterNode

definitialize(addr)

s=addr.split("

:

ifs.length<

2

puts"

InvalidIPorPort(givenas#{addr})-useIP:

Portformat"

exit1

port=s.pop#removesportfromsplitarray

ip=s.join("

)#ifs.length>

1here,it'

sIPv6,sorestoreaddress

@r=nil

@info={}

@info[:

host]=ip

port]=port

slots]={}

migrating]={}

importing]={}

replicate]=false

@dirty=false#Trueifweneedtoflushslotsinfointonode.

@friends=[]

deffriends

@friends

defslots

slots]

defhas_flag?

(flag)

flags].index(flag)

defto_s

"

#{@info[:

host]}:

port]}"

defconnect(o={})

returnif@r

Connectingtonode#{self}:

STDOUT.flush

begin

@r=Redis.new(:

host=>

host],:

port=>

port],:

timeout=>

60)

@r.ping

rescue

xputs"

[ERR]Sorry,can'

tconnecttonode#{self}"

exit1ifo[:

abort]

OK"

defassert_cluster

info=@r.info

if!

info["

cluster_enabled"

]||info["

].to_i==0

[ERR]Node#{self}isnotconfiguredasaclusternode."

defassert_empty

(@r.cluster("

info"

).split("

\r\n"

).index("

cluster_known_nodes:

))||

(@r.info['

db0'

])

[ERR]Node#{self}isnotempty.Eitherthenodealreadyknowsothernodes(checkwithCLUSTERNODES)orcontainssomekeyindatabase0."

defload_info(o={})

self.connect

nodes=@r.cluster("

nodes"

nodes.each{|n|

#nameaddrflagsroleping_sentping_recvlink_statusslots

split=n.split

name,addr,flags,master_id,ping_sent,ping_recv,config_epoch,link_status=split[0..6]

slots=split[8..-1]

info={

:

name=>

name,

addr=>

addr,

flags=>

flags.split("

),

replicate=>

master_id,

ping_sent=>

ping_sent.to_i,

ping_recv=>

ping_recv.to_i,

link_status=>

link_status

}

info[:

replicate]=falseifmaster_id=="

-"

ifinfo[:

flags].index("

myself"

@info=@info.merge(info)

slots.each{|s|

ifs[0..0]=='

['

ifs.index("

->

)#Migrating

slot,dst=s[1..-1].split("

migrating][slot.to_i]=dst

elsifs.index("

-<

)#Importing

slot,src=s[1..-1].split("

importing][slot.to_i]=src

start,stop=s.split("

self.add_slots((start.to_i)..(stop.to_i))

self.add_slots((s.to_i)..(s.to_i))

}ifslots

@dirty=false

@r.cluster("

).each{|e|

k,v=e.split("

k=k.to_sym

v.chop!

ifk!

=:

cluster_state

@info[k]=v.to_i

@info[k]=v

elsifo[:

getfriends]

@friends<

<

info

defadd_slots(slots)

slots][s]=:

new

@dirty=true

defset_as_replica(node_id)

replicate]=node_id

defflush_node_config

returnif!

@dirty

if@info[:

replicate]

replicate"

@info[:

replicate])

#Iftheclusterdidnotalreadyjoineditispossiblethat

#theslavedoesnotknowthemasternodeyet.Soonerrors

#wereturnASAPleavingthedirtyflagset,toflushthe

#configlater.

return

new=[]

slots].each{|s,val|

ifval==:

new<

s

slots][s]=true

addslots"

*new)

definfo_string

#Wewanttodisplaythehashslotsassignedtothisnode

#asranges,likein:

1-5,8-9,20-25,30"

#

#Note:

thiscouldbeeasilywrittenwithoutsideeffects,

#weuse'

slots'

justtosplitthecomputationintosteps.

#Firststep:

wewantanincreasingarrayofintegers

#forinstance:

[1,2,3,4,5,8,9,20,21,22,23,24,25,30]

slots=@info[:

slots].keys.sort

#Aswewanttoaggregateadjacentslotsweconvertallthe

#slotintegersintoranges(withjustoneelement)

#Sowehavesomethinglike[1..1,2..2,...andsoforth.

slots.map!

{|x|x..x}

#Finallywegrouprangeswithadjacentelements.

slots=slots.reduce([]){|a,b|

a.empty?

&

&

b.first==(a[-1].last)+1

a[0..-2]+[(a[-1].first)..(b.last)]

a+[b]

#Nowourtaskiseasy,wejustconvertrangeswithjustone

#elementintoanumber,andarealrangeintoastart-endformat.

#Finallywejointhearrayusingthecommaasseparator.

slots=slots.map{|x|

x.count==1?

x.first.to_s:

#{x.first}-#{x.last}"

}.join("

role=self.has_flag?

("

master"

)?

M"

S"

ifself.info[:

replicate]and@dirty

is="

S:

#{self.info[:

name]}#{self.to_s}"

#{role}:

name]}#{self.to_s}\n"

+

slots:

#{slots}(#{self.slots.length}slots)"

#{(self.info[:

flags]-["

]).join("

)}"

is+="

\nreplicates#{info[:

replicate]}"

elsifself.has_flag?

)&

self.info[:

replicas]

\n#{info[:

replicas].length}additionalreplica(s)"

is

#Returnasinglestringrepresentingnodesandassociatedslots.

#TODO:

removeslavesfromconfigwhenslaveswillbehandled

#byRedisCluster.

defget_config_signature

config=[]

).each_line{|l|

s=l.split

slots=s[8..-1].select{|x|x[0..0]!

["

}

nextifslots.length==0

config<

s[0]+"

+(slots.sort.join("

))

config.sort.join("

|"

definfo

@info

defis_dirty?

@dirty

defr

@r

classRedisTrib

definitialize

@nodes=[]

@fix=false

@errors=[]

defcheck_arity(req_args,num_args)

if((req_args>

0andnum_args!

=req_args)||

(req_args<

0andnum_args<

req_args.abs))

[ERR]Wrongnumberofargumentsforspecifiedsubcommand"

defadd_node(node)

@nodes<

node

defcluste

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

当前位置:首页 > 高等教育 > 研究生入学考试

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

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