当前位置:   article > 正文

【DataSophon】DataSophon1.2.1 ranger usersync整合_datasophon 打包

datasophon 打包

 目录

一、简介

二、实现步骤

2.1 ranger-usersync包下载编译

2.2 构建压缩包

2.3 编辑元数据文件

2.4 修改源码

三、重新安装


一、简介


如下是DDP1.2.1默认有的rangerAdmin, 我们需要将rangerusersync整合进来 ,实现将Linux机器上的用户和组信息同步到RangerAdmin的数据库中进行管理。


二、实现步骤


2.1 ranger-usersync包下载编译


ranger官网tar包下载

https://ranger.apache.org/download.html

自己编译 或者网上下载

参考文章:

Apache Ranger - Download Apache Ranger?

Ranger安装和使用-CSDN博客

https://juejin.cn/post/6844904159930482696

https://zhuanlan.zhihu.com/p/562012618

权限管理Ranger详解_大数据权限管理利器 - ranger-CSDN博客

2.2 构建压缩包


将ranger-usersync安装包集成到ranger组件中重新打包,如下是ranger admin包和ranger-usersync包。

  1. # 解压ranger组件原有包
  2. tar -zxvf ranger-2.1.0.tar.gz
  3. cd ranger-2.1.0
  4. # 将编译好的的sync安装包解压到当前目录
  5. tar -zxvf ranger-2.1.0-usersync.tar.gz ./
  6. cd ranger-2.1.0-usersync
  7. vim ranger_usersync.sh
  1. #!/bin/bash
  2. # 获取脚本当前目录
  3. current_path=$(dirname "$0")
  4. # 使用说明
  5. usage="Usage: $0 {start|stop|status|restart}"
  6. start(){
  7. echo "ranger userSync start"
  8. sh "$current_path/ranger-usersync" start
  9. if [ $? -eq 0 ]; then
  10. echo "ranger userSync start success"
  11. else
  12. echo "ranger userSync start failed"
  13. exit 1
  14. fi
  15. }
  16. stop(){
  17. echo "ranger userSync stop"
  18. sh "$current_path/ranger-usersync" stop
  19. if [ $? -eq 0 ]; then
  20. echo "ranger userSync stop success"
  21. else
  22. echo "ranger userSync stop failed"
  23. exit 1
  24. fi
  25. }
  26. status(){
  27. process_name="UnixAuthenticationService"
  28. # 使用 pgrep 命令检测进程是否存在
  29. pgrep -f "$process_name" > /dev/null
  30. if [ $? -eq 0 ]; then
  31. echo "进程 $process_name 存在"
  32. exit 0
  33. else
  34. echo "进程 $process_name 不存在"
  35. exit 1
  36. fi
  37. }
  38. restart(){
  39. echo "ranger userSync restart"
  40. sh "$current_path/ranger-usersync" restart
  41. if [ $? -eq 0 ]; then
  42. echo "ranger userSync restart success"
  43. else
  44. echo "ranger userSync restart failed"
  45. exit 1
  46. fi
  47. }
  48. # 处理参数
  49. startStop=$1
  50. case $startStop in
  51. start)
  52. start
  53. ;;
  54. stop)
  55. stop
  56. ;;
  57. status)
  58. status
  59. ;;
  60. restart)
  61. restart
  62. ;;
  63. *)
  64. echo "$usage"
  65. exit 1
  66. ;;
  67. esac
  68. echo "End $startStop ranger userSync"

打包

  1. tar -zcvf ranger-2.1.0.tar.gz ranger-2.1.0
  2. md5sum ranger-2.1.0.tar.gz
  3. echo '756fa828e02d8f890ca2165d237ef487' > ranger-2.1.0.tar.gz.md5
  4. cp ranger-2.1.0.tar.gz ranger-2.1.0.tar.gz.md5 /opt/datasophon/DDP/packages/

2.3 编辑元数据文件


ranger安装配置文件

vim /opt/datasophon/DDP/packages/datasophon-manager-1.2.1/conf/meta/DDP-1.2.1/RANGER/service_ddl.json
  1. {
  2. "name": "RANGER",
  3. "label": "Ranger",
  4. "description": "权限控制框架",
  5. "version": "2.1.0",
  6. "sortNum": 10,
  7. "dependencies":[],
  8. "packageName": "ranger-2.1.0.tar.gz",
  9. "decompressPackageName": "ranger-2.1.0",
  10. "roles": [
  11. {
  12. "name": "RangerAdmin",
  13. "label": "RangerAdmin",
  14. "roleType": "master",
  15. "cardinality": "1",
  16. "logFile": "/var/log/ranger/admin/ranger-admin-${host}-root.log",
  17. "jmxPort": 6081,
  18. "sortNum": 1,
  19. "startRunner": {
  20. "timeout": "60",
  21. "program": "bin/ranger_admin.sh",
  22. "args": [
  23. "start"
  24. ]
  25. },
  26. "stopRunner": {
  27. "timeout": "600",
  28. "program": "bin/ranger_admin.sh",
  29. "args": [
  30. "stop"
  31. ]
  32. },
  33. "statusRunner": {
  34. "timeout": "60",
  35. "program": "bin/ranger_admin.sh",
  36. "args": [
  37. "status"
  38. ]
  39. },
  40. "externalLink": {
  41. "name": "RangerAdmin Ui",
  42. "label": "RangerAdmin Ui",
  43. "url": "http://${host}:6080"
  44. }
  45. },
  46. {
  47. "name": "RangerUsersync",
  48. "label": "RangerUsersync",
  49. "roleType": "master",
  50. "runAs": {
  51. "user": "root",
  52. "group": "root"
  53. },
  54. "cardinality": "1",
  55. "logFile": "ranger-2.1.0-usersync/logs/usersync-${host}-ranger.log",
  56. "jmxPort": "",
  57. "sortNum": 2,
  58. "startRunner": {
  59. "timeout": "60",
  60. "program": "ranger-2.1.0-usersync/ranger_usersync.sh",
  61. "args": [
  62. "start"
  63. ]
  64. },
  65. "stopRunner": {
  66. "timeout": "600",
  67. "program": "ranger-2.1.0-usersync/ranger_usersync.sh",
  68. "args": [
  69. "stop"
  70. ]
  71. },
  72. "statusRunner": {
  73. "timeout": "60",
  74. "program": "ranger-2.1.0-usersync/ranger_usersync.sh",
  75. "args": [
  76. "status"
  77. ]
  78. },
  79. "restartRunner": {
  80. "timeout": "60",
  81. "program": "ranger-2.1.0-usersync/ranger_usersync.sh",
  82. "args": [
  83. "restart"
  84. ]
  85. }
  86. }
  87. ],
  88. "configWriter": {
  89. "generators": [
  90. {
  91. "filename": "install.properties",
  92. "configFormat": "custom",
  93. "templateName": "ranger-install.ftl",
  94. "outputDirectory": "",
  95. "includeParams": [
  96. "rootPassword",
  97. "dbHost",
  98. "database",
  99. "rangerUser",
  100. "rangerPassword",
  101. "rangerAdminUrl",
  102. "enableHDFSPlugin",
  103. "enableHIVEPlugin",
  104. "enableHBASEPlugin",
  105. "spnegoPrincipal",
  106. "spnegoKeytab",
  107. "adminPrincipal",
  108. "adminKeytab",
  109. "hadoopHome",
  110. "rangerHome"
  111. ]
  112. },
  113. {
  114. "filename": "install.properties1",
  115. "configFormat": "custom",
  116. "templateName": "ranger-usersync-install.ftl",
  117. "outputDirectory": "ranger-2.1.0-usersync",
  118. "includeParams": [
  119. "rangerAdminUrl",
  120. "adminPrincipal",
  121. "adminKeytab",
  122. "hadoopHome",
  123. "syncInterval"
  124. ]
  125. }
  126. ]
  127. },
  128. "parameters": [
  129. {
  130. "name": "rootPassword",
  131. "label": "数据库root用户密码",
  132. "description": "",
  133. "required": true,
  134. "configType": "map",
  135. "type": "input",
  136. "value": "",
  137. "configurableInWizard": true,
  138. "hidden": false,
  139. "defaultValue": "123456"
  140. },
  141. {
  142. "name": "dbHost",
  143. "label": "数据库地址",
  144. "description": "",
  145. "required": true,
  146. "configType": "map",
  147. "type": "input",
  148. "value": "",
  149. "configurableInWizard": true,
  150. "hidden": false,
  151. "defaultValue": "${apiHost}"
  152. },{
  153. "name": "database",
  154. "label": "数据库名",
  155. "description": "",
  156. "required": true,
  157. "configType": "map",
  158. "type": "input",
  159. "value": "",
  160. "configurableInWizard": true,
  161. "hidden": false,
  162. "defaultValue": "ranger"
  163. },
  164. {
  165. "name": "rangerUser",
  166. "label": "Ranger数据库用户",
  167. "description": "",
  168. "required": true,
  169. "configType": "map",
  170. "type": "input",
  171. "value": "",
  172. "configurableInWizard": true,
  173. "hidden": false,
  174. "defaultValue": "ranger"
  175. },{
  176. "name": "rangerPassword",
  177. "label": "Ranger数据库密码",
  178. "description": "",
  179. "required": true,
  180. "configType": "map",
  181. "type": "input",
  182. "value": "",
  183. "configurableInWizard": true,
  184. "hidden": false,
  185. "defaultValue": "ranger"
  186. },
  187. {
  188. "name": "rangerAdminUrl",
  189. "label": "Ranger访问地址",
  190. "description": "",
  191. "required": true,
  192. "configType": "map",
  193. "type": "input",
  194. "value": "",
  195. "configurableInWizard": true,
  196. "hidden": false,
  197. "defaultValue": "${rangerAdminUrl}"
  198. },
  199. {
  200. "name": "enableHDFSPlugin",
  201. "label": "启用HDFS Ranger插件",
  202. "description": "",
  203. "required": true,
  204. "type": "switch",
  205. "value": false,
  206. "configurableInWizard": true,
  207. "hidden": false,
  208. "defaultValue": false
  209. },
  210. {
  211. "name": "enableHIVEPlugin",
  212. "label": "启用Hive Ranger插件",
  213. "description": "",
  214. "required": true,
  215. "type": "switch",
  216. "value": false,
  217. "configurableInWizard": true,
  218. "hidden": false,
  219. "defaultValue": false
  220. },
  221. {
  222. "name": "enableHBASEPlugin",
  223. "label": "启用Hbase Ranger插件",
  224. "description": "",
  225. "required": true,
  226. "type": "switch",
  227. "value": false,
  228. "configurableInWizard": true,
  229. "hidden": false,
  230. "defaultValue": false
  231. },
  232. {
  233. "name": "enableKerberos",
  234. "label": "开启Kerberos认证",
  235. "description": "开启Kerberos认证",
  236. "required": false,
  237. "type": "switch",
  238. "value": false,
  239. "configurableInWizard": true,
  240. "hidden": true,
  241. "defaultValue": false
  242. },
  243. {
  244. "name": "spnegoPrincipal",
  245. "label": "Spnego Principal",
  246. "description": "",
  247. "configWithKerberos": true,
  248. "required": false,
  249. "configType": "map",
  250. "type": "input",
  251. "value": "HTTP/${host}@HADOOP.COM",
  252. "configurableInWizard": true,
  253. "hidden": true,
  254. "defaultValue": "HTTP/${host}@HADOOP.COM"
  255. },
  256. {
  257. "name": "spnegoKeytab",
  258. "label": "Spnego Keytab",
  259. "description": "",
  260. "configWithKerberos": true,
  261. "required": false,
  262. "configType": "map",
  263. "type": "input",
  264. "value": "/etc/security/keytab/spnego.service.keytab",
  265. "configurableInWizard": true,
  266. "hidden": true,
  267. "defaultValue": "/etc/security/keytab/spnego.service.keytab"
  268. },
  269. {
  270. "name": "adminPrincipal",
  271. "label": "Ranger Admin Principal",
  272. "description": "",
  273. "configWithKerberos": true,
  274. "required": false,
  275. "configType": "map",
  276. "type": "input",
  277. "value": "rangeradmin/${host}@HADOOP.COM",
  278. "configurableInWizard": true,
  279. "hidden": true,
  280. "defaultValue": "rangeradmin/${host}@HADOOP.COM"
  281. },
  282. {
  283. "name": "adminKeytab",
  284. "label": "Ranger Admin Keytab",
  285. "description": "",
  286. "configWithKerberos": true,
  287. "required": false,
  288. "configType": "map",
  289. "type": "input",
  290. "value": "/etc/security/keytab/rangeradmin.keytab",
  291. "configurableInWizard": true,
  292. "hidden": true,
  293. "defaultValue": "/etc/security/keytab/rangeradmin.keytab"
  294. },
  295. {
  296. "name": "hadoopHome",
  297. "label": "HADOOP_HOME",
  298. "description": "",
  299. "configWithKerberos": true,
  300. "required": true,
  301. "configType": "map",
  302. "type": "input",
  303. "value": "${HADOOP_HOME}",
  304. "configurableInWizard": true,
  305. "hidden": true,
  306. "defaultValue": "${HADOOP_HOME}"
  307. },
  308. {
  309. "name": "rangerHome",
  310. "label": "RANGER_HOME",
  311. "description": "",
  312. "required": true,
  313. "configType": "map",
  314. "type": "input",
  315. "value": "${RANGER_HOME}",
  316. "configurableInWizard": true,
  317. "hidden": false,
  318. "defaultValue": "${RANGER_HOME}"
  319. },
  320. {
  321. "name": "syncInterval",
  322. "label": "SYNC_INTERVAL",
  323. "description": "userSync同步间隔时间,单位(分钟)",
  324. "required": true,
  325. "configType": "map",
  326. "type": "input",
  327. "value": "1",
  328. "configurableInWizard": true,
  329. "hidden": false,
  330. "defaultValue": "1"
  331. }
  332. ]
  333. }

各worker元数据文件,已部署的路径:

vim /opt/datasophon/datasophon-worker/conf/templates/ranger-usersync-install.ftl

ranger配置文件 install.properties ,使用了 SYNC_SOURCE = unix

  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # The base path for the usersync process
  16. ranger_base_dir = /etc/ranger
  17. #
  18. # The following URL should be the base URL for connecting to the policy manager web application
  19. # For example:
  20. #
  21. # POLICY_MGR_URL = http://policymanager.xasecure.net:6080
  22. #
  23. POLICY_MGR_URL = ${rangerAdminUrl}
  24. # sync source, only unix and ldap are supported at present
  25. # defaults to unix
  26. SYNC_SOURCE = unix
  27. #
  28. # Minimum Unix User-id to start SYNC.
  29. # This should avoid creating UNIX system-level users in the Policy Manager
  30. #
  31. MIN_UNIX_USER_ID_TO_SYNC = 500
  32. # Minimum Unix Group-id to start SYNC.
  33. # This should avoid creating UNIX system-level users in the Policy Manager
  34. #
  35. MIN_UNIX_GROUP_ID_TO_SYNC = 500
  36. # sync interval in minutes
  37. # user, groups would be synced again at the end of each sync interval
  38. # defaults to 5 if SYNC_SOURCE is unix
  39. # defaults to 360 if SYNC_SOURCE is ldap
  40. SYNC_INTERVAL = ${syncInterval}
  41. #User and group for the usersync process
  42. unix_user=ranger
  43. unix_group=ranger
  44. #change password of rangerusersync user. Please note that this password should be as per rangerusersync user in ranger
  45. rangerUsersync_password=admin123
  46. #Set to run in kerberos environment
  47. usersync_principal=<#if adminPrincipal??>${adminPrincipal}</#if>
  48. usersync_keytab=<#if adminKeytab??>${adminKeytab}</#if>
  49. hadoop_conf=${hadoopHome}/etc/hadoop/conf
  50. #
  51. # The file where all credential is kept in cryptic format
  52. #
  53. CRED_KEYSTORE_FILENAME=/etc/ranger/usersync/conf/rangerusersync.jceks
  54. # SSL Authentication
  55. AUTH_SSL_ENABLED=false
  56. AUTH_SSL_KEYSTORE_FILE=/etc/ranger/usersync/conf/cert/unixauthservice.jks
  57. AUTH_SSL_KEYSTORE_PASSWORD=UnIx529p
  58. AUTH_SSL_TRUSTSTORE_FILE=
  59. AUTH_SSL_TRUSTSTORE_PASSWORD=
  60. # ---------------------------------------------------------------
  61. # The following properties are relevant only if SYNC_SOURCE = ldap
  62. # ---------------------------------------------------------------
  63. # The below properties ROLE_ASSIGNMENT_LIST_DELIMITER, USERS_GROUPS_ASSIGNMENT_LIST_DELIMITER, USERNAME_GROUPNAME_ASSIGNMENT_LIST_DELIMITER,
  64. #and GROUP_BASED_ROLE_ASSIGNMENT_RULES can be used to assign role to LDAP synced users and groups
  65. #NOTE all the delimiters should have different values and the delimiters should not contain characters that are allowed in userName or GroupName
  66. # default value ROLE_ASSIGNMENT_LIST_DELIMITER = &
  67. ROLE_ASSIGNMENT_LIST_DELIMITER = &
  68. #default value USERS_GROUPS_ASSIGNMENT_LIST_DELIMITER = :
  69. USERS_GROUPS_ASSIGNMENT_LIST_DELIMITER = :
  70. #default value USERNAME_GROUPNAME_ASSIGNMENT_LIST_DELIMITER = ,
  71. USERNAME_GROUPNAME_ASSIGNMENT_LIST_DELIMITER = ,
  72. # with above mentioned delimiters a sample value would be ROLE_SYS_ADMIN:u:userName1,userName2&ROLE_SYS_ADMIN:g:groupName1,groupName2&ROLE_KEY_ADMIN:u:userName&ROLE_KEY_ADMIN:g:groupName&ROLE_USER:u:userName3,userName4&ROLE_USER:g:groupName3
  73. #&ROLE_ADMIN_AUDITOR:u:userName&ROLE_KEY_ADMIN_AUDITOR:u:userName&ROLE_KEY_ADMIN_AUDITOR:g:groupName&ROLE_ADMIN_AUDITOR:g:groupName
  74. GROUP_BASED_ROLE_ASSIGNMENT_RULES =
  75. # URL of source ldap
  76. # a sample value would be: ldap://ldap.example.com:389
  77. # Must specify a value if SYNC_SOURCE is ldap
  78. SYNC_LDAP_URL =
  79. # ldap bind dn used to connect to ldap and query for users and groups
  80. # a sample value would be cn=admin,ou=users,dc=hadoop,dc=apache,dc=org
  81. # Must specify a value if SYNC_SOURCE is ldap
  82. SYNC_LDAP_BIND_DN =
  83. # ldap bind password for the bind dn specified above
  84. # please ensure read access to this file is limited to root, to protect the password
  85. # Must specify a value if SYNC_SOURCE is ldap
  86. # unless anonymous search is allowed by the directory on users and group
  87. SYNC_LDAP_BIND_PASSWORD =
  88. # ldap delta sync flag used to periodically sync users and groups based on the updates in the server
  89. # please customize the value to suit your deployment
  90. # default value is set to true when is SYNC_SOURCE is ldap
  91. SYNC_LDAP_DELTASYNC =
  92. # search base for users and groups
  93. # sample value would be dc=hadoop,dc=apache,dc=org
  94. SYNC_LDAP_SEARCH_BASE =
  95. # search base for users
  96. # sample value would be ou=users,dc=hadoop,dc=apache,dc=org
  97. # overrides value specified in SYNC_LDAP_SEARCH_BASE
  98. SYNC_LDAP_USER_SEARCH_BASE =
  99. # search scope for the users, only base, one and sub are supported values
  100. # please customize the value to suit your deployment
  101. # default value: sub
  102. SYNC_LDAP_USER_SEARCH_SCOPE = sub
  103. # objectclass to identify user entries
  104. # please customize the value to suit your deployment
  105. # default value: person
  106. SYNC_LDAP_USER_OBJECT_CLASS = person
  107. # optional additional filter constraining the users selected for syncing
  108. # a sample value would be (dept=eng)
  109. # please customize the value to suit your deployment
  110. # default value is empty
  111. SYNC_LDAP_USER_SEARCH_FILTER =
  112. # attribute from user entry that would be treated as user name
  113. # please customize the value to suit your deployment
  114. # default value: cn
  115. SYNC_LDAP_USER_NAME_ATTRIBUTE = cn
  116. # attribute from user entry whose values would be treated as
  117. # group values to be pushed into Policy Manager database
  118. # You could provide multiple attribute names separated by comma
  119. # default value: memberof, ismemberof
  120. SYNC_LDAP_USER_GROUP_NAME_ATTRIBUTE = memberof,ismemberof
  121. #
  122. # UserSync - Case Conversion Flags
  123. # possible values: none, lower, upper
  124. SYNC_LDAP_USERNAME_CASE_CONVERSION=lower
  125. SYNC_LDAP_GROUPNAME_CASE_CONVERSION=lower
  126. #user sync log path
  127. logdir=logs
  128. #/var/log/ranger/usersync
  129. # PID DIR PATH
  130. USERSYNC_PID_DIR_PATH=/var/run/ranger
  131. # do we want to do ldapsearch to find groups instead of relying on user entry attributes
  132. # valid values: true, false
  133. # any value other than true would be treated as false
  134. # default value: false
  135. SYNC_GROUP_SEARCH_ENABLED=
  136. # do we want to do ldapsearch to find groups instead of relying on user entry attributes and
  137. # sync memberships of those groups
  138. # valid values: true, false
  139. # any value other than true would be treated as false
  140. # default value: false
  141. SYNC_GROUP_USER_MAP_SYNC_ENABLED=
  142. # search base for groups
  143. # sample value would be ou=groups,dc=hadoop,dc=apache,dc=org
  144. # overrides value specified in SYNC_LDAP_SEARCH_BASE, SYNC_LDAP_USER_SEARCH_BASE
  145. # if a value is not specified, takes the value of SYNC_LDAP_SEARCH_BASE
  146. # if SYNC_LDAP_SEARCH_BASE is also not specified, takes the value of SYNC_LDAP_USER_SEARCH_BASE
  147. SYNC_GROUP_SEARCH_BASE=
  148. # search scope for the groups, only base, one and sub are supported values
  149. # please customize the value to suit your deployment
  150. # default value: sub
  151. SYNC_GROUP_SEARCH_SCOPE=
  152. # objectclass to identify group entries
  153. # please customize the value to suit your deployment
  154. # default value: groupofnames
  155. SYNC_GROUP_OBJECT_CLASS=
  156. # optional additional filter constraining the groups selected for syncing
  157. # a sample value would be (dept=eng)
  158. # please customize the value to suit your deployment
  159. # default value is empty
  160. SYNC_LDAP_GROUP_SEARCH_FILTER=
  161. # attribute from group entry that would be treated as group name
  162. # please customize the value to suit your deployment
  163. # default value: cn
  164. SYNC_GROUP_NAME_ATTRIBUTE=
  165. # attribute from group entry that is list of members
  166. # please customize the value to suit your deployment
  167. # default value: member
  168. SYNC_GROUP_MEMBER_ATTRIBUTE_NAME=
  169. # do we want to use paged results control during ldapsearch for user entries
  170. # valid values: true, false
  171. # any value other than true would be treated as false
  172. # default value: true
  173. # if the value is false, typical AD would not return more than 1000 entries
  174. SYNC_PAGED_RESULTS_ENABLED=
  175. # page size for paged results control
  176. # search results would be returned page by page with the specified number of entries per page
  177. # default value: 500
  178. SYNC_PAGED_RESULTS_SIZE=
  179. #LDAP context referral could be ignore or follow
  180. SYNC_LDAP_REFERRAL = ignore
  181. # if you want to enable or disable jvm metrics for usersync process
  182. # valid values: true, false
  183. # any value other than true would be treated as false
  184. # default value: false
  185. # if the value is false, jvm metrics is not created
  186. JVM_METRICS_ENABLED=
  187. # filename of jvm metrics created for usersync process
  188. # default value: ranger_usersync_metric.json
  189. JVM_METRICS_FILENAME=
  190. #file directory for jvm metrics
  191. # default value : logdir
  192. JVM_METRICS_FILEPATH=
  193. #frequency for jvm metrics to be updated
  194. # default value : 10000 milliseconds
  195. JVM_METRICS_FREQUENCY_TIME_IN_MILLIS=

2.4 修改源码


com.datasophon.worker.strategy.RangerAdminHandlerStrategy

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package com.datasophon.worker.strategy;
  18. import cn.hutool.core.io.FileUtil;
  19. import com.datasophon.common.Constants;
  20. import com.datasophon.common.cache.CacheUtils;
  21. import com.datasophon.common.command.ServiceRoleOperateCommand;
  22. import com.datasophon.common.enums.CommandType;
  23. import com.datasophon.common.utils.ExecResult;
  24. import com.datasophon.common.utils.ShellUtils;
  25. import com.datasophon.worker.handler.ServiceHandler;
  26. import com.datasophon.worker.utils.KerberosUtils;
  27. import java.util.ArrayList;
  28. public class RangerAdminHandlerStrategy extends AbstractHandlerStrategy implements ServiceRoleStrategy {
  29. public RangerAdminHandlerStrategy(String serviceName, String serviceRoleName) {
  30. super(serviceName, serviceRoleName);
  31. }
  32. @Override
  33. public ExecResult handler(ServiceRoleOperateCommand command) {
  34. String workPath = Constants.INSTALL_PATH + Constants.SLASH + command.getDecompressPackageName();
  35. ExecResult startResult = new ExecResult();
  36. ServiceHandler serviceHandler = new ServiceHandler(command.getServiceName(), command.getServiceRoleName());
  37. if (command.getEnableKerberos()) {
  38. logger.info("start to get ranger keytab file");
  39. String hostname = CacheUtils.getString(Constants.HOSTNAME);
  40. KerberosUtils.createKeytabDir();
  41. if (!FileUtil.exist("/etc/security/keytab/spnego.service.keytab")) {
  42. KerberosUtils.downloadKeytabFromMaster("HTTP/" + hostname, "spnego.service.keytab");
  43. }
  44. if (!FileUtil.exist("/etc/security/keytab/rangeradmin.keytab")) {
  45. KerberosUtils.downloadKeytabFromMaster("rangeradmin/" + hostname, "rangeradmin.keytab");
  46. }
  47. }
  48. if (command.getCommandType().equals(CommandType.INSTALL_SERVICE) && command.getServiceRoleName().equals("RangerUsersync")) {
  49. ShellUtils.exceShell("mv " + workPath + "/ranger-2.1.0-usersync/install.properties1 " + workPath + "/ranger-2.1.0-usersync/install.properties");
  50. ShellUtils.exceShell("chmod 755 " + workPath + "/ranger-2.1.0-usersync/install.properties");
  51. logger.info("setup ranger user sync");
  52. ArrayList<String> commands = new ArrayList<>();
  53. commands.add("sh");
  54. commands.add("./setup.sh");
  55. ExecResult execResult = ShellUtils.execWithStatus(workPath + "/ranger-2.1.0-usersync", commands, 300L, logger);
  56. if (execResult.getExecResult()) {
  57. logger.info("setup ranger user sync success");
  58. } else {
  59. logger.info("setup ranger user sync failed");
  60. return execResult;
  61. }
  62. ShellUtils.exceShell("sed -i '/<name>ranger\\.usersync\\.enabled<\\/name>/{n;s/<value>false<\\/value>/<value>true<\\/value>/}' "
  63. + workPath +
  64. "/ranger-2.1.0-usersync/conf/ranger-ugsync-site.xml");
  65. startResult = serviceHandler.start(command.getStartRunner(), command.getStatusRunner(),
  66. command.getDecompressPackageName(), command.getRunAs());
  67. } else {
  68. startResult = serviceHandler.start(command.getStartRunner(), command.getStatusRunner(),
  69. command.getDecompressPackageName(), command.getRunAs());
  70. }
  71. return startResult;
  72. }
  73. }

com.datasophon.worker.strategy.ServiceRoleStrategyContext

map.put("RangerUsersync", new RangerAdminHandlerStrategy("RANGER", "RangerUsersync"));

datasophon-worker jar包更新

mv datasophon-worker-1.2.1.jar      /opt/datasophon/datasophon-worker/lib/


三、重新安装


添加ranger服务

分配服务Master角色

服务配置

选择"settings"我们可以看到linux 上的用户已同步成功。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/861609
推荐阅读
相关标签
  

闽ICP备14008679号