<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:derby:;databaseName=/usr/local/hive-1.2.1/metastore/metastore_db;create=true</value> <description> JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=truefor postgres database. </description> </property>
$ hive Logging initialized using configuration in file:/usr/local/hive-1.2.1/conf/hive-log4j.properties hive> show databases; OK default Time taken: 0.993 seconds, Fetched: 1 row(s)
postgres=# help You are using psql, the command-line interface to PostgreSQL. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit postgres=#
# "local" is for Unix domain socket connections only #localallall peer localallall trust # IPv4 local connections: #host allall127.0.0.1/32 md5 host allall127.0.0.1/32 trust # IPv6 local connections: #host allall ::1/128 md5 host allall ::1/128 trust # Allow replication connections from localhost, by a user with the # replication privilege. #local replication all peer #local replication all peer #local replication all peer local replication all trust host replication all127.0.0.1/32 trust host replication all ::1/128 trust
4.3 在PostpreSQL中创建数据库和用户
先创建一个名为hiveuser的用户,密码:123456,
然后创建一个名为metastore的数据库:
1 2 3 4
$ sudo -u postgres psql
postgres=# CREATE USER hiveuser WITH PASSWORD '123456'; postgres=# CREATE DATABASE metastore;
测试用户和数据库是否能登录
1
$ psql -h localhost -U hiveuser -d pymetastore
登录成功说明配置完成
1 2 3 4 5 6 7
hadoop@Master:~$ psql -h localhost -U hiveuser -d metastore Password for user hive: psql (10.8 (Ubuntu 10.8-0ubuntu0.18.04.1)) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help"for help.
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:postgresql://localhost/metastore</value> <description> JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=truefor postgres database. </description> </property>
<property> <name>javax.jdo.option.ConnectionDriverName</name> <value>org.postgresql.Driver</value> <description>Driver classnamefor a JDBC metastore</description> </property>
<property> <name>javax.jdo.option.ConnectionUserName</name> <value>hiveuser</value> <description>Username to use against metastore database</description> </property>
<property> <name>javax.jdo.option.ConnectionPassword</name> <value>123456</value> <description>passwordto use against metastore database</description> </property>
hadoop@Master:~$ hive SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/bigdata/hive-1.2.1/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/bigdata/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is oftype [org.apache.logging.slf4j.Log4jLoggerFactory] Logging initialized using configuration in file:/usr/local/bigdata/hive-1.2.1/conf/hive-log4j2.properties Async:true Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/bigdata/hadoop-2.7.7/lib/native/libhadoop.sowhichmighthavedisabledstackguard. TheVMwilltrytofixthestackguardnow. It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'. Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases. hive> > show databases; OK default Time taken: 12.294 seconds, Fetched: 1 row(s) hive> create table t1( > id int > ,name string > ,hobby array<string> > ,add map<String,string> > ) > row format delimited > fields terminated by ',' > collection items terminated by '-' > map keys terminated by ':' > ; OK Time taken: 1.239 seconds hive> Connection reset by 192.168.233.200 port 22
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/metastore?useSSL=true</value> <description> JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=truefor postgres database. </description> </property>
<property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver classnamefor a JDBC metastore</description> </property>
<property> <name>javax.jdo.option.ConnectionUserName</name> <value>hiveuser</value> <description>Username to use against metastore database</description> </property>
<property> <name>javax.jdo.option.ConnectionPassword</name> <value>123456</value> <description>passwordto use against metastore database</description> </property>