Ambari2.5.2+HDP2.6.2安装时UID错误,创建家目录错误解决

文章目录

  • UID问题描述
  • UID问题解决
  • 创建家目录问题描述
  • 创建家目录问题解决
  • 重启ambari服务

UID问题描述

#  在使用ambari安装hdp集群时报错如下:
stderr: 
Traceback (most recent call last):
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py", line 35, in 
    BeforeAnyHook().execute()
  File "/usr/lib/python2.6/site-packages/resource_management/libraries/script/script.py", line 329, in execute
    method(env)
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py", line 29, in hook
    setup_users()
  File "/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py", line 51, in setup_users
    fetch_nonlocal_groups = params.fetch_nonlocal_groups,
  File "/usr/lib/python2.6/site-packages/resource_management/core/base.py", line 166, in __init__
    self.env.run()
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 160, in run
    self.run_action(resource, action)
  File "/usr/lib/python2.6/site-packages/resource_management/core/environment.py", line 124, in run_action
    provider_action()
  File "/usr/lib/python2.6/site-packages/resource_management/core/providers/accounts.py", line 84, in action_create
    shell.checked_call(command, sudo=True)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 72, in inner
    result = function(command, **kwargs)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 102, in checked_call
    tries=tries, try_sleep=try_sleep, timeout_kill_strategy=timeout_kill_strategy)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 150, in _call_wrapper
    result = _call(command, **kwargs_copy)
  File "/usr/lib/python2.6/site-packages/resource_management/core/shell.py", line 303, in _call
    raise ExecutionFailed(err_msg, code, out, err)
resource_management.core.exceptions.ExecutionFailed: Execution of 'useradd -m -u 1002 -G hadoop -g hadoop zookeeper' returned 4. useradd: UID 1002 is not unique
Error: Error: Unable to run the custom hook script ['/usr/bin/python', '/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py', 'ANY', '/var/lib/ambari-agent/data/command-1072.json', '/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY', '/var/lib/ambari-agent/data/structured-out-1072.json', 'INFO', '/var/lib/ambari-agent/tmp', 'PROTOCOL_TLSv1_2', '']
 stdout:
2019-06-03 10:53:17,586 - Stack Feature Version Info: Cluster Stack=2.6, Cluster Current Version=None, Command Stack=None, Command Version=None -> 2.6
2019-06-03 10:53:17,592 - Using hadoop conf dir: /usr/hdp/current/hadoop-client/conf
User Group mapping (user_group) is missing in the hostLevelParams
2019-06-03 10:53:17,593 - Group['hadoop'] {}
2019-06-03 10:53:17,595 - Group['users'] {}
2019-06-03 10:53:17,595 - File['/var/lib/ambari-agent/tmp/changeUid.sh'] {'content': StaticFile('changeToSecureUid.sh'), 'mode': 0555}
2019-06-03 10:53:17,597 - call['/var/lib/ambari-agent/tmp/changeUid.sh httpfs'] {}
2019-06-03 10:53:17,606 - call returned (0, '1001')
2019-06-03 10:53:17,606 - User['httpfs'] {'gid': 'hadoop', 'fetch_nonlocal_groups': True, 'groups': [u'hadoop'], 'uid': 1001}
2019-06-03 10:53:17,612 - File['/var/lib/ambari-agent/tmp/changeUid.sh'] {'content': StaticFile('changeToSecureUid.sh'), 'mode': 0555}
2019-06-03 10:53:17,613 - call['/var/lib/ambari-agent/tmp/changeUid.sh zookeeper'] {}
2019-06-03 10:53:17,624 - call returned (0, '1002')
2019-06-03 10:53:17,624 - User['zookeeper'] {'gid': 'hadoop', 'fetch_nonlocal_groups': True, 'groups': [u'hadoop'], 'uid': 1002}
2019-06-03 10:53:17,625 - Adding user User['zookeeper']
Error: Error: Unable to run the custom hook script ['/usr/bin/python', '/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY/scripts/hook.py', 'ANY', '/var/lib/ambari-agent/data/command-1072.json', '/var/lib/ambari-agent/cache/stacks/HDP/2.0.6/hooks/before-ANY', '/var/lib/ambari-agent/data/structured-out-1072.json', 'INFO', '/var/lib/ambari-agent/tmp', 'PROTOCOL_TLSv1_2', '']

Command failed after 1 tries

# 该问题为UID被占用,修改UID的取值范围即可 

Ambari2.5.2+HDP2.6.2安装时UID错误,创建家目录错误解决_第1张图片

UID问题解决

# 修改文件:/var/lib/ambari-server/resources/stacks/HDP/2.0.6/hooks/before-ANY/files/changeToSecureUid.sh
[root@manager ~]# vim /var/lib/ambari-server/resources/stacks/HDP/2.0.6/hooks/before-ANY/files/changeToSecureUid.sh
function find_available_uid() {
 for ((i=8001; i<=9000; i++))
 do
   grep -q $i /etc/passwd
   if [ "$?" -ne 0 ]
   then
    newUid=$i
    break
   fi
 done
}

# 修改原来的  for ((i=1001; i<=2000; i++)) 为  for ((i=8001; i<=9000; i++))
# 8001,9000可以取值为暂时未使用的UID,可以使用id UID验证UID是否被使用,找一段未使用的UID即可

Ambari2.5.2+HDP2.6.2安装时UID错误,创建家目录错误解决_第2张图片

创建家目录问题描述

# 在服务器执行:useradd -m -u 8001 -G hadoop -g hadoop zookeeper报错

Ambari2.5.2+HDP2.6.2安装时UID错误,创建家目录错误解决_第3张图片

# 在服务器执行:mkdir /home/zookeeper报错
# 没有在/home/目录下创建文件的权限

在这里插入图片描述
Ambari2.5.2+HDP2.6.2安装时UID错误,创建家目录错误解决_第4张图片

创建家目录问题解决

cd /var/lib/ambari-server/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts
修改params.py
smoke_user_dirs中/home/{smoke_user}修改为:/var/{smoke_user}
hbase_user_dirs中/home/{hbase_user}修改为:/var/{hbase_user}

重启ambari服务

修改了ambari脚本之后,需要执行以下步骤重启ambari

  • 删除ambari-agent缓存:rm -rf /var/lib/ambari-agent/cache/
  • 重启ambari-server:ambari-server restart
  • 重启ambari-agent:ambari-agent restart

你可能感兴趣的:(Ambari)