Hive安装
1.1下载Hive安装包
官网:http://hive.apache.org/downloads.html
个人建议到这里下载:http://apache.forsale.plus/
1.2将hive文件上传到HADOOP集群,并解压
将文件上传到 /usr ,解压
tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /usr/
重命名: mv /usr/apache-hive-1.2.1-bin /usr/hive
1.3配置环境变量
编辑/ect/profile
#set hive env
export HIVE_HOME=/export/servers/hive
export PATH=${HIVE_HOME}/bin:$PATH
#让环境变量生效
source /etc/profile
1.4修改hive配置文件hive/conf/
进入配置文件的目录
cd /usr/hive/conf/
修改hive-env.sh文件
cp hive-env.sh.template hive-env.sh
将以下内容写入到hive-env.sh文件中
export JAVA_HOME=/export/servers/jdk
export HADOOP_HOME=/export/servers/hadoop
export HIVE_HOME=/export/servers/hive
修改log4j文件
cp hive-log4j.properties.template hive-log4j.properties
将EventCounter修改成org.apache.hadoop.log.metrics.EventCounter
#log4j.appender.EventCounter=org.apache.hadoop.hive.shims.HiveEventCounter
log4j.appender.EventCounter=org.apache.hadoop.log.metrics.EventCounter
1.5配置远程登陆模式
创建hive-site.xml文件
touch hive-site.xml
将以下信息写入到hive-site.xml文件中
<configuration> <property> <name>hive.metastore.warehouse.dir</name> <value>/usr/hive-1.2.2/warehouse</value> </property>
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://hadoop02:3306/hivedb?createDatabaseIfNotExist=true</value> //红色字体为你的hive主机名 </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>root</value> //database user name
</property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>password</value> //database password </property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
</configuration>
1.6安装MySQL并配置数据库及权限
安装MySQL数据库及客户端
yum install mysql-server
yum install mysql
service mysqld start //开启服务
# mysql -u root mysql
mysql>use mysql;
mysql>desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "password"; //为root添加远程连接的能力。
mysql>update user set Password = password('xxxxxx') where User='root';
mysql>select Host,User,Password from user where User='root';
mysql>flush privileges;
mysql>exit;
重新登陆: mysql -u root -p 检查是否安装完成。
把mysql-connector-java-5.1.28.jar下载放到hive的lib目录
执行 schematool -dbType mysql -initSchema
1.7启动
启动hive之前先启动HA集群
3启动yarn start-yarn.sh 或者 start-all.sh //同时把集群和yarn开启
利用 jps 检查namenode是否正常开启,没有的话需要手动单点启动: hadoop-daemon.sh start namenode
4.开数据库服务:
service mysqld start
service mysqld start //检查服务状态
5.开启hive
运行hive命令即可启动hive
1.8测试
show databases;
1.9参考官网
https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin
二.HIVE安装报错解决方案
1、执行 schemaTool -dbType mysql -initSchema 如果报错Terminal initialization failed; falling back to unsupported
将/export/servers/hive/lib 里面的jline2.12替换了hadoop 中/export/servers/hadoop/hadoop-2.6.1/share/hadoop/yarn/lib/jline-0.09*.jar
这个问题的报错是因为你在执行apache-hive-1.2.2-bin版本的时候,抛出的异常,解决方案是把该hive版本的lib下面的jline-2.12.jar拷贝到/usr/hadoop/share/hdoop/yarn/lib里面,然后把yarn里面的lib的jlne-0.09.jar包给改个名字即可。
重新启动hive即可。
2、登录SQL权限问题
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
flush privileges;
3、 java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
解决方案:
schemaTool -dbType mysql -initSchema
4,WARN: Establishing SSL connection without server’s identity verification is not recommended
Sun Aug 23 13:39:14 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.
解决方案:
1.设置useSSL=false
这里有个坑就是hive的配置文件是.XML
格式,而在xml文件中&;
才表示&
,所以正确的做法是在Hive的配置文件中,如hive-site.xml
进行如下设置
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hivedb?createDatabaseIfNotExist=true&
useSSL=false</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>