赞
踩
相关文件材料
链接:https://pan.baidu.com/s/17240ITPR14vcRku6_P0kug?pwd=me15
提取码:me15
1、用下面命令解压文件并赋予权限
sudo tar -zxvf ./apache-hive-3.1.2-bin.tar.gz -C /usr/local # 解压到/usr/local中
cd /usr/local/
sudo mv apache-hive-3.1.2-bin hive # 将文件夹名改为hive
sudo chown -R dblab:dblab hive # 修改文件权限
2、用下面这个命令配置hive-default.xml文件,可以顺便设置远程连接
cd /usr/local/hive/conf
mv hive-default.xml.template hive-default.xml
3、在hive-default.xml配置如下内容
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <!-- JDBC配置 -->
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&userSSL=false</value>
- <description>JDBC连接字符串,用于连接JDBC元存储</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionDriverName</name>
- <value>com.mysql.jdbc.Driver</value>
- <description>JDBC元存储的驱动类名</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionUserName</name>
- <value>hive</value>
- <description>用于连接元存储数据库的用户名</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionPassword</name>
- <value>hive</value>
- <description>用于连接元存储数据库的密码</description>
- </property>
- <property>
- <name>hive.metastore.warehouse.dir</name>
- <value>/usr/local/hadoop/tmp/dfs/data</value>
- <description>Hive元数据仓库目录</description>
- </property>
-
- <!-- Hive元数据配置 -->
- <property>
- <name>hive.metastore.schema.verification</name>
- <value>false</value>
- <description>是否验证Hive元数据模式</description>
- </property>
- <property>
- <name>hive.metastore.event.db.notification.api.auth</name>
- <value>false</value>
- <description>是否启用Hive元数据事件通知API身份验证</description>
- </property>
- <property>
- <name>hive.cli.print.header</name>
- <value>true</value>
- <description>是否在CLI中打印表头</description>
- </property>
- <property>
- <name>hive.cli.print.current.db</name>
- <value>true</value>
- <description>是否在CLI中打印当前数据库</description>
- </property>
- <property>
- <name>datanucleus.schema.autoCreateAll</name>
- <value>true</value>
- <description>是否自动创建所有DataNucleus模式</description>
- </property>
- <property>
- <name>hive.metastore.uris</name>
- <value>thrift://localhost:9083</value>
- <description>Hive元数据服务URI</description>
- </property>
-
- <!-- Hive执行引擎配置 -->
- <property>
- <name>hive.execution.engine</name>
- <value>mr</value>
- <description>Hive执行引擎</description>
- </property>
-
- <!-- 连接超时时间配置 -->
- <property>
- <name>hive.spark.client.connect.timeout</name>
- <value>300000ms</value>
- <description>Hive Spark客户端连接超时时间</description>
- </property>
- <property>
- <name>hive.spark.client.server.connect.timeout</name>
- <value>300000ms</value>
- <description>Hive Spark客户端与服务器连接超时时间</description>
- </property>
-
- <!-- HiveServer2配置 -->
- <property>
- <name>hive.server2.thrift.port</name>
- <value>10000</value>
- <description>HiveServer2的Thrift端口号</description>
- </property>
- <property>
- <name>hive.server2.thrift.http.port</name>
- <value>10001</value>
- <description>HiveServer2的Thrift HTTP端口号</description>
- </property>
- <property>
- <name>metastore.catalog.default</name>
- <value>hive</value>
- <description>默认的元存储目录</description>
- </property>
- <property>
- <name>hive.server2.thrift.bind.host</name>
- <value>0.0.0.0</value>
- <description>HiveServer2的Thrift绑定主机</description>
- </property>
- <property>
- <name>hive.server2.thrift.client.user</name>
- <value>hadoop</value>
- <description>用于Thrift客户端的用户名</description>
- </property>
- <property>
- <name>hive.server2.thrift.client.password</name>
- <value>123456</value>
- <description>用于Thrift客户端的密码</description>
- </property>
-
- <!-- 其他配置 -->
- <property>
- <name>hive.support.concurrency</name>
- <value>true</value>
- <description>是否支持并发</description>
- </property>
- <property>
- <name>hive.enforce.bucketing</name>
- <value>true</value>
- <description>是否强制执行分桶</description>
- </property>
- <property>
- <name>hive.exec.dynamic.partition.mode</name>
- <value>nonstrict</value>
- <description>Hive动态分区模式</description>
- </property>
- <property>
- <name>hive.txn.manager</name>
- <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
- <description>Hive事务管理器</description>
- </property>
- <property>
- <name>hive.compactor.initiator.on</name>
- <value>true</value>
- <description>是否启用Hive压缩器初始化</description>
- </property>
- <property>
- <name>hive.compactor.worker.threads</name>
- <value>1</value>
- <description>Hive压缩器工作线程数</description>
- </property>
- <property>
- <name>hive.metastore.disallow.incompatible.col.type.changes</name>
- <value>false</value>
- <description>是否禁止不兼容列类型更改</description>
- </property>
- </configuration>

4、安装mysql作为元数据存储库
sudo apt-get update #更新软件源
sudo apt-get install mysql-server #安装mysql
5、把这个mysql的jar包解压到目录下
tar -zxvf mysql-connector-java-5.1.40.tar.gz #解压
cp mysql-connector-java-5.1.40/mysql-connector-java-5.1.40-bin.jar /usr/local/hive/lib #将mysql-connector-java-5.1.40-bin.jar拷贝到/usr/local/hive/lib目录下
6、登录mysql,创建hive数据库并赋予权限
create database hive;
grant all on *.* to hive@localhost identified by 'hive';#将所有数据库的所有表的所有权限赋给hive用户,后面的hive是配置hive-site.xml中配置的连接密码
flush privileges; #刷新mysql系统权限关系表
7、启动hive
cd /usr/local/hadoop #进入Hadoop安装目录
./sbin/start-dfs.sh
cd /usr/local/hive
./bin/hive
8、可能出现的错误及解决方法
启动Hive过程中,可能出现的错误和解决方案如下:
【错误1】
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument
【原因】
com.google.common.base.Preconditions.checkArgument 这是因为hive内依赖的guava.jar和hadoop内的版本不一致造成的。
【解决方法】
1.查看hadoop安装目录下share/hadoop/common/lib内guava.jar版本
2.查看hive安装目录下lib内guava.jar的版本 如果两者不一致,删除版本低的,并拷贝高版本的 问题解决!
【错误2】org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : “VERSION” in Catalog “” Schema “”. DataNucleus requires this table to perform its persistence operations.
【解决方案】
进入hive安装目录(比如/usr/local/hive),执行如下命令:./bin/schematool -dbType mysql -initSchema
9、到hive的bin的目录下执行下面命令
hive --service metastore
hive --service hiveserver2 #需要出现四个id
netstat -ntulp |grep 10000#查看hive是不是
在beeline下连接,如果可以就可以用其他工具连接了。账户密码都可以默认空
!connect jdbc:hive2://localhost:10000
可以了,
下一篇spark
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。