hive安装

安装mysql的5.7版本

 docker run -p 13306:3306 --name mysql57 --restart always -v mysql57_conf:/etc/mysql/conf.d -v mysql57_logs:/logs -v mysql57_data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

命令说明:

-p 13306:3306:将容器的 3306 端口映射到主机的 13306 端口。

-v -v mysql57_conf:/etc/mysql/conf.d:将主机docker的volume mysql57_conf 下conf/my.cnf 挂载到容器的 /etc/mysql/my.cnf。

-v mysql57_logs:/logs:将主机docker的volume mysql57_logs 挂载到容器的 /logs。

-v mysql57_data:/var/lib/mysql :将主机docker的volume mysql57_data 挂载到容器的 /var/lib/mysql 。

-e MYSQL_ROOT_PASSWORD=123456:初始化 root 用户的密码。

查看运行情况:

docker ps |grep mysql
49990570eee2        mysql:5.7                         "docker-entrypoint..."   50 seconds ago      Up 49 seconds       33060/tcp, 0.0.0.0:13306->3306/tcp             mysql57

测试

先进入容器

root@hdfs-01:~# docker exec -it mysql57 bash

连接mysql

root@49990570eee2:/# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 

创建hive用户并赋权限

CREATE USER 'hive'@'%' IDENTIFIED BY 'huawei123!@#';

GRANT ALL ON hive.* TO 'hive'@'%'

安装hive

下载hive

wget http://archive.cloudera.com/cdh5/cdh/5/hive-1.1.0-cdh5.14.0.tar.gz

解压

tar -zxvf hive-1.1.0-cdh5.14.0.tar.gz -C /data/servers
cd /data/servers/hive-1.1.0-cdh5.14.0

配置hive.env.sh

vim conf/hive-env.sh

HADOOP_HOME=/data/servers/hadoop-2.6.0-cdh5.14.0
# Hive Configuration Directory can be controlled by:
# export HIVE_CONF_DIR=
export HIVE_CONF_DIR=/data/servers/hive-1.1.0-cdh5.14.0/conf

配置hive-site.xml



        
                javax.jdo.option.ConnectionURL
                jdbc:mysql://hdfs-01:13306/hive?createDatabaseIfNotExist=true
        

        
                javax.jdo.option.ConnectionDriverName
                com.mysql.jdbc.Driver
        
        
                javax.jdo.option.ConnectionUserName
                hive
        
        
                javax.jdo.option.ConnectionPassword
                huawei123!@#
        
        
                hive.cli.print.current.db
                true
        
        
                hive.cli.print.header
                true
        
        
                hive.server2.thrift.bind.host
                hdfs-01
        



上传mysql驱动包

上传到/data/servers/hive-1.1.0-cdh5.14.0/lib下

rz -bye mysql-connector-java-5.1.38.jar

配置hive环境变量

vim /etc/profile

export HIVE_HOME=/data/servers/hive-1.1.0-cdh5.14.0
export PATH=${HIVE_HOME}/bin:$PATH

source /etc/profile

验证

root@hdfs-01:/data/servers/hive-1.1.0-cdh5.14.0# hive
ls: cannot access '/data/servers/spark-2.4.3-bin-hadoop2.6/lib/spark-assembly-*.jar': No such file or directory

Logging initialized using configuration in jar:file:/data/servers/hive-1.1.0-cdh5.14.0/lib/hive-common-1.1.0-cdh5.14.0.jar!/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive (default)> show databases;

beeline方式连接(推荐)

#启动hiveserver2  服务
nohup bin/hive --service hiveserver2  &
bin/beeline
beeline> !connect jdbc:hive2://hdfs-01:10000
#后面用户名输入root,密码不用输入

你可能感兴趣的:(hive安装)