1、configuration目录详解
-
configuration目录:主要对第三方服务的Conf目录下相关配置进行参数定义。
-
核心:configuration被 Ambari Server 加载之后,在前端页面上会出现两个配置项,分别是 高级选项 和 自定义选项。其中 高级选项 里面就是 xml 文件的内容,自定义选项 可以加入自定义配置信息,如果不需要显示自定义配置信息的话,可以通过添加 来隐藏掉自定义配置信息。
2、自定义目录文件
2.1、目录文件说明
- 目录中文件如下
<configuration>
<property>
<name>flink_install_dir</name>
<value>/opt/flink</value>
<description>Location to install Flink</description>
</property>
<property>
<name>elasticsearch_port</name>
<display-name>Elasticsearch port</display-name>
<value>9200</value>
<description>Elasticsearch port</description>
</property>
<property>
<name>content</name>
<display-name>Elasticsearch config file template</display-name>
<description>This is the template for elasticsearch.yml file</description>
<value>
http.port: {{elasticsearch_port}}
</value>
<value-attributes>
<type>content</type>
<show-property-name>true</show-property-name>
</value-attributes>
<on-ambari-upgrade add="true"/>
</property>
<!-->......省略<-->
</configuration>
property
属性说明
属性名称 | 属性描述 | 备注 |
---|---|---|
name | 属性名称,当无 display-name 属性时,name 值将会显示在前端页面上。 | |
display-name | 前端页面显示的名称,会覆盖显示在前端页面上的 name 值。 | |
value | 属性值,前端页面对应输入框里面的值,可修改并保存。 | |
description | 属性描述信息。在前端页面上以鼠标悬浮框的形式显示出来。 |
- 页面展示:configuration 文件内的大部分(普通)属性都会在 Ambari Web UI 上的 CONFIGS 下展示,内容可编辑修改。
2.2、相关参数配置详解
(1)配置项锁定
- 实现效果:服务安装后不可编辑,
<value-attributes>
<editable-only-at-install>true</editable-only-at-install>
</value-attributes>
- 修改前效果图
- 修改后效果图
(2)允许字段为空
- 实现效果:允许value值为空
<value-attributes>
<empty-value-valid>true</empty-value-valid>
</value-attributes>
- 修改前效果:默认情况下字段值为空在安装页面会告警提示
- 修改后效果
(3)设置密码校验
- 实现效果:修改配置项时需要输入密码
<property require-input="true">
<name>kadmin.local.password</name>
<display-name>admin password</display-name>
<value/>
<property-type>PASSWORD</property-type>
<description>The password is used to add the kerberos database administrator</description>
<value-attributes>
<type>password</type>
</value-attributes>
</property>
-
修改后效果图
(4)实现swith滑块 -
效果要求:实现滑块形式的开关要求
<property>
<name>hue-hdfs-module-enabled</name>
<value>Yes</value>
<display-name>Hue HDFS Module</display-name>
<description>Enable Hue Filebrower Module</description>
<value-attributes>
<overridable>false</overridable>
<type>value-list</type>
<entries>
<entry>
<value>Yes</value>
<label>ON</label>
</entry>
<entry>
<value>No</value>
<label>OFF</label>
</entry>
</entries>
<selection-cardinality>1</selection-cardinality>
</value-attributes>
</property>
-
修改前效果
-
修改后效果
(5)是否显示配置名称
- 目标效果:隐藏部分name配置,将value输入框设置为文本框
<value-attributes>
<!-- 默认为input普通输入框,当type为directories时,即为目录输入框,当type为content时,即为文本框 -->
<type>content</type>
<!-- 是否显示配置名称 -->
<show-property-name>true</show-property-name>
</value-attributes>
- 输入框 VS 目录输入框VS 文本框显示效果
(6)自动创建用户和用户组
<property>
<name>elastic_user</name>
<display-name>Elasticsearch user</display-name>
<value>es</value>
<description>Elasticsearch user</description>
<property-type>USER</property-type>
<value-attributes>
<type>user</type>
<user-groups>
<property>
<type>cluster-env</type>
<name>user_group</name>
</property>
<property>
<type>elastic-env</type>
<name>es_group</name>
</property>
</user-groups>
</value-attributes>
</property>
<property>
<name>es_group</name>
<display-name>es User Group</display-name>
<value>elasticsearch_group</value>
<property-type>GROUP</property-type>
<description>es user group.</description>
</property>
- 注意事项:只有在初始安装时可自动创建用户/用户组,如果进行扩容则无法实现自动创建
(7)配置修改后,提示重启服务
<?xml version="1.0"?>
<metainfo>
<schemaVersion>2.0</schemaVersion>
<services>
<service>
...(省略)
<components>
<component>
<name>ELASTICSEARCH_SERVICE</name>
<displayName>Elasticsearch Service</displayName>
<category>MASTER</category>
<cardinality>1+</cardinality>
...(省略)
<configuration-dir>configuration</configuration-dir>
<configuration-dependencies>
<config-type>elastic-config</config-type>
</configuration-dependencies>
...(省略)
</component>
</components>
<configuration-dir>configuration</configuration-dir>
<configuration-dependencies>
<config-type>elastic-env</config-type>
</configuration-dependencies>
...(省略)
</service>
</services>
</metainfo>
- 参数说明: 作用域下的 / 来说,如果在前端页面上修改了该 xml 文件内容后并保存配置,那么整个服务都将会提示重启。如果是 的作用域下,则只提示重启该 component 组件,并不是所有组件都重启。
属性 | 说明 | 备注 |
---|---|---|
config-type | configuration 目录下 xml 文件的名 | |
configuration-dependencies | 指定服务所依赖的配置文件 |
3、调试方法
1、修改文件
2、将修改文件覆盖/var/lib/ambari-server/resources/stacks/HDP/3.1/services/FLINK
3、重启ambari-server
4、卸载服务重新安装
-
文件配置路径:Ambari 自定义服务的参数配置由 xml 文件管理,默认存放在 configuration 目录下。如果要自定义该目录名称的话,可以在 metainfo.xml 中声明,在 service 标签下设置 configuration-dir 的值:
configuration-dir
-
配置修改记录会保存到 ambari 数据库中,主要涉及到的表有如下:
- serviceconfig
- serviceconfigmapping
- clusterconfig(历史配置的详细内容)