目录
一、部署规划
二、部署版本
三、集群规划
四、MySQL安装
五、Hive安装
1、下载解压
2、配置环境变量
3、修改配置
4、metastore配置
5、下载mysql驱动包
6、初始化MYSQL
7、分发文件
8、启动metastore
9、hiveserver2配置
10、启动hiveserver2
11、连接测试
Hadoop3.*高可用集群部署参考:
https://blog.csdn.net/forest_long/article/details/128157294
软件 | 版本 |
操作系统 | CentOS Linux release 7.6.1810 (Core) |
JAVA | java version "1.8.0_131" |
Hadoop | Hadoop 3.2.1 |
Hive | Hive 3.1.2 |
hive远程模式 && hiveserver2高可用
主机 | hive-metastore组件 | hiveserver2组件 | mysql组件 |
hadoop101 | hive-metastore | hiveserver2 | mysql |
hadoop102 | hive-metastore | hiveserver2 | |
hadoop103 |
安装参考:
【大数据入门核心技术-Hive】MySQL5.7安装
create database hive;
create user "hive"@"%" identified by "Passw0rd";
grant all privileges on hive.* to "hive"@"%";
flush privileges;
下载地址:
https://downloads.apache.org/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz
tar -zxf apache-hive-3.1.2-bin.tar.gz -C /usr/local/
cd /usr/local
mv apache-hive-3.1.2-bin hive-3.1.2
/etc/profie下加入
export HIVE_HOME=/usr/local/hive-3.1.2
export PATH=$PATH:$HIVE_HOME/bin
cd $HIVE_HOME/conf
cp hive-log4j2.properties.template hive-log4j2.properties
cat > hive-env.sh << 'EOF'
export HADOOP_HOME=/usr/local/hadoop-3.2.1
export HIVE_CONF_DIR=/usr/local/hive-3.1.2/conf
export HIVE_AUX_JARS_PATH=/usr/local/hive-3.1.2/lib
EOF
创建目录
hdfs dfs -mkdir -p /apps/hive/{warehouse,tmp,logs}
hdfs dfs -chmod -R 775 /apps/hive/
cd $HIVE_HOME/conf
cat > metastore-site.xml << 'EOF'
hive.metastore.local
true
hive.exec.scratchdir
/data/bigdata/hive/tmp
hive.scratch.dir.permission
775
hive.metastore.warehouse.dir
/data/bigdata/hive/warehouse
javax.jdo.option.ConnectionURL
jdbc:mysql://hadoop101:3306/hive?createDatabaseIfNotExist=true&useSSL=false
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
javax.jdo.option.ConnectionUserName
hive
javax.jdo.option.ConnectionPassword
passwOrd
hive.metastore.uris
thrift://hadoop101:9083
EOF
hadoop102配置相同, 注意修改hive.metastore.uris地址为thrift://hadoop102:9083
mkdir -p /data/bigdata/hive/tmp
cat > hive-site.xml << 'EOF'
javax.jdo.option.ConnectionURL
jdbc:mysql://hadoop101:3306/hive?createDatabaseIfNotExist=true&useSSL=false
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
javax.jdo.option.ConnectionUserName
hive
javax.jdo.option.ConnectionPassword
yz123456
hive.querylog.location
/data/bigdata/hive/tmp
hive.exec.local.scratchdir
/data/bigdata/hive/tmp
hive.downloaded.resources.dir
/data/bigdata/hive/tmp
hive.cli.print.header
true
hive.cli.print.current.db
true
hive.server2.webui.host
127.0.0.1
hive.server2.webui.port
10002
EOF
下载mysql驱动,放到hive/lib
wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar
cp mysql-connector-java-5.1.44.jar /usr/local/hive-3.1.2/lib
执行一次即可
cd $HIVE_HOME/bin/
schematool -dbType mysql -initSchema
报错:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
guave版本不对, 解决方法, 删除低版本(hadoop或者hive), 复制高版本, 如下:
ll $HIVE_HOME/lib/guava*; ll $HADOOP_HOME/share/hadoop/common/lib/guava*
-rw-r--r-- 1 root root 2308517 Sep 27 2018 /usr/local/hive-3.1.2/lib/guava-19.0.jar
-rw-r--r-- 1 1000 1000 2747878 Jan 3 2021 /usr/local/hadoop-3.2.1/share/hadoop/common/lib/guava-27.0-jre.jar
rm -f $HIVE_HOME/lib/guava-19.0.jar
cp $HADOOP_HOME/share/hadoop/common/lib/guava-27.0-jre.jar $HIVE_HOME/lib/
scp /usr/local/hive-3.1.2 hadoop102:/usr/local
hadoop101和hadoop102都做这个操作
mkdir -pv $HIVE_HOME/logs
nohup $HIVE_HOME/bin/hive --service metastore >> $HIVE_HOME/logs/metastore.log 2>&1 &
hadoop101和hadoop102节点操作相同
配置hiveserver2-site.xml
cat > hiveserver2-site.xml << 'EOF'
hive.metastore.uris
thrift://hadoop101:9083,thrift://hadoop102:9083
hive.server2.support.dynamic.service.discovery
true
hive.server2.active.passive.ha.enable
true
hive.server2.zookeeper.namespace
hiveserver2
hive.zookeeper.quorum
hadoop101:2181,hadoop102:2181,hadoop103:2181
hive.zookeeper.client.port
2181
hive.server2.thrift.port
10001
hive.server2.thrift.bind.host
slave1
EOF
注意修改hive.server2.thrift.bind.host为本机的hostname
修改hadoop配置
在core-site.xml中加入以下配置
hadoop.proxyuser.root.hosts
*
hadoop.proxyuser.root.groups
*
hadoop.proxyuser.xxx.hosts和hadoop.proxyuser.xxx.groups,其中xxx为启动HiveServer2的用户
保存好后需要重启hadoop
stop-all.sh
start-all.sh
mkdir -pv $HIVE_HOME/logs
nohup $HIVE_HOME/bin/hive --service hiveserver2 >> $HIVE_HOME/logs/hiveserver2.log 2>&1 &
$HIVE_HOME/bin/beeline -u jdbc:hive2://hadoop101:10001
$HIVE_HOME/bin/beeline -u jdbc:hive2://hadoop102:10001