6. [Optional] Install a Metastore Database

If you are installing Hive and HCatalog or installing Oozie, you must install a database to store metadata information in the metastore. You can either use an existing database instance or install a new instance manually. HDP supports the following databases for the metastore:

  • Postgres 8.x, 9.x

  • MySQL 5.x

  • Oracle 11g r2

  • SQL Server 2012, 2014

[Note]Note

By default, Hive uses the Derby database for the metastore. However, Derby is not supported for production systems.

The following instructions explain how to install MySQL as the metastore. See your third-party documentation for instructions on how to install other supported databases.

To install a new instance of MySQL:

  1. Connect to the host machine you plan to use for Hive and HCatalog.

  2. Install MySQL server. From a terminal window, type:

    For RHEL/CentOS/Oracle Linux:

    yum install mysql-server

    For SLES:

    zypper install mysql-server

    For Ubuntu:

    apt-get install mysql-server
  3. Start the instance.

    For RHEL/CentOS/Oracle Linux:

    /etc/init.d/mysqld start 

    For SLES:

    /etc/init.d/mysqld start

    For Ubuntu:

    /etc/init.d/mysql start

  4. Set the root user password using the following command format:

    mysqladmin -u root password $mysqlpassword

    For example, to set the password to "root":

    mysqladmin -u root password root
  5. Remove unnecessary information from log and STDOUT.

    mysqladmin -u root 2>&1 >/dev/null
  6. Now that the root password has been set, you can use the following command to log in to MySQL as root:

    mysql -u root -proot

    As root, create the “dbuser” and grant it adequate privileges. This user provides access to the Hive metastore. Use the following series of commands (shown here with the returned responses) to create "dbuser" with password "dbuser".

    [root@c6402 /]# mysql -u root -proot
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 11
    Server version: 5.1.73 Source distribution
    
    Copyright (c) 2000, 2013, 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> CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'dbuser';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'localhost';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> CREATE USER 'dbuser'@'%' IDENTIFIED BY 'dbuser';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'%';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'localhost' WITH GRANT OPTION;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'%' WITH GRANT OPTION;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql>
  7. Use the exit command to exit MySQL.

  8. You should now be able to reconnect to the database as "dbuser" using the following command:

    mysql -u dbuser -pdbuser

    After testing the "dbuser" login, use the exit command to exit MySQL.

  9. Install the MySQL connector JAR file.

    • For RHEL/CentOS/Oracle Linux:

      yum install mysql-connector-java*
    • For SLES:

      zypper install mysql-connector-java*
    • For Ubuntu:

      apt-get install mysql-connector-java*


loading table of contents...