Install hive in Ubuntu, install and configure MySQL, and use the MySQL database as hive metadata

Install hive in Ubuntu, install and configure MySQL, and use the MySQL database as hive metadata

The following are the specific steps:

  1. Install MySQL

    Enter the following command in the terminal to install MySQL:

    sudo apt-get update
    sudo apt-get install mysql-server
    

    During the installation process, you will be prompted to set the MySQL root user password, please set it according to the prompt.

  2. Create hive metadata database

    Enter the following command in the terminal to log in to MySQL:

    mysql -u root -p
    

    Then enter the root user password you set to log in to MySQL.

    Next, enter the following command on the MySQL command line to create the hive metadata database:

    CREATE DATABASE hive_metastore;
    
  3. Create hive metadata user

    Enter the following command on the MySQL command line to create a hive metadata user:

    CREATE USER 'hiveuser'@'localhost' IDENTIFIED BY 'password';
    

    where 'hiveuser' is the username you want to create and 'password' is the password for that user.

  4. Authorize hive metadata users

    Enter the following command on the MySQL command line to authorize the hive metadata user to access the hive metadata database:

    GRANT ALL PRIVILEGES ON hive_metastore.* TO 'hiveuser'@'localhost';
    
  5. Configure the hive-site.xml file

    Open the hive-site.xml file and add the following configuration:

    <property>
      <name>javax.jdo.option.ConnectionURL</name>
      <value>jdbc:mysql://localhost/hive_metastore?createDatabaseIfNotExist=true</value>
    </property>
    <property>
      <name>javax.jdo.option.ConnectionDriverName</name>
      <value>com.mysql.jdbc.Driver</value>
    </property>
    <property>
      <name>javax.jdo.option.ConnectionUserName</name>
      <value>hiveuser</value>
    </property>
    <property>
      <name>javax.jdo.option.ConnectionPassword</name>
      <value>password</value>
    </property>
    

    where 'hiveuser' and 'password' are the username and password of the hive metadata user you created in step 3, respectively.

  6. Restart the hive service

    Enter the following command in the terminal to restart the hive service:

    sudo systemctl restart hive-server2
    

    Then, you can use MySQL as the metadata database of hive.

Hope these steps can help you install and configure MySQL as hive metadata.

Guess you like

Origin blog.csdn.net/ccbbaaap/article/details/130657914