Ubuntu 16.04 configure hive mysql db metadata

    The default metadata database derby used by hive is not very useful. The first is that multitasking is not supported, and the second is to configure hive environment variables and then start hive because derby's data file path problem often reports errors.

    A small prerequisite for configuring hive is that the Hadoop environment has been configured ok and hfs is available. Refer to its official quick start. The main configuration file for hive configuration is hive-site.conf.

1. Copy a copy from the default xml.

cp hive-default.xml.template hive-site.xml

2. Ubuntu installs mysql, if mysql is already installed, skip this step.

sudo apt install mysql-server mysql-client

During the execution of the command, there will be a dialog box asking you to enter the password of the mysql account root. Enter twice in a row to complete the configuration of the mysql root account password.

To be precise, the root account should not be provided directly as the application account for the general mysql database. All need to create a new account for hive to use. One is unsafe, just like linux services generally create a new user group to provide services; the other is that if the number of db connections in the generation environment is full, mysql will reserve a connection for root for database management. This function will not work if it is also used by normal applications.

3. Modify the hive-site.xml file in 4 places one by one as follows.


<property>  
    <name>javax.jdo.option.ConnectionURL</name>  
    <value>jdbc:mysql://localhost:3306/hive</value>  
    <description>JDBC connect string for a JDBC metastore</description>  
  </property>  


<property>  
    <name>javax.jdo.option.ConnectionDriverName</name>  
    <value>com.mysql.jdbc.Driver</value>  
    <description>Driver class name for a JDBC metastore</description>  
  </property>  

<property>  
    <name>javax.jdo.option.ConnectionUserName</name>  
    <value>root</value>  
    <description>Username to use against metastore database</description>  
  </property>  


<property>  
    <name>javax.jdo.option.ConnectionPassword</name>  
    <value>root</value>  
    <description>password to use against metastore database</description>  
  </property>  

 

4. Enter mysql from the command line. Create a db configured behind connectionUrl and add createDatabaseIfNoExist. But it doesn't work, so I created it manually.

5. The init schema is required before hive is executed, and hdfs needs to be started before hive is started.

schematool -dbType mysql -initSchema

6. Start the hive command, and you will be prompted that the mysql jar package cannot be found. Go to mvnrepository to download a jar package and put it under lib. The mysql jar package used by the author of hive2 version is 5.1. Add the jar package to start ok.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324910930&siteId=291194637