Hive supports access to open source MySQL and Postgres metabases.
The node where the database is installed must be in the same network segment as the cluster, so that they can access each other.
Use the open source driver package to replace the cluster's existing one. Download the open source PostgreSQL driver package postgresql-42.2.5.jar at https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.5/ and upload it to the ${BIGDATA_HOME}/third_lib/Hive directory on all MetaStore nodes.
Run the following commands on all MetaStore nodes to modify the permission on the driver package:
cd ${BIGDATA_HOME}/third_lib/Hive
chown omm:wheel postgresql-42.2.5.jar
chmod 600 postgresql-42.2.5.jar
Visit the MySQL official website at https://www.mysql.com/, choose DOWNLOADS > MySQL Community(GPL) DownLoads > Connector/J, and download the driver package of the required version.
Run the following commands on all MetaStore nodes to modify the permission on the driver package:
cd /opt/Bigdata/FusionInsight_HD_*/install/FusionInsight-Hive-*/hive-*/lib/
chown omm:wheel mysql-connector-java-*.jar
chmod 600 mysql-connector-java-*.jar
create user testuser with password 'password';
create database hivemeta owner testuser;
grant all privileges on database hivemeta to testuser;
create database hivemeta;
create user 'testuser'@'%' identified by 'password';
grant all privileges on hivemeta.* to 'testuser';
flush privileges;
Run the following command to import the SQL file to Postgres:
./bin/psql -U username -d databasename -f hive-schema-3.1.0.postgres.sql
Specifically:
./bin/psql is in the Postgres installation directory.
username indicates the username for logging in to Postgres.
databasename indicates the database name.
Run the following command to import the SQL file to the MySQL database:
./bin/mysql -u username -p password -D databasename<hive-schema-3.1.0.mysql.sql
Specifically:
./bin/mysql is in the MySQL installation directory.
username indicates the user name for logging in to MySQL.
databasename indicates the database name.
Parameter |
Default Value |
Description |
---|---|---|
javax.jdo.option.extend.ConnectionPassword |
****** |
User password for connecting to the external metadata database on Metastore. The password is encrypted in the background. |
chmod 755 /opt/Bigdata/tmp
cd Client installation directory
source bigdata_env
kinit Component service user (Skip this step for clusters with Kerberos authentication disabled.)
create table test(id int,str1 string,str2 string);
select * from TBLS;
If information about the test table is displayed, the external database is successfully deployed. For example: