Hive-2.3.4 installation (upgrade from Hive-1.2.2)

Keywords: hive MySQL JDBC Apache

Download Hive installation package from website

Modify hive-site.xml (version 2.3.4 does not have this file to create directly)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
	<property>
	    	<name>javax.jdo.option.ConnectionDriverName</name>
	    	<value>com.mysql.jdbc.Driver</value>
 	</property>
  	<property>
    		<name>javax.jdo.option.ConnectionURL</name>
    		<value>jdbc:mysql://SZ01:3306/hive?createDatabaseIfNotExist=true</value>
  	</property>
  	<property>
    		<name>javax.jdo.option.ConnectionUserName</name>
    		<value>root</value>
  	</property>
  	<property>
    		<name>javax.jdo.option.ConnectionPassword</name>
    		<value>root</value>
  	</property>
  	<!-- 
  		<property>  
  			<name>hive.hwi.war.file</name>  
  			<value>lib/hive-hwi-1.2.2.war</value>
		</property>
	-->
	
    <property>
                <name>hive.metastore.schema.verification</name>
                <value>false</value>
    </property>
	<property> 
   		 <name>hive.cli.print.current.db</name>
		 <value>true</value>
	</property>
	<property> 
	         <name>hive.cli.print.header</name>
	         <value>true</value>
	</property>
	
	<property>
       		 <name>hive.server2.thrift.port</name>
     		 <value>10010</value>
	</property>

    	<property>
       		<name>hive.server2.thrift.bind.host</name>
       		<value>SZ01</value>
     	</property>

</configuration>

It is normal to start hive, but this error is displayed when show databases. It is obvious that the metabase is not initialized (because I have installed version 1.2.2, and there is a hive metabase in MySQL, so I need to delete this database when upgrading)
hive (default)> show databases; FAILED: SemanticException org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
Initialization: schematool -dbType mysql -initSchema
This error occurred after initialization

org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
Underlying cause: java.lang.ClassNotFoundException : com.mysql.jdbc.Driver

I didn't put the jdbc connection jar package of mysql into the lib directory
Continue initialization

Error: Duplicate entry '1' for key 'PRIMARY' (state=23000,code=1062)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
Underlying cause: java.io.IOException : Schema script failed, errorcode 2

This is that I did not delete the metabase hive after upgrading hive
Continue initialization

Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed

Initialization succeeded!!!

Posted by ryadex on Tue, 03 Dec 2019 14:14:21 -0800