TDH 5.x/6.x元数据初始化脚本优化

  使用配置, 其他常见问题
内容纲要

概要描述


TDH 5.x及TDH 6.x版本使用默认元数据(metastore)启动脚本时,在特殊场景下可能会导致Inceptor模块不能正常工作。

详细说明


对于TDH 5.x版本或者TDH 6.x版本用户,可以参照如下方法优化初始化脚本。

示例环境说明:

  • Shell示例环境为TDH 6.0.2,Inceptor镜像ID为 8f992d1a4482
  • 截图示例环境为TDH 5.2.2,Inceptor镜像ID为 13e505811aef

一、修改镜像里面的初始化脚本


1、打开Manager Web界面,确定 Inceptor Server 节点信息。

可参见 如何进入某一组件的Docker容器 第2步,确定Inceptor Server节点服务器信息。

2、找出 Inceptor 镜像

SSH登录Inceptor Server服务器,运行命令 docker images |grep inceptor 找出inceptor的镜像,例如:

[root@bryan1 ~]# docker images|grep inceptor
bryan1:5000/transwarp/inceptor-gateway     transwarp-6.0.2-final     31f3c9e82d90        6 months ago        1.27GB
bryan1:5000/transwarp/inceptor             transwarp-6.0.2-final     8f992d1a4482        6 months ago        3.84GB
[root@bryan1 ~]#
//Inceptor镜像为8f992d1a4482

file

3、利用Inceptor镜像构建一个Inceptor的bash终端

命令 docker run -ti *image_id* bash ,例如:

[root@bryan1 ~]# docker run -ti 8f992d1a4482 bash
[root@12c4a4a616a1 ~]#
//12c4a4a616a1为容器ID(Container ID)

file

4、找出最新版的元数据初始化脚本

命令 ls -v /usr/lib/hive/scripts/metastore/scripts/upgrade/mysql/hive-schema-0.12* |tail -n 1,例如:

[root@12c4a4a616a1 ~]# ls -v /usr/lib/hive/scripts/metastore/scripts/upgrade/mysql/hive-schema-0.12.* |tail -n 1
/usr/lib/hive/scripts/metastore/scripts/upgrade/mysql/hive-schema-0.12.39.mysql.sql
[root@12c4a4a616a1 ~]#
//文件 /usr/lib/hive/scripts/metastore/scripts/upgrade/mysql/hive-schema-0.12.39.mysql.sql 为最新的元数据初始化脚本

file

5、修改此最新的脚本文件

查找并注释掉第一个sql的drop table if exists 这一行:DROP TABLE IF EXISTS APPS;
注释方法为在最前面加上两个中横线+空格, “– ”,请注意‘– ’(双破折号)注释风格要求第2个破折号后面至少跟一个空格符,例如:

[root@12c4a4a616a1 ~]# vi /usr/lib/hive/scripts/metastore/scripts/upgrade/mysql/hive-schema-0.12.39.mysql.sql
//原内容如下(不含双引号):
“DROP TABLE IF EXISTS APPS;”
//在改行前面添加“-- ”,将其注释掉后,如下(不含双引号):
“-- DROP TABLE IF EXISTS APPS;”

file

//查看里面内容,找到要注释的行,如下图:

file

//注释掉第一个sql的drop table if exists 这一行,修改之后如下图;

file

二、发布成新的镜像


1、发布成新的镜像

保持inceptor container终端是登录状态(保持在第一步的Inceptor容器12c4a4a616a1内),然后另开一个服务器终端;
备份Inceptor镜像,并把修改后的inceptor container commit成一个新的inceptor镜像,命令:docker commit container_id registry:image_tag ,例如:

[root@bryan1 ~]# docker images |grep inceptor
bryan1:5000/transwarp/inceptor-gateway     transwarp-6.0.2-final                   31f3c9e82d90        6 months ago        1.27GB
bryan1:5000/transwarp/inceptor             transwarp-6.0.2-final                   8f992d1a4482        6 months ago        3.84GB
//查看现有Inceptor镜像
[root@bryan1 ~]# docker tag 8f992d1a4482 bryan1:5000/transwarp/inceptor:transwarp-6.0.2-final_Original_Backup
//备份Inceptor镜像为transwarp-6.0.2-final_Original_Backup
[root@bryan1 ~]# docker images |grep inceptor
bryan1:5000/transwarp/inceptor-gateway     transwarp-6.0.2-final                   31f3c9e82d90        6 months ago        1.27GB
bryan1:5000/transwarp/inceptor             transwarp-6.0.2-final                   8f992d1a4482        6 months ago        3.84GB
bryan1:5000/transwarp/inceptor             transwarp-6.0.2-final_Original_Backup   8f992d1a4482        6 months ago        3.84GB
//已经备份成功,Image ID为8f992d1a4482
[root@bryan1 ~]# docker commit 12c4a4a616a1 bryan1:5000/transwarp/inceptor:transwarp-6.0.2-final
sha256:4dcadd1fdf19d139e9d32764b76960718633a3cc250f83117771ef076271a675
//Commit Inceptor容器12c4a4a616a1为新的镜像
[root@bryan1 ~]# docker images |grep inceptor
bryan1:5000/transwarp/inceptor             transwarp-6.0.2-final                   4dcadd1fdf19        2 minutes ago       3.84GB
bryan1:5000/transwarp/inceptor-gateway     transwarp-6.0.2-final                   31f3c9e82d90        6 months ago        1.27GB
bryan1:5000/transwarp/inceptor             transwarp-6.0.2-final_Original_Backup   8f992d1a4482        6 months ago        3.84GB
[root@bryan1 ~]#
//生成了新的Inceptor镜像,Image ID为4dcadd1fdf19

//下列截图的环境为TDH 5.2.2,命令:docker commit d0d72312c1a9 tdh-01:5000/transwarp/inceptor:transwarp-5.2.2-final

file

Commit之后docker images可以看到一个创建时间(created)最新的inceptor的镜像:

file

三、Push新生成的Inceptor镜像到仓库

将新生成的Inceptor镜像push到镜像仓库,命令:docker push registry:image_tag,例如:

[root@bryan1 ~]# docker push bryan1:5000/transwarp/inceptor:transwarp-6.0.2-final
The push refers to repository [bryan1:5000/transwarp/inceptor]
f3f3deaef5d3: Preparing
0a8df00060fb: Preparing
65946bd96a67: Preparing
851ba2eba064: Preparing
784c1ac51dc2: Preparing
c4b1fedaa498: Waiting
......
transwarp-6.0.2-final: digest: sha256:f88233931a2c7e9d8bb83e6e554f735f715eba9e2aa22b6533e174a358e8eb80 size: 15580
[root@bryan1 ~]#
//Push成功

下图对应的命令:docker push tdh-01:5000/transwarp/inceptor:transwarp-5.2.2-final

file

四、重启Inceptor验证


1、在Manager页面,重启Inceptor组件服务;
  • TDH 5.x,无重启快捷菜单,需要先停止,等停止后,再启动:

file

  • TDH 6.x,直接点击重启菜单重启即可:

file

2、在Inceptor的安装节点上,找到inceptor-server的container,然后进入container;

可以参考KB:如何进入某一组件的Docker容器

3、查看第一步中修改的初始化脚本是否生效;

这篇文章对您有帮助吗?

平均评分 4.7 / 5. 次数: 3

尚无评价,您可以第一个评哦!

非常抱歉,这篇文章对您没有帮助.

烦请您告诉我们您的建议与意见,以便我们改进,谢谢您。