Hive安装和使用


Hive安装和使用

文章插图
 
参考资料:Hive3.1.2安装指南_厦大数据库实验室博客
Hive学习(一) 安装 环境:CentOS 7 + Hadoop3.2 + Hive3.1 - 一个人、一座城 - 博客园
1.安装hive1.1下载地址hive镜像路径
http://www.Apache.org/dyn/closer.cgi/hive 或者 https://mirrors.bfsu.edu.cn/apache/hive/hive-3.1.2/
wget https://mirrors.bfsu.edu.cn/apache/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz .1.2.解压到安装路径tar -zxvf ./apache-hive-3.1.2-bin.tar.gz -C/usr/localcd/usr/localsudo mv apache-hive-3.1.2-bin hive1.3.设置hive路径vi ~/.bash_profileexport HIVE_HOME=/usr/local/hiveexport HIVE_CONF_DIR=${HIVE_HOME}/confexport PATH=$PATH:$HIVE_HOME/binsource ~/.bash_profile1.4.修改/usr/local/hive/conf下的hive-site.xmlcd /usr/local/hive/confmv hive-default.xml.template hive-default.xmlvim hive-site.xml<configuration><property><name>JAVAx.jdo.option.ConnectionURL</name><value>jdbc:MySQL://localhost:3306/hive?createDatabaseIfNotExist=true&useSSL=false</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>hiveMhxzKhl88!</value></property><!--hive工作的hdfs临时存储空间--><property><name>hive.exec.scratchdir</name><value>/tmp/hive</value></property><!--hive工作的本地临时存储空间--><property><name>hive.exec.local.scratchdir</name><value>/home/xxx/hive/tmp</value></property><!--如果启用了日志功能,则存储操作日志的顶级目录--><property><name>hive.server2.logging.operation.log.location</name><value>home/xxx/hive/tmp/operation_logs</value></property><!--Hive运行时结构化日志文件的位置--><property><name>hive.querylog.location</name><value>/home/xxx/hive/tmp</value></property><!--用于在远程文件系统中添加资源的临时本地目录--><property><name>hive.downloaded.resources.dir</name><value>/home/xxx/hive/tmp/${hive.session.id}_resources</value></property> <property><name>hive.server2.authentication</name><value>NONE</value></property><property><name>dfs.permissions.enabled</name><value>false</value></property><property><name>hive.server2.enable.doAs</name><value>FALSE</value></property></configuration>1.5 hive-env.sh
cp hive-env.sh.template hive-env.sh#并编辑export HIVE_CONF_DIR=${HIVE_HOME}/confexport HIVE_AUX_JARS_PATH=${HIVE_HOME}/conf/lib1.5 拷贝mysql驱动包
wget https://cdn.mysql.com//archives/mysql-connector-java-5.1/mysql-connector-java-5.1.46.zipunzipmysql-connector-java-5.1.46.zipcp mysql-connector-java-5.1.46-bin.jar ${HIVE_HOME}/conf/lib2.安装mysql2.1下载myql的版本https://downloads.mysql.com/archives/community/
yum -y install mysql-community-serverLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfileNo package mysql-community-server available.Error: Nothing to do如果yum没办法安装,需要单独下载安装
mysql-community-release-el7-5.noarch.rpm
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpmrpm -ivh mysql57-community-release-el7-10.noarch.rpm yum install mysql-serve查询是否安装ok
rpm -qa|grep mysql修改默认字符集
vi /etc/my.cnf[client]default-character-set=utf8[mysql]default-character-set=utf8[mysqld]collation-server = utf8_unicode_ciinit-connect='SET NAMES utf8'character-set-server = utf8systemctl restart mysqld.service2.2 启动mysql服务systemctlstart mysqld.service2.3 设置登录密码查看临时密码
grep 'temporary password' /var/log/mysqld.log2021-01-07T10:48:25.445856Z 1 [Note] A temporary password is generated for root@localhost: K:3q5rpb4+8R试着用初始密码登录
mysql -p Enter password:设置初始密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MhxzKhl88!'2.4 新建hive数据库 。这个hive数据库与hive-site.xml中localhost:3306/hive的hive对应,用来保存hive元数据
mysql> create database hive; . 配置mysql允许hive接入:
注意yourname是你当前的用户


推荐阅读