たごもりすメモ

コードとかその他の話とか。

CDH4.2(Hive 0.10)のmetastoreは CDH4.1.x (Hive 0.9) 以前と互換性がなかった件

hiveserver が /tmp 下に消されると困るファイルを置く問題、hive 0.10に上げれば直るらしい! と思ったのでうっかり yum update hadoop hive したら Hive 0.10 のmetastoreが Hive 0.9 と非互換なので動かなくなりました。
CDH4.1.x使ってる人はいま yum update すると CDH 4.2 が容赦なくインストールされるので超危険です。気をつけましょう。

ドキュメントを改めて確認にいったらひっそりと書いてありました。

There are no incompatible changes for Hive between CDH4.0 and CDH4.2.0

Redirecting...

えー?

こちらのblog postによると非互換だと言うんですが。Impalaの話だけど、hive metasotreの話。コメント欄にClouderaの人が出てきてる。

Hi,
The problem is that the Hive metastore schema is not backwards compatible
between Hive v0.9 and Hive v0.10. The deployment script needs to be updated
to change:
SOURCE
/usr/lib/hive/scripts/metastore/upgrade/mysql/hive-schema-0.9.0.mysql.sql;
To:
SOURCE
/usr/lib/hive/scripts/metastore/upgrade/mysql/hive-schema-0.10.0.mysql.sql;

We will get the blog updated, thanks for letting us know!

Thanks,
Lenni
Software Engineer - Cloudera

Impala EC2 set up instructions no longer working - Grokbase

っていうか非互換じゃなかったら動いてるだろ常識的に考えて。

ちなみにやっちゃうと以下のようなエラーが出ます。

2013-03-05 12:51:05,069 ERROR hive.log (MetaStoreUtils.java:logAndThrowMetaException(832)) - MetaException(message:javax.jdo.JDODataStoreException: Required table missing : "`SKEWED_STRING_LIST`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
NestedThrowables: org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : "`SKEWED_STRING_LIST`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables")
        at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.get_tables(HiveMetaStore.java:2342)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

設定では datanucleus.autoCreateTables は有効になってるんですけどね。

これを修正するためのSQLが /usr/lib/hive/scripts/metastore/upgrade 以下にあったので、自分はMySQL使ってたからとりあえず実行してみました。

$ mysql -h DBSERVER -u HIVEUSER DBNAME < /usr/lib/hive/scripts/metastore/upgrade/mysql/upgrade-0.9.0-to-0.10.0.mysql.sql

実行後に metastore の内容がぶっこわれました。show tables でテーブル一覧は見えるのに show partitions を実行するとそんなテーブルは無いと言われ、またスキーマも正常に見えなくなりました……。

しょうがないので現在、hive warehouse を別のパスに設定しなおし metastore を初期化して create table を実行後にLOAD祭中。いやはや。

まとめ

誰か追試タノム

追記(3/5 15:45)

結論としては「非互換性はある、CDH4.2に上げたらHive起動前にmetastoreのupgrade作業をやれ」ということのようです。

ここのページ の "Step 4: Upgrade the Metastore Schema" に書いてあった。

The current version of CDH4 includes changes in the Hive metastore schema. If you have been using Hive 0.9 or earlier, you must upgrade the Hive metastore schema after you install the new version of Hive but before you start Hive. To do this, run the appropriate schema upgrade scripts in /usr/lib/hive/scripts/metastore/upgrade/:

Schema upgrade scripts from 0.7 to 0.8 and from 0.8 to 0.9 for Derby, MySQL, and PostgreSQL
0.8 and 0.9 schema scripts for Oracle, but no upgrade scripts (you will need to create your own)
Schema upgrade scripts from 0.9 to 0.10 for Derby, MySQL, PostgreSQL and Oracle

Important
・Cloudera strongly encourages you to make a backup copy of your metastore database before running the upgrade scripts. You will need this backup copy if you run into problems during the upgrade or need to downgrade to a previous version.
You must upgrade the metastore schema before starting Hive. Failure to do so may result in metastore corruption.
・To run a script, you must first cd to the directory that script is in: that is /usr/lib/hive/scripts/metastore/upgrade/.

Redirecting...

これのどこが非互換無しだ……。

ということで、サブ用のクラスタで以下の作業をやった。

# cd /usr/lib/hive/scripts/metastore/upgrade/mysql
mysql]# /usr/local/mysql/bin/mysql cdh4metastoretest < upgrade-0.9.0-to-0.10.0.mysql.sql 

Upgrading MetaStore schema from 0.9.0 to 0.10.0

< HIVE-3072 Skewed Table DDL >

< HIVE-3649: Support stored as directories >

< HIVE-1362 Column Statistics Support in Hive >

Finished upgrading MetaStore schema from 0.9.0 to 0.10.0

無事テーブル一覧もパーティション一覧も見られました。やれやれ。

追記 (3/6)

Clouderaのページの記述が修正されましたね。

CDH4.2.0 upgrades Hive to version 0.10. This requires a schema upgrade.

The following table shows the Hive version changes over the past several CDH releases, and indicates those that require a schema upgrade.

(....)

This means that all upgrades from CDH3 to CDH4x, and from CDH4.x to CDH4.2, require a schema upgrade.

Redirecting...

たいへんわかりやすくなったので、ここを見にさえ来てればOKという感じになっているんではないかと思います。*1

*1:自分の感覚としては yum update して即座に再起動したらぶっこわれるようなものを同一パッケージ名で配らないでほしいなー、という気はしますが。