记录个 hive 的安装配置流程
安装版本:apache-hive-3.1.2-bin.tar.gz
$ tar xzvf apache-hive-3.1.2-bin.tar.gz -C /home/hadoop/local/
$ cd /home/hadoop/local/
$ ln -s apache-hive-3.1.2-bin hive
$ vim /etc/profile.d/my_env.sh
- HIVE_HOME=/home/hadoop/local/hive
- PATH=$PATH:$HIVE_HOME/bin
- export HIVE_HOME PATH
$ source /etc/profile
$ cd /home/hadoop/local/hive/lib
$ rm -rf log4j-slf4j-impl-2.10.0.jar
$ cp mysql-connector-java-8.0.11.jar /home/hadoop/local/hive/lib/
$ vim conf/hive-site.xml
- "1.0"?>
- "text/xsl" href="configuration.xsl"?>
- <configuration>
- <property>
- <name>javax.jdo.option.ConnectionURLname>
- <value>jdbc:mysql://ns1:3306/metastore?useSSL=falsevalue>
- property>
-
- <property>
- <name>javax.jdo.option.ConnectionDriverNamename>
- <value>com.mysql.cj.jdbc.Drivervalue>
- property>
-
- <property>
- <name>javax.jdo.option.ConnectionUserNamename>
- <value>rootvalue>
- property>
-
- <property>
- <name>javax.jdo.option.ConnectionPasswordname>
- <value>123456value>
- property>
-
- <property>
- <name>hive.metastore.warehouse.dirname>
- <value>/user/hive/warehousevalue>
- property>
-
- <property>
- <name>hive.metastore.schema.verificationname>
- <value>falsevalue>
- property>
-
- <property>
- <name>hive.server2.thrift.portname>
- <value>10000value>
- property>
-
- <property>
- <name>hive.server2.thrift.bind.hostname>
- <value>ns1value>
- property>
-
- <property>
- <name>hive.metastore.event.db.notification.api.authname>
- <value>falsevalue>
- property>
-
- <property>
- <name>hive.cli.print.headername>
- <value>truevalue>
- property>
-
- <property>
- <name>hive.cli.print.current.dbname>
- <value>truevalue>
- property>
- configuration>
$ cd /home/hadoop/local/hive/conf/
$ mv hive-log4j2.properties.template hive-log4j2.properties
$ vim hive-log4j2.properties
修改日志存放路径配置:
property.hive.log.dir = /home/hadoop/local/hive/logs
创建数据库:
mysql> create database metastore;
初始化:
$ cd /home/hadoop/local/hive/bin/
$ schematool -initSchema -dbType mysql -verbose
初始化后会自动在数据库中创建表:
- MySQL [metastore]> show tables;
- +-------------------------------+
- | Tables_in_metastore |
- +-------------------------------+
- | AUX_TABLE |
- | BUCKETING_COLS |
- | CDS |
- | COLUMNS_V2 |
- | COMPACTION_QUEUE |
- | COMPLETED_COMPACTIONS |
- | COMPLETED_TXN_COMPONENTS |
- | CTLGS |
- | DATABASE_PARAMS |
- | DBS |
- | DB_PRIVS |
- | DELEGATION_TOKENS |
- | FUNCS |
- | FUNC_RU |
- | GLOBAL_PRIVS |
- | HIVE_LOCKS |
- | IDXS |
- | INDEX_PARAMS |
- | I_SCHEMA |
- | KEY_CONSTRAINTS |
- | MASTER_KEYS |
- | MATERIALIZATION_REBUILD_LOCKS |
- | METASTORE_DB_PROPERTIES |
- | MIN_HISTORY_LEVEL |
- | MV_CREATION_METADATA |
- | MV_TABLES_USED |
- | NEXT_COMPACTION_QUEUE_ID |
- | NEXT_LOCK_ID |
- | NEXT_TXN_ID |
- | NEXT_WRITE_ID |
- | NOTIFICATION_LOG |
- | NOTIFICATION_SEQUENCE |
- | NUCLEUS_TABLES |
- | PARTITIONS |
- | PARTITION_EVENTS |
- | PARTITION_KEYS |
- | PARTITION_KEY_VALS |
- | PARTITION_PARAMS |
- | PART_COL_PRIVS |
- | PART_COL_STATS |
- | PART_PRIVS |
- | REPL_TXN_MAP |
- | ROLES |
- | ROLE_MAP |
- | RUNTIME_STATS |
- | SCHEMA_VERSION |
- | SDS |
- | SD_PARAMS |
- | SEQUENCE_TABLE |
- | SERDES |
- | SERDE_PARAMS |
- | SKEWED_COL_NAMES |
- | SKEWED_COL_VALUE_LOC_MAP |
- | SKEWED_STRING_LIST |
- | SKEWED_STRING_LIST_VALUES |
- | SKEWED_VALUES |
- | SORT_COLS |
- | TABLE_PARAMS |
- | TAB_COL_STATS |
- | TBLS |
- | TBL_COL_PRIVS |
- | TBL_PRIVS |
- | TXNS |
- | TXN_COMPONENTS |
- | TXN_TO_WRITE_ID |
- | TYPES |
- | TYPE_FIELDS |
- | VERSION |
- | WM_MAPPING |
- | WM_POOL |
- | WM_POOL_TO_TRIGGER |
- | WM_RESOURCEPLAN |
- | WM_TRIGGER |
- | WRITE_SET |
- +-------------------------------+
- 74 rows in set (0.00 sec)
$ hive
hive(default)> show databases;
- OK
- database_name
- default
- Time taken: 0.712 seconds, Fetched: 1 row(s)