一,将Mysql驱动包拷贝到lib目录下 (hive客户端会同时连接mysql数据库和HDFS)
二,将其他的安装包传到softwore目录下
1°、解压Hive文件:
重命名,配置环境变量/etc/profile.d/bigdata.sh
export HIVE_HOME=/opt/hive
export PATH=$PATH:$HIVE_HOME/bin
source /etc/profile.d/bigdata.sh
进入$HIVE_HOME/conf/修改文件
cp hive-env.sh.template hive-env.sh
cp hive-default.xml.template hive-site.xml
2°、修改$HIVE_HOME/conf的hive-env.sh,增加以下三行
export JAVA_HOME=/opt/jdk
export HADOOP_HOME=/opt/hadoop
export HIVE_HOME=/opt/hive
3°、修改$HIVE_HOME/conf/hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node01:3306/hive?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8</value>
</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>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
<property>
<name>hive.querylog.location</name>
<value>/opt/hive/tmp</value>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/opt/hive/tmp</value>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/opt/hive/tmp</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>192.168.1.40</value>
<description>Bind host on which to run the HiveServer2 Thrift service.</description>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
<description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is ‘binary’.</description>
</property>
4°、初始化hive元数据仓库
可以简写为:schematool -initSchema -dbType mysql
5°、启动hive
opt]# hive或者用beeline启动连接
注意:如果日志太多,解决办法:
1.在 Hive 安装目录的 conf 目录下创建出 log4j.properties 日志配置文件
2.添加如下内容:
log4j.rootLogger=ERROR, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
3.然后exit退出hive再重新进入
三,查看下10000端口是否开启,如果没有则开启
1、firewalld的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
3.配置firewalld-cmd
查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
那怎么开启一个端口呢
添加:firewall-cmd --zone=public --add-port=80/tcp --permanent
(--permanent永久生效,没有此参数重启后失效)
重新载入:firewall-cmd --reload
查看:firewall-cmd --zone= public --query-port=80/tcp
删除:firewall-cmd --zone= public --remove-port=80/tcp --permanent
四,运行,在/opt/hive/bin下./hiveserver2 或者nohup hive --service hiveserver2 &
然后查看10000端口启动没 netstat -anp | grep 10000
如果出现10000端口开启,那就完美一半了
五,因为在配置文件里设置的hive.server2.authentication参数值为NONE,表示不用输入密码
所以直接 beeline -u jdbc:hive2://192.168.1.40:10000 -n hdfs
本机虚拟机连接方式:beeline -u jdbc:hive2://192.168.8.101:10000 -n root
注意:如果报错User:root 不能连之类的错,就把hadoop代理那个改了
六,注意
①如果提示
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...
这个问题其实不影响你的程序的使用。这个错误是因为新版本(5.5.45)之后要求连接mysql时是否使用SSL连接,一般设置不使用(false)即可,更改hive-site.xml里的元数据注册里useSSL=false就行
jdbc:mysql://node01:3306/hive239?createDatabaseIfNotExist=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8
主要功能:
1)认证用户服务器确保数据发送确客户机服务器;
2)加密数据防止数据途窃取;
3)维护数据完整性确保数据传输程改变;
②如果报错:The reference to entity “useUnicode“ must end with the ‘;‘ delimiter.
这是由xml文件中的编码规则决定要这么变换。在xml文件中有以下几类字符要进行转义替换:
< | < | 小于号 |
---|---|---|
> | > | 大于号 |
& | & | 和 |
' | ’ | 单引号 |
" | " | 双引号 |
jdbc:mysql://node01:3306/hive?createDatabaseIfNotExist=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8
③报错:User: root is not allowed to impersonate anony mous (state=,code=0)
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
④beeline连接hiveserver2时报错:beeline Required field 'client_protocol' is unset
解决:
进入hive/bin目录,使用 ./beeline -u jdbc:hive2://node01:10000 -n root