hive
上传hive压缩包并解压
tar -zxvf apache-hive-3.1.2-bin.tar.gz
配置hive环境变量
vim /etc/profile
export HIVE_HOME=/opt/server/hive
export PATH=$PATH:$HIVE_HOME/bin
刷新环境变量
source /etc/profile
初始化hive
可以不做跳过使用mysql初始化
bin/schematool -dbType derby -initSchema
报错
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:518)
at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:536)
at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:430)
at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141)
at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5104)
at org.apache.hive.beeline.HiveSchemaTool.<init>(HiveSchemaTool.java:96)
at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1473)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:318)
at org.apache.hadoop.util.RunJar.main(RunJar.java:232)
将hadoop的guava-27.0-jre.jar替换hive的低版本的guava
cp /opt/server/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar /opt/server/hive/lib/
rm /opt/server/hive/lib/guava-19.0.jar
再重新初始化
启动
bin/hive
测试
show databases; //查看所有数据库
mysql
更新apt源
sudo apt update
下载
sudo apt install mysql-server
检查版本
mysql --version
查看mysql是否启动
systemctl status mysql.service
配置
进入MySQL
mysql -uroot -p123123
修改root任意网段可以访问
CREATE USER 'hive'@'%' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' WITH GRANT OPTION;
刷新权限
flush privileges;
创建存放hive元数据库
create database metastore;
上传mysql-connector-java-8.0.28.jar到hive的lib目录
配置hive文件
进入conf目录
vim hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.178.164:3306/metastore?useSSL=false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>192.168.178.164</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://master:9083</value>
</property>
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<property>
<name>hive.server2.active.passive.ha.enable</name>
<value>true</value>
</property>
</configuration>
初始化
bin/schematool -dbType mysql -initSchema
set hive.exec.mode.local.auto=true;
启动
./bin/hive --service metastore &
./bin/hive --service hiveserver2 &