Config inconsistency exists: unknown configType=kafka-broker

本文解决在Ambari中卸载Kafka时遇到的配置不一致错误,通过手动更新数据库删除残留配置组,确保服务完全卸载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ambari卸载kafka 出现上述错误

查看日志tail -100 /var/log/ambari-server/ambari-server.log 

ERROR [ambari-client-thread-29533] HostImpl:1084 - Config inconsistency exists: unknown configType=kafka-broker

问题梳理

  • 错误: 已经在ambari-server中将hbase服务删除掉,出现该错误怀疑上次删除完关闭ambari-server时,没有来得及更新数据库导致的,所以需要手动变更数据库才能解决;

源码解析

定位到异常错误的地方,在HostImpl中,看到如下的代码:

@Override
  public Map<String, HostConfig> getDesiredHostConfigs(Cluster cluster,
      Map<String, DesiredConfig> clusterDesiredConfigs) throws AmbariException {
    Map<String, HostConfig> hostConfigMap = new HashMap<String, HostConfig>();

    if( null == cluster ){
      clusterDesiredConfigs = new HashMap<String, DesiredConfig>();
    }

    // per method contract, fetch if not supplied
    if (null == clusterDesiredConfigs) {
      clusterDesiredConfigs = cluster.getDesiredConfigs();
    }

    if (clusterDesiredConfigs != null) {
      for (Map.Entry<String, DesiredConfig> desiredConfigEntry
          : clusterDesiredConfigs.entrySet()) {
        HostConfig hostConfig = new HostConfig();
        hostConfig.setDefaultVersionTag(desiredConfigEntry.getValue().getTag());
        hostConfigMap.put(desiredConfigEntry.getKey(), hostConfig);
      }
    }
    
    // 怀疑是这里`cluster.getConfigGroupsByHostname(getHostName())`引入了没有删除的数据
    Map<Long, ConfigGroup> configGroups = (cluster == null) ? new HashMap<Long, ConfigGroup>() : cluster.getConfigGroupsByHostname(getHostName());

    if (configGroups != null && !configGroups.isEmpty()) {
      for (ConfigGroup configGroup : configGroups.values()) {
        for (Map.Entry<String, Config> configEntry : configGroup
            .getConfigurations().entrySet()) {

          String configType = configEntry.getKey();
          // HostConfig config holds configType -> versionTag, per config group
          HostConfig hostConfig = hostConfigMap.get(configType);
          if (hostConfig == null) {
            hostConfig = new HostConfig();
            hostConfigMap.put(configType, hostConfig);
            if (cluster != null) {
              Config conf = cluster.getDesiredConfigByType(configType);
              if(conf == null) {
              //报错出现在这个地方,说明该config已经被清理,但是循环还是走到了这里!
                LOG.error("Config inconsistency exists:"+
                    " unknown configType="+configType);
              } else {
                hostConfig.setDefaultVersionTag(conf.getTag());
              }
            }
          }
          Config config = configEntry.getValue();
          hostConfig.getConfigGroupOverrides().put(configGroup.getId(),
              config.getTag());
        }
      }
    }
    return hostConfigMap;
  }

在ambari中,同数据库的连接是基于jpa完成的,找到ClusterEntity下的configGroupEntities定义,可以看出ClusterEntity同ConfigGroupEntity之间的关系,

  @OneToMany(mappedBy = "clusterEntity", cascade = CascadeType.ALL)
  private Collection<ConfigGroupEntity> configGroupEntities;

ConfigGroupEnity中,可以发现其依赖一下两个表:

  @OneToMany(mappedBy = "configGroupEntity", cascade = CascadeType.ALL)
  private Collection<ConfigGroupHostMappingEntity> configGroupHostMappingEntities;

  @OneToMany(mappedBy = "configGroupEntity", cascade = CascadeType.ALL)
  private Collection<ConfigGroupConfigMappingEntity> configGroupConfigMappingEntities;

在数据库中找到如下对应关系,定位到问题:

mysql> use ambari
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from configgroup;
+----------+------------+------------+-------+----------------------------------------------------+------------------+--------------+
| group_id | cluster_id | group_name | tag   | description                                        | create_timestamp | service_name |
+----------+------------+------------+-------+----------------------------------------------------+------------------+--------------+
|        2 |          2 | test01     | KAFKA | New configuration group created on Wed Jan 08 2020 |    1578470900704 | KAFKA        |
|        3 |          2 | test02     | KAFKA | New configuration group created on Wed Jan 08 2020 |    1578470900782 | KAFKA        |
|        4 |          2 | test05     | KAFKA | New configuration group created on Wed Jan 08 2020 |    1578470900843 | KAFKA        |
+----------+------------+------------+-------+----------------------------------------------------+------------------+--------------+
3 rows in set (0.01 sec)

mysql> delete  from configgroup;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`ambari`.`configgrouphostmapping`, CONSTRAINT `FK_cghm_cgid` FOREIGN KEY (`config_group_id`) REFERENCES `configgroup` (`group_id`))
mysql> SET FOREIGN_KEY_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)

mysql> delete  from configgroup;
Query OK, 3 rows affected (0.00 sec)

mysql> SET FOREIGN_KEY_CHECKS=1;
Query OK, 0 rows affected (0.00 sec)

mysql> delete  from configgrouphostmapping;
Query OK, 3 rows affected (0.07 sec)

重启ambari-server restart

再次安装就可以了

ref:https://www.jianshu.com/p/40b534b0843a

这是什么情况:(new_env) C:\Users\23221>conda install -n base mamba -c conda-forge -y Collecting package metadata (current_repodata.json): done Solving environment: | The environment is inconsistent, please check the package plan carefully The following packages are causing the inconsistency: - defaults/win-64::anaconda-client==1.9.0=py39haa95532_0 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64::anaconda==custom=py39_1 - defaults/win-64::anaconda-navigator==2.1.4=py39haa95532_0 - defaults/noarch::anaconda-project==0.10.2=pyhd3eb1b0_0 - defaults/win-64::astroid==2.6.6=py39haa95532_0 - defaults/noarch::backports.functools_lru_cache==1.6.4=pyhd3eb1b0_0 - defaults/win-64::bcrypt==3.2.0=py39h196d8e1_0 - defaults/win-64::bokeh==2.4.2=py39haa95532_0 - defaults/win-64::clyent==1.2.2=py39haa95532_1 - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64::conda==22.9.0=py39haa95532_0 - defaults/win-64::conda-build==3.21.8=py39haa95532_2 - defaults/noarch::conda-pack==0.6.0=pyhd3eb1b0_0 - defaults/noarch::conda-repo-cli==1.0.4=pyhd3eb1b0_0 - defaults/noarch::conda-token==0.3.0=pyhd3eb1b0_0 - defaults/noarch::conda-verify==3.4.2=py_1 - defaults/noarch::cookiecutter==1.7.3=pyhd3eb1b0_0 - defaults/noarch::dask==2022.2.1=pyhd3eb1b0_0 - defaults/noarch::datashader==0.13.0=pyhd3eb1b0_1 - defaults/noarch::distributed==2022.2.1=pyhd3eb1b0_0 - defaults/noarch::flake8==3.9.2=pyhd3eb1b0_0 - defaults/noarch::flask==1.1.2=pyhd3eb1b0_0 - defaults/win-64::gensim==4.1.2=py39hd77b12b_0 - defaults/noarch::google-api-core==1.25.1=pyhd3eb1b0_0 - defaults/noarch::google-auth==1.33.0=pyhd3eb1b0_0 - defaults/noarch::google-cloud-core==1.7.1=pyhd3eb1b0_0 - defaults/noarch::google-cloud-storage==1.31.0=py_0 - defaults/noarch::holoviews==1.14.8=pyhd3eb1b0_0 - defaults/noarch::hvplot==0.7.3=pyhd3eb1b0_1 - defaults/noarch::intake==0.6.5=pyhd3eb1b0_0 - defaults/win-64::ipykernel==6.9.1=py39haa95532_0 - defaults/win-64::ipytho
最新发布
03-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值