Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

When does Ambari create the Hive schema when using an external MySQL server?

avatar
Rising Star

Ambari 2.1.2 - HDP 2.3.2

Startup of the Hive metastore fails because schema tool can't validate the the hive.VERSION table. According to this, http://docs.hortonworks.com/HDPDocuments/Ambari-2.... Ambari is supposed to create the schema automatically with an HDP stack of 2.2 (I'm assuming later versions as well)

Kris

1 ACCEPTED SOLUTION

avatar
Rising Star

Hive schema is created only if the hive schema has not already been created and is created before starting Hive Metastore.

create_schema_cmd = format("export HIVE_CONF_DIR={hive_server_conf_dir} ; " "{hive_bin}/schematool -initSchema " "-dbType {hive_metastore_db_type} " "-userName {hive_metastore_user_name} " "-passWord {hive_metastore_user_passwd!p}")

check_schema_created_cmd = as_user(format("export HIVE_CONF_DIR={hive_server_conf_dir} ; " "{hive_bin}/schematool -info " "-dbType {hive_metastore_db_type} " "-userName {hive_metastore_user_name} " "-passWord {hive_metastore_user_passwd!p}"), params.hive_user)

Execute(create_schema_cmd, not_if = check_schema_created_cmd, user = params.hive_user )

View solution in original post

4 REPLIES 4

avatar
Rising Star

Hive schema is created only if the hive schema has not already been created and is created before starting Hive Metastore.

create_schema_cmd = format("export HIVE_CONF_DIR={hive_server_conf_dir} ; " "{hive_bin}/schematool -initSchema " "-dbType {hive_metastore_db_type} " "-userName {hive_metastore_user_name} " "-passWord {hive_metastore_user_passwd!p}")

check_schema_created_cmd = as_user(format("export HIVE_CONF_DIR={hive_server_conf_dir} ; " "{hive_bin}/schematool -info " "-dbType {hive_metastore_db_type} " "-userName {hive_metastore_user_name} " "-passWord {hive_metastore_user_passwd!p}"), params.hive_user)

Execute(create_schema_cmd, not_if = check_schema_created_cmd, user = params.hive_user )

avatar
Rising Star

I now see where the agent is calling initSchema... had missed it before.

It fails when run from Ambari but succeeded when run from the cli. I'll accept an answer and drive on.

avatar

@kkaneI just installed a couple of clusters last week and Ambari created the schema in MySQL Database I specified. So, there are two possible scenarios.

1.If this is fresh cluster install, I think there is issue with permission on database, please check the same.

2. If this is upgraded cluster, you should upgrade Hive metastore as well.

avatar

Today, Ambari calls "hive.cmd --service schematool -info ...", and if that fails, it assumes that the schema isn't created, so it then calls, "hive.cmd --service schematool -initSchema ..." This works for HDP 2.0.6 and higher.

See https://github.com/apache/ambari/blob/trunk/ambari... Several internal Jiras have tracked this issue, BUG-14330, BUG-39736, BUG-17404