参考:
CDH 5.1.5(parcels)集群中hive1.1.0升级到hive-1.2.1步骤全,升级hive元数据库,数据不丢失(亲测可用)
操作步骤:
下载hive-1.2.1-bin
解压:
[root@node01 ~]# cd /opt/software/
[root@node01 software]# ls
apache-hive-1.2.1-bin.tar.gz cloudera-manager-centos7-cm5.14.2_x86_64.tar.gz jdk-8u231-linux-x64.tar.gz maxwell-1.22.1.tar.gz
apache-phoenix-4.14.0-cdh5.14.2-bin.tar.gz flink-1.9.1-cdh-5.14.2.tar.gz kafka-manager-1.3.1.6.zip mysql-connector-java.jar
[root@node01 software]# tar -zxf apache-hive-1.2.1-bin.tar.gz -C /opt/module/
[root@node01 software]# cd /opt/module/
[root@node01 module]# mv apache-hive-1.2.1-bin hive-1.2.1
[root@node01 module]# cd hive-1.2.1/
将hive-1.2.1中的lib复制到cdh中hive的lib121目录下
[root@node01 hive]# cd /opt/cloudera/parcels/CDH/lib/hive
[root@node01 hive]# mkdir lib121
[root@node01 hive]# cp /opt/module/hive-1.2.1/lib/* lib121/
修改cdh中hive启动文件中的hive-lib配置
[root@node01 bin]# pwd
/opt/cloudera/parcels/CDH/lib/hive/bin
[root@node01 bin]# vi hive
......
HIVE_LIB=${HIVE_HOME}/lib121
......
Coudera 界面停止Hive服务,如果安装了Hue,Ozzie,Impala先停掉再停掉Hive
所有节点更新hadoop上jline jar包,并删除老的jlien jar包
[root@node01 lib121]# ln -s /opt/cloudera/parcels/CDH/lib/hive/lib121/jline-2.12.jar /opt/cloudera/parcels/CDH/lib/hadoop-yarn/lib/jline-2.12.jar
[root@node01 lib121]# cd /opt/cloudera/parcels/CDH/lib/hadoop-yarn/lib/
[root@node01 lib]# ls
activation-1.1.jar commons-lang-2.6.jar jackson-xc-1.8.8.jar jersey-server-1.9.jar log4j-1.2.17.jar
aopalliance-1.0.jar commons-logging-1.1.3.jar javax.inject-1.jar jettison-1.1.jar protobuf-java-2.5.0.jar
asm-3.2.jar guava-11.0.2.jar jaxb-api-2.2.2.jar jetty-6.1.26.cloudera.4.jar servlet-api-2.5.jar
commons-cli-1.2.jar guice-3.0.jar jaxb-impl-2.2.3-1.jar jetty-util-6.1.26.cloudera.4.jar spark-1.6.0-cdh5.14.2-yarn-shuffle.jar
commons-codec-1.4.jar guice-servlet-3.0.jar jersey-client-1.9.jar jline-2.11.jar spark-yarn-shuffle.jar
commons-collections-3.2.2.jar jackson-core-asl-1.8.8.jar jersey-core-1.9.jar jline-2.12.jar stax-api-1.0-2.jar
commons-compress-1.4.1.jar jackson-jaxrs-1.8.8.jar jersey-guice-1.9.jar jsr305-3.0.0.jar xz-1.0.jar
commons-io-2.4.jar jackson-mapper-asl-1.8.8.jar jersey-json-1.9.jar leveldbjni-all-1.8.jar zookeeper.jar
[root@node01 lib]# mv /opt/cloudera/parcels/CDH/lib/hadoop-yarn/lib/jline-2.11.jar /opt/cloudera/parcels/CDH/lib/hadoop-yarn/lib/jline-2.11.jar.bak
分发到所有节点,更改所属用户、用户组
chown -R cloudera-scm:cloudera-scm /opt/cloudera
在元数据存储所在节点备份MySQL中hive元数据库:
[root@node02 ~]# mysqldump -uroot -hnode02 -p metastore > metastore110.sql
执行升级脚本:
[root@node02 hive-1.2.1]# cd /opt/module/hive-1.2.1/scripts/metastore/upgrade/mysql/
[root@node02 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28-log MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use metastore;
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> source upgrade-0.13.0-to-0.14.0.mysql.sql;
+--------------------------------------------------+
| |
+--------------------------------------------------+
| Upgrading MetaStore schema from 0.13.0 to 0.14.0 |
+--------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.01 sec)
ERROR 1061 (42000): Duplicate key name 'PCS_STATS_IDX'
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
+-----------------------------------------------------------+
| |
+-----------------------------------------------------------+
| Finished upgrading MetaStore schema from 0.13.0 to 0.14.0 |
+-----------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> source upgrade-0.14.0-to-1.1.0.mysql.sql;
+-------------------------------------------------+
| |
+-------------------------------------------------+
| Upgrading MetaStore schema from 0.14.0 to 1.1.0 |
+-------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
+----------------------------------------------------------+
| |
+----------------------------------------------------------+
| Finished upgrading MetaStore schema from 0.14.0 to 1.1.0 |
+----------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> source upgrade-1.1.0-to-1.2.0.mysql.sql;
+------------------------------------------------+
| |
+------------------------------------------------+
| Upgrading MetaStore schema from 1.1.0 to 1.2.0 |
+------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
+---------------------------------------------------------+
| |
+---------------------------------------------------------+
| Finished upgrading MetaStore schema from 1.1.0 to 1.2.0 |
+---------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
在cloudera 管理界面启动Hive服务
查看升级后的版本:
[root@node01 module]# hive --version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Hive 1.2.1
Subversion git://localhost.localdomain/home/sush/dev/hive.git -r 243e7c1ac39cb7ac8b65c5bc6988f5cc3162f558
Compiled by sush on Fri Jun 19 02:03:48 PDT 2015
From source with checksum ab480aca41b24a9c3751b8c023338231
查看数据是否与升级之前一致:
[root@node01 module]# hive
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Logging initialized using configuration in jar:file:/opt/cloudera/parcels/CDH-5.14.2-1.cdh5.14.2.p0.3/lib/hive/lib121/hive-common-1.2.1.jar!/hive-log4j.properties
hive> show databases;
OK
default
test_myq
Time taken: 1.969 seconds, Fetched: 2 row(s)
hive> use test_myq;
OK
Time taken: 0.046 seconds
hive> show tables;
OK
mytable
test
Time taken: 0.093 seconds, Fetched: 2 row(s)
hive> select * from mytable;
OK
Time taken: 0.502 seconds
hive> select * from test;
OK
mort 6.66
zane 5.55
Time taken: 0.113 seconds, Fetched: 2 row(s)