IceRegistry divergent

上文介绍了IceBox, 那么在IceBox上解决集群主备部署和接口负载均衡等问题,就需要使用到IceRegistry.,IceGrid以后再解释。

有啥好处呢?上图,对,都是通过注册代理服务来实现接口的调用,使用者不用关心是来自哪个集群机器提供的接口服务。


run cmd :

icegridregistry --Ice.Config=registry.properties


registry.properties:

IceGrid.Registry.Client.Endpoints=tcp -p 4061
IceGrid.Registry.Server.Endpoints=tcp
IceGrid.Registry.Internal.Endpoints=tcp
#不需要权限认证
IceGrid.Registry.AdminPermissionsVerifier=IceGrid/NullPermissionsVerifier
#持久化数据存放路径
IceGrid.Registry.Data=/usr/local/registry
#允许动态注册
IceGrid.Registry.DynamicRegistration=1
在IceBox的配置文件example.properties中增加

ExampleService.AdapterId=ExampleServiceAdapter
ExampleServiceAdapter.Endpoints=tcp
#registryhost相当于reg所在机器地址,比如192.168.1.1
Ice.Default.Locator=IceGrid/Locator:tcp -h registryhost -p 4061
这样的话就可以完成通信了。
客户端的调用就得改一改:

//Ice.ObjectPrx base = ic.stringToProxy("ExampleService:default -p 10001"); 
Ice.ObjectPrx base = ic.stringToProxy("ExampleService@ExampleServiceAdapter:default -p 10001"); 


那么问题来了,如只有一个Reg,挂掉咋办, 在这里要援引自官方的一个说明:

To promote a slave to become the new master, you must shut down the slave and change its IceGrid.Registry.ReplicaName property to Master (or remove the property altogether). On restart, the new master notifies the nodes and registries that were active before it was shut down. An inactive registry or node will eventually connect to the new master if its default locator proxy contains the endpoint of the new master registry or the endpoint of a slave that is connected to the new master. If you cannot afford any down-time of the registry and want to minimize the down-time of the master, you should run at least two slaves. That way, if the master becomes unavailable, there will always be one registry available while you promote one of the slaves.

我们可以这样做,在Registry.properties里面增加一个名字, 使IceRegistry支持主从模式, 默认是Master 

IceGrid.Registry.ReplicaName=Master
#主机是Master,从机去replica1,一旦主机挂掉了,从机的名字需要改成Master,方便集群中的数据持久化

改变IceBox的配置文件,增加为多Ip,可以填多个,端口也是一样的可以多个

Ice.Default.Locator=IceGrid/Locator:tcp -h registryhost1 registryhost2  -p 4061
最后设计的集群可以是这个样子:




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值