赞
踩
3、修改$HIVE_HOME/conf/hive-site.xml
hive的初步安装在博客中有写道,不做重复撰写了。
[root@hadoop001 software]# mkdir mysql
[root@hadoop001 mysql]# yum install -y numactl libaio
[root@hadoop001 mysql]# rpm -ivh mysql-community-common-8.0.19-1.el7.x86_64.rpm
[root@hadoop001 mysql]# rpm -ivh mysql-community-libs-8.0.19-1.el7.x86_64.rpm
[root@hadoop001 mysql]# rpm -ivh mysql-community-client-8.0.19-1.el7.x86_64.rpm
[root@hadoop001 mysql]# rpm -ivh mysql-community-server-8.0.19-1.el7.x86_64.rpm
[root@hadoop001 mysql]# systemctl start mysqld.service
[root@hadoop001 mysql]# systemctl status mysqld.service
[root@hadoop001 mysql]# grep 'temporary password' /var/log/mysqld.log
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你自己的密码';
ALTER USER 'root'@'localhost' IDENTIFIED BY '你自己的密码' PASSWORD EXPIRE NEVER;
update mysql.user set host='%' where user='root';
flush privileges;
[root@hadoop001 lib]# rm -f mysql-connector-java-5.1.46.jar
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.88.140:3306/metastore?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT%2B8</value>
<description>连接协议</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
<description>JDBC连接驱动</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>用户名</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>本人mysql密码</value>
<description>密码</description>
</property>
<!-- Hive 元数据存储版本的验证 -->
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<!--元数据存储授权 -->
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<!-- Hive 默认在 HDFS 的工作目录 -->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
</configuration>
[root@hadoop001 lib]# schematool -initSchema -dbType mysql -verbose
启动集群
[root@hadoop001 lib]# start-dfs.sh
[root@hadoop001 lib]# start-yarn.sh
启动hive
create table test (name string);
insert into test values('john');
select * from test;
[root@hadoop001 bin]# vi hive-script.sh
[root@hadoop001 bin]# sed -i "s/\r//" hive-script.sh
[root@hadoop001 bin]# chmod +x hive-script.sh
[root@hadoop001 bin]# hive-script.sh start
hiveserver2服务启动异常
添加下列信息
(Hive hiveserver2 监听端口10000异常 启动失败 - 夏天换上冬装 - 博客园 (cnblogs.com))
重启hdfs
[root@hadoop001 bin]# hive-script.sh start
[root@hadoop001 bin]# beeline -u 'jdbc:hive2://hadoop001:10000' -n root
Hive需要在启动了hadoop集群、yarn之后启动,不然会连接不上。
配置文件书写有误,hive是不能输入指令的。下面贴一下完整的文件内容
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.88.140:3306/metastore?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT%2B8</value>
<description>连接协议</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
<description>JDBC连接驱动</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>用户名</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>JJ12315kk.</value>
<description>密码</description>
</property>
<!-- Hive 元数据存储版本的验证 -->
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<!--元数据存储授权 -->
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
<!-- Hive 默认在 HDFS 的工作目录 -->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<!-- 指定存储元数据要连接的地址 -->
<property>
<name>hive.metastore.uris</name>
<value>thrift://hadoop001:9083</value>
</property>
<!-- 这是hiveserver2 -->
<!-- 指定 hiveserver2 连接的 host -->
<property>
<name>hive.server2.thrift.bind.host</name>
<value>hadoop001</value>
</property>
<!-- 指定 hiveserver2 连接的端口号 -->
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<!--beeline错误需要添加信息-->
<property>
<name>hive.server2.active.passive.ha.enable</name>
<value>true</value>
<description>Whether HiveServer2 Active/Passive High Availability be enabled when Hive Interactive sessions are enabled.This will also require hive.server2.support.dynamic.service.discovery to be enabled.</description>
</property>
</configuration>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。