大叔问题定位分享(23)Ambari安装向导点击下一步卡住

 ambari安装第一步是输入集群name,点击next时页面卡住不动,如下图:

注意到其中一个接口请求结果异常,http://ambari.server:8080/api/v1/version_definitions 重现如下:

curl -u admin:admin "http://ambari.server:8080/api/v1/version_definitions?fields=VersionDefinition/stack_default,VersionDefinition/stack_repo_update_link_exists,VersionDefinition/max_jdk,VersionDefinition/min_jdk,operating_systems/repositories/Repositories/*,operating_systems/OperatingSystems/*,VersionDefinition/stack_services,VersionDefinition/repository_version&VersionDefinition/show_available=true&VersionDefinition/stack_name=HDP&_=1547529429429"
{
"href" : "http://ambari.server:8080/api/v1/version_definitions?fields=VersionDefinition/stack_default,VersionDefinition/stack_repo_update_link_exists,VersionDefinition/max_jdk,VersionDefinition/min_jdk,operating_systems/repositories/Repositories/*,operating_systems/OperatingSystems/*,VersionDefinition/stack_services,VersionDefinition/repository_version&VersionDefinition/show_available=true&VersionDefinition/stack_name=HDP&_=1547529429429",
"items" : [ ]
}

跟进代码发现对应的js代码为:

ambari-web/app/controllers/installer.js

  /**
   * query every stack names from server
   * @return {Array}
   */
  loadStacksVersions: function () {
    var requests = [];
    const dfd = $.Deferred();
    this.get('stackNames').forEach(function (stackName) {
      requests.push(App.ajax.send({
        name: 'wizard.stacks_versions_definitions',
        sender: this,
        data: {
          stackName: stackName,
          dfd: dfd
        },
        success: 'loadStacksVersionsDefinitionsSuccessCallback',
        error: 'loadStacksVersionsErrorCallback'
      }));
    }, this);
    this.set('loadStacksRequestsCounter', requests.length);
    return dfd.promise();
  },

这段代码要访问所有的stack version,但是服务器返回空,所以一直卡住

注意到服务器启动时有一段日志:

2019-01-15 12:03:45,452 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.0 is not active, skipping VDF
2019-01-15 12:03:45,452 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.0.6 is not active, skipping VDF
2019-01-15 12:03:45,452 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.0.6.GlusterFS is not active, skipping VDF
2019-01-15 12:03:45,452 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.1 is not active, skipping VDF
2019-01-15 12:03:45,452 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.1.GlusterFS is not active, skipping VDF
2019-01-15 12:03:45,452 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.2 is not active, skipping VDF
2019-01-15 12:03:45,453 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.3 is not active, skipping VDF
2019-01-15 12:03:45,453 INFO [ambari-client-thread-44] AmbariMetaInfo:1430 - Stack HDP-2.3.ECS is not active, skipping VDF
2019-01-15 12:03:45,453 INFO [ambari-client-thread-44] AmbariMetaInfo:1428 - Stack HDP-2.3.GlusterFS is not valid, skipping VDF: The service 'OOZIE' in stack 'HDP:2.3.GlusterFS' extends a non-existent service: 'common-services/OOZIE/5.0.0.2.3'

跟进日志代码发现

org.apache.ambari.server.api.services.AmbariMetaInfo

  private synchronized void ensureVersionDefinitions() {
...
        StackId stackId = new StackId(stack);
        if (!stack.isValid()) {
          LOG.info("Stack {} is not valid, skipping VDF: {}", stackId, StringUtils.join(stack.getErrors(), "; "));
        } else if (!stack.isActive()) {
          LOG.info("Stack {} is not active, skipping VDF", stackId);
        }

这里isActive是在StackModule.populateStackInfo中赋值:

org.apache.ambari.server.stack.StackModule

  private void populateStackInfo() {
...
    StackMetainfoXml smx = stackDirectory.getMetaInfoFile();
...
      stackInfo.setActive(smx.getVersion().isActive());

可以看到isActive取值自StackMetainfoXml

org.apache.ambari.server.state.stack.StackMetainfoXml

这个类对应的metainfo.xml为

/var/lib/ambari-server/resources/stacks/HDP/$version/metainfo.xml 

cat /var/lib/ambari-server/resources/stacks/HDP/2.6/metainfo.xml

<metainfo>

  <versions>

    <active>false</active>

  </versions>

  <extends>2.5</extends>

  <minJdk>1.7</minJdk>

  <maxJdk>1.8</maxJdk>

</metainfo>

查看metainfo.xml发现安装完成之后各个版本的metainfo.xml中active默认都是false;

将active改为true,然后重启ambari-server,如果重启之后解决问题,那么恭喜你,如果还有问题请继续看:

尝试手工注册vdf

curl -v -k -u admin:admin -H "X-Requested-By:ambari" -X POST http://ambari.server:8080/api/v1/version_definitions -d '{"VersionDefinition": {"version_url":"http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos7/2.x/BUILDS/2.6.5.0-292/HDP-2.6.5.0-292.xml"}}'

各个版本的vdf可以在这里找到:http://s3.amazonaws.com/dev.hortonworks.com/HDP/hdp_urlinfo.json

 

终于见到stack选择页面

 

posted @ 2019-01-15 18:57  匠人先生  阅读(2566)  评论(1编辑  收藏  举报