上传安装包 解压
tar zxvf apache-hive-3.1.2-bin.tar.gz mv apache-hive-3.1.2-bin hive
解决Hive与Hadoop之间guava版本差异
cd /export/software/hive/ rm -rf lib/guava-19.0.jar cp cp /export/software/hadoop/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar /export/software/hive/lib
修改配置文件
hive-env.sh
cd /export/software/hive/conf mv hive-env.sh.template hive-env.sh vim hive-env.sh export HADOOP_HOME=/export/software/hadoop/hadoop-3.3.0 export HIVE_CONF_DIR=/export/software/hive/conf export HIVE_AUX_JARS_PATH=/export/software/hive/lib
hive-site.xml
vim hive-site.xml
javax.jdo.option.ConnectionURL jdbc:mysql://node1:3306/metastore?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8 javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver javax.jdo.option.ConnectionUserName root javax.jdo.option.ConnectionPassword 123456 hive.server2.thrift.bind.host node1 hive.metastore.uris thrift://node1:9083 hive.metastore.event.db.notification.api.auth false hive.metastore.warehouse.dir /user/hive/warehouse
上传mysql jdbc驱动到hive安装包lib下
mysql-connector-java-5.1.32.jar
初始化元数据
cd /export/software/hive bin/schematool -initSchema -dbType mysql -verbos #初始化成功会在mysql中创建74张表
在hdfs创建hive存储目录(如存在则不用操作)
hadoop fs -mkdir /tmp hadoop fs -mkdir -p /user/hive/warehouse hadoop fs -chmod g+w /tmp hadoop fs -chmod g+w /user/hive/warehouse
1)启动 Hive
# 启动metastore服务 [root@node1 hive]$ bin/hive --service metastore & [root@node1 hive]$ bin/hive
2)使用 Hive
hive> show databases; hive> show tables; hive> create table test (id int); hive> insert into test values(1); hive> select * from test;