安装hive的前提是先安装hadoop集群,并且hive只需要在hadoop的namenode节点中安装即可,可以不在datanode节点的机器上安装,启动hive的前提是需要hadoop在正常跑着
rpm -qa|grep mariadb
rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
yum -y install libaio
yum -y install net-tools
tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar.tar -C /soft/modlue
rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm(依赖于common, client)
mysqld --initialize
/var/lib
下。更改mysql数据库所属于用户及其所属于组:chown mysql:mysql /var/lib/mysql -R
systemctl start mysqld.service
grep ‘password‘ mysqld.log
mysql -u root -p
输入刚才获取的初始密码set password=password(‘123456789‘);
flush privileges;
Your password does not satisfy the current policy requirements.
set global validate_password_policy=0;
set global validate_password_length=4;
(最少4位)grant all privileges on *.* to banana@‘%‘ identified by ‘123456789‘ with grant option;
(最好手打命令,拷贝老出错)下载hive:https://downloads.apache.org/hive/
hadoop2.9.2 + hive-2.3.6
Hive的运行模式
依据Hive的安装和metastore的设置机器,分为下面三个模式:
嵌入模式:使用自带的derby数据库
本地模式:将metastore放在mysql,并且mysql和hive安装在同一台机器上
远程模式:将metastore放在mysql,并且mysql和hive安装在不同一台机器上
tar -zxvf apache-hive-2.3.6-bin.tar.gz -C /soft/module/
mv apache-hive-2.3.6-bin hive
sudo vim /etc/profile
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
# 配置 HADOOP_HOME 路径
export HADOOP_HOME=/soft/module/hadoop-2.9.2
# 配置 HIVE_CONF_DIR 路径
export HIVE_CONF_DIR=/soft/module/hive/conf
export HIVE_AUX_JARS_PATH=/soft/module/hive/lib
sbin/start-dfs.sh
sbin/start-yarn.sh
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive</value>
所以要在集群上新建目录
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
cp mysql-connector-java-5.1.48.jar /soft/module/hive/lib/
vim hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!--将该name对应的value修改为MySQL的地址-->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop100:3306/metastore?createDatabaseIfNotExist=true&characterEncoding=UTF-8&useSSL=false</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<!--将该name对应的value修改为MySQL驱动类路径:-->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<!--将对应的value修改为MySQL数据库登录名-->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>username to use against metastore database</description>
</property>
<!--将对应的value修改为MySQL数据库的登录密码-->
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456789</value>
<description>password to use against metastore database</description>
</property>
</configuration>
2.1 第三步和第四步不做行吗??? 或者加上下面的???(我自己没做3,4步就好使)
<property>
<name>system:java.io.tmpdir</name>
<value>/soft/module/hive/tmpdir</value>
</property>
<property>
<name>system:user.name</name>
<value>root</value>
</property>
${system:java.io.tmpdir}
替换为hive的临时目录,例如我替换为/soft/module/hive/tmp/
,该目录如果不存在则要自己手工创建,并且赋予读写权限。${system:user.name}
都替换为root
https://www.jianshu.com/p/7b1b21bf05c2
1、关闭防火墙
2、开启 mysql外链权限
3、jar包冲突,删除hive下
4、配置hive-site.xml
cd $HIVE_HOME/bin
schematool -initSchema -dbType mysql
cd $HIVE_HOME/bin
进入Hive的bin目录./hive
执行hive启动show functions;
desc function sum;
show databases;
create database test_db;
use test_db;
show tables;
create table student(id int,name string) row format delimited fields terminated by ‘\t‘;
load data local inpath ‘/soft/module/hive/student.txt‘ into table student;
insert into student values(1000,"ss");
ps -ef|grep hive
来看hive 的端口号,然后kill 掉相关的进程。hive --service metastore &
hive --service hiveserver2 &
nohup hive --service metastore 2>&1 &
nohup hive --service hiveserver2 2>&1 &
bin/hive
hive> show databases;
hive> use default;
hive> show tables;
hive> create table student(id int, name string);
hive> show tables;
hive> desc student;
hive> insert into student values(1000,"ss");
hive> select * from student;
hive> quit;
truncate table student;
hadoop fs -put student.txt /user/hive/warehouse/test_db.db/student
load data local inpath ‘/soft/module/hive/student.txt‘ into table student;
load data inpath ‘hdfs路径(user/...)‘ into table student;
vim core-site.xml
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
分发文件
/soft/module/hive/bin/hive --service hiveserver2 &
(在native的namenode启动)nohup:ignoring input and appending output to ‘nohup.out‘
cat nohup.out
RunJar进程
或在UI界面查看-jar包配置
- 挑选必须的jar包,编辑成自己的lib配置到工程中(推荐)
其实所有jar包都在${HIVE_HOME}/lib目录下,这里列示下需要的jar包名:
${HADOOP_HOME}/share/hadoop/common/hadoop-common-2.2.0.jar(mr工程中已存在,无需再次添加,如果新建项目需配置
$ { HIVE_HOME } /lib/hive-exec-0.11.0.jar
$ { HIVE_HOME } /lib/hive-jdbc-0.11.0.jar
$ { HIVE_HOME } /lib/hive-metastore-0.11.0.jar
$ { HIVE_HOME } /lib/hive-service-0.11.0.jar
$ { HIVE_HOME } /lib/libfb303-0.9.0.jar
$ { HIVE_HOME } /lib/commons-logging-1.0.4.jar (此jar包已经存在就不要再次添加)
$ { HIVE_HOME } /lib/slf4j-api-1.6.1.jar(此jar包已经存在就不要再次添加)
- 导入jar包
- 修改pom.xml配置文件(不推荐,会下载额外很多无用包,而且时间很长在1小时左右)
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>2.3.6</version>
</dependency>
<property>
<name>hadoop.proxyuser.banana.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.banana.hosts</name>
<value>*</value>
</property>
core-site.xml
两天了!!!!!!!!!!./bin/schematool -initSchema -dbType mysql
命令失败
参考链接: https://blog.csdn.net/liuzhuang2017/article/details/82051112
原因: select user,host,authentication_string from user;
修改root用户权限 update user set host=‘%‘ where user=‘root‘;
flush privileges;
配置文件错误
Thu Mar 19 19:17:33 CST 2020 WARN: Establishing SSL connection without server‘s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn‘t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false‘. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
<value>jdbc:mysql://hadoop100:3306/metastore?createDatabaseIfNotExist=true&useSSL=false</value>
平时的&
在xml里为&
原文:https://www.cnblogs.com/Hephaestus/p/12531634.html