Hive安装
软件需求与环境说明
- 假设已经搭建好 Hadoop-2.6.0 环境,并能正常运行
- mysql 安装软件 服务端:MySQL-server-5.5.16-1.rhel5.x86_64.rpm 客户端:MySQL-client-5.5.16-1.rhel5.x86_64.rpm
- hive安装软件:apache-hive-1.2.1-bin.tar.gz
- Java 连接 MySQL 驱动软件: mysql-connector-java-5.1.17-bin.jar
安装mysql
- 使用 rpm -ivh MySQL-server-5.5.16-1.rhel5.x86_64.rpm 安装服务端
- 使用 rpm -ivh MySQL-client-5.5.16-1.rhel5.x86_64.rpm 安装客户端
- 在命令行界面输入 mysql 命令,进入 MySQL 界面,新增 hive 用户,并赋予权限,以后 Hive 就使用该用户登录 MySQL
create database hive;
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' IDENTIFIED BY 'hadoop01' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'localhost' IDENTIFIED BY 'hadoop01' WITH GRANT OPTION;
flush privileges;
alter database hive character set latin1;
- 使用 hive 登录 MySQL: mysql -u hive -p; 注意:如果已经安装mysql需要先卸载,需要修改root密码再进行操作,具体见mysql安装笔记
安装Hive
- 把 apache-hive-1.2.1-bin.tar 解压至 /home/cluster 目录下,并重命名为 hive
- 把 mysql-connector-java-5.1.17-bin.jar 拷贝到 /home/cluster/hive/lib 目录下
- 配置环境变量或者hive-env.sh
export HIVE_HOME=/home/cluster/hive
export PATH=$HIVE_HOME/bin:$PATH
- hive-site.xml
<!-- hive表的默认存储路径 -->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<!--mysql远程存储metastore配置-->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.56.13/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hadoop01</value>
</property>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>false</value>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
- hive命令行下,set javax.jdo.option.ConnectionURL 检查是否是连接到 mysql
hive客户端安装
hive服务端安装好之后,服务端如何连接使用? * 服务端需要启动hive metastore服务,客户端才能远程使用hive元信息
代码语言:javascript复制hive --service metastore -p <port_num>
- 如果不加端口默认启动:hive –service metastore,则默认监听端口是:9083
- 客户端hive-site.xml配置
<!-- thrift://<host_name>:<port> 默认端口是9083 -->
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.56.10:9083</value>
<description>Thrift uri for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>
<property>
<name>hive.metastore.client.socket.timeout</name>
<value>3600</value>
</property>
<!-- hive表的默认存储路径 -->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
喜欢 (1)or分享 (0)