YARN-Service-Registry
基于YARN,可以部署批处理作业或者进行查询,也可以运行长期运行服务,例如tomcat集群,HBase集群,这些服务实例需要被客户端发现,传统做法是通过DNS暴露IP和Port或者写入文件,但是这种机制,无法在服务被创建前被发现。
YARN支持基本的注册,允许AM注册一个web url和一个IPC地址。但是不满足我们的需求,它无法注册其他的端点,例如REST urls或者zookeeper地址,或者AM执行的任务的地址。未来,会通过一个唯一的实例ID去引用一个服务,不管它是否启动,这使得解决了通过静态引用去获取服务的信息,甚至当前未运行的服务实例的信息。
支持的注册机制:
不支持的注册机制:
不建议注册短期运行任务。
查找服务:
未来可能支持的查找机制,通过DNS查找服务。
服务注册的关键要求:
允许动态注册服务实例:
YARN 部署的服务实例必须可以注册绑定和被客户端发现。
核心hadoop服务实例必须能注册服务端点。
绑定信息必须在服务移动或者HA失效时更新。
服务实例必须可以推送各种服务端点,比如:Web UI,RPC,REST,Zookeeper,certificates。
注册服务属性:
注册必须高度可获取
可伸缩,一个服务可以发布多少数据
无所不在,必须在各种平台兼容
必须支持垂直命名空间和名称。
注册API语言、项目
跨语言,客户端语言!= 服务
REST API 获取服务信息
访问控制
所有可读、限制写
支持远程访问
不要求注册服务属性:
不要求存活检查,领导选举,或者其他状态共享。
注册信息不要求永久存储在zookeeper里面,不然很容易快速到达zookeeper限制。
架构:
我们使用zookeeper集群的一部分命名空间来作为服务注册的root。默认是(yarnRegistry)
1.通过一个叫Service Record的东西,绑定一个path到一个值上。
2.服务记录被注册到永久znode上。
3.每个服务记录列出了服务的各种端点
4.对于每一个服务端点包括:
协议名称:Web、REST、IPC、zookeeper
地址:去定位服务
地址类型:
API:
5.端点必须是外部可访问的
6.核心服务使用下列的惯例注册:/services/{servicename}
7.YARN服务需要用下列的惯例注册
/users/{username}/{serviceclass}/{instancename}
8.服务组件的惯例注册
/users/{username}/{serviceclass}/{instancename}/components/{componentname}
9.服务类名必须唯一
10.服务组件必须有一个唯一的名称。
注册模型
服务条目必须永久性。
Service Record:
type:String
description:String
external:List[Endpoint]
internal:List[Endpoint]
YARN Persistence policies
permanent
application
application-attempt
container
endpoints:
api:URI as String
protocol:String
addressType:String,
addresses: List[Map[String,String]]
Registry API:
安全:
注册服务可以通过kerberos管理。
限制:
zookeeper默认节点限制是1M。
配置
在RM开启注册服务
Is the registry enabled in the YARN Resource Manager? If true, the YARN RM will, as needed. create the user and system paths, and purge service records when containers, application attempts and applications complete. If false, the paths must be created by other means, and no automatic cleanup of service records will take place. hadoop.registry.rm.enabled false
设置zookeeper
A comma separated list of hostname:port pairs defining the zookeeper quorum binding for the registry hadoop.registry.zk.quorum localhost:2181
设置zookeeper注册路径
The root zookeeper node for the registry hadoop.registry.zk.root /registry
安全选项:关键设置包括:开启安全模式、acl、kerberos realm、jaas
Key to set if the registry is secure. Turning it on changes the permissions policy from "open access" to restrictions on kerberos with the option of a user adding one or more auth key pairs down their own tree. hadoop.registry.secure false
Key to define the JAAS context. Used in secure mode hadoop.registry.jaas.context Client
Is the registry enabled: does the RM start it up,
create the user and system paths, and purge
service records when containers, application attempts
and applications complete
hadoop.registry.rm.enabled
false
A comma separated list of hostname:port pairs defining the
zookeeper quorum binding for the registry
hadoop.registry.zk.quorum
localhost:2181
The root zookeeper node for the registry
hadoop.registry.zk.root
/registry
Key to set if the registry is secure. Turning it on
changes the permissions policy from "open access"
to restrictions on kerberos with the option of
a user adding one or more auth key pairs down their
own tree.
hadoop.registry.secure
false
A comma separated list of Zookeeper ACL identifiers with
system access to the registry in a secure cluster.
These are given full access to all entries.
If there is an "@" at the end of a SASL entry it
instructs the registry client to append the default kerberos domain.
hadoop.registry.system.acls
sasl:yarn@, sasl:mapred@, sasl:mapred@, sasl:hdfs@
The kerberos realm: used to set the realm of
system principals which do not declare their realm,
and any other accounts that need the value.
If empty, the default realm of the running process
is used.
If neither are known and the realm is needed, then the registry
service/client will fail.
hadoop.registry.kerberos.realm
Key to define the JAAS context. Used in secure
mode
hadoop.registry.jaas.context
Client
Zookeeper session timeout in milliseconds
hadoop.registry.zk.session.timeout.ms
60000
Zookeeper session timeout in milliseconds
hadoop.registry.zk.connection.timeout.ms
15000
Zookeeper connection retry count before failing
hadoop.registry.zk.retry.times
5
hadoop.registry.zk.retry.interval.ms
1000
Zookeeper retry limit in milliseconds, during
exponential backoff: {@value}
This places a limit even
if the retry times and interval limit, combined
with the backoff policy, result in a long retry
period
hadoop.registry.zk.retry.ceiling.ms
60000
使用YARN Service Registry
注册不能被用于:
订阅服务变更
共享信息
共享秘钥