Support Questions
Find answers, ask questions, and share your expertise

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

Contributor

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

Accepted Solutions

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

Contributor

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

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

Contributor

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

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

Contributor

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.

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

@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.

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

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