- 解压hive安装包
Tar -zxvf apache-hive-2.1.1-bin.tar.gz -
安装mysql,使用yum命令自动安装
将mysql的connector到hive的lib目录下
启动MySQL,service mysqld start
修改mysql密码:
Mysql -u root
Use mysql;
Update user set password=password(‘newpass’) where user=’root’;
Flush privileges;
Grant all privileges . to ‘root’%’ identified by ‘newpass’ with grant optiomn;
FLUSH PRIVILEGES;
- 配置环境变量
Vim /etc/profile
HIVE
export HIVE_HOME=/home/zhouwang/apache-hive-2.1.1-bin
export HIVE_CONF_HOME=$HIVE_HOME/conf
export PATH=:$PATH:$HIVE_HOME/bin
- 配置hive,conf/hive-site.xml
进入conf目录,将原有的文件重命名
cp hive-env.sh.template hive-env.sh
cp hive-default.xml.template hive-site.xml
cp hive-log4j2.properties.template hive-log4j2.properties
cp hive-exec-log4j2.properties.template hive-exec-log4j2.properties
修改的hive-site.xml
- hive.downloaded.resources.dir
- hive.server2.logging.operation.log.location
- javax.jdo.option.ConnectionURL=>jdbc:mysql://192.168.56.101:3306/hive?createDatabaseIfNotExist=true
- javax.jdo.option.ConnectionDriverName=>com.mysql.jdbc.Driver
- javax.jdo.option.ConnectionUserName
- javax.jdo.option.ConnectionPassword
- hive.metastore.schema.verification=>false
- hive.metastore.warehouse.dir=>/user/hive/warehouse
- hive.server2.thrift.port=>10000(默认有可能冲突)
- hive.metastore.uris=>thrift://node1:9083
- hive.querylog.location=>/user/hive/log
- hive.exec.scratchdir=>/user/hive/tmp
hive.metastore.schema.verification
hive.metastore.uris 这两个参数是配置远程matestore的,要启动hiveserver2必须要配置此参数
将所有${system:user.name}替换为自己的用户名XX,将所有${system:java.io.tmpdir}替换为/zhouwang/apache-hive-2.1.1-bin/tmp
- 修改hive-env.sh
加入
export HADOOP_HOME=/home/zhouwang/hadoop-2.7.4
export HIVE_CONF_DIR=/home/zhouwang/apache-hive-2.1.1/conf
export HIVE_AUX_JARS_PATH=/home/zhouwangl/apache-hive-2.1.1/lib
- 使用Hadoop新建hdfs目录
Hadoop fs -mkdir -p /user/hive/warehouse
Hadoop fs -mkdir -p /user/hive/tmp
Hadoop fs -mkdir -p /user/hive/log
Hadoop fs -chmod -R 777 /user/hive
- 对mysql数据库机型初始化
Schematool -initSchema -dbType mysql - 启动远程服务
Hive --service metastore &
Hive –service hiveserver2 &
- 所遇问题
Beeline连接hiveserver2的时候出现java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User zhouwang is not allowed to impersonate anonymous.
需要在hadoop配置文件core-site.xml中加入如下配置项:
hadoop.proxyuser.zhouwang.hosts
*
hadoop.proxyuser.zhouwang.groups
*
Hadoop.proxyuser.zhouwang.hosts配置项名称中zhouwang部分为报错User中的用户名部分.