Hive安装

  • 卸载原有mysql
[root@hnxxzxfzjz006 ~]# rpm -qa | grep -i mysql
mysql-server-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64
mysql-libs-5.1.71-1.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
MySQL-python-1.2.3-0.3.c1.1.el6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
[root@hnxxzxfzjz006 ~]# rpm -e --nodeps mysql-5.1.71-1.el6.x86_64
[root@hnxxzxfzjz006 ~]# rpm -e --nodeps mysql-server-5.1.71-1.el6.x86_64
[root@hnxxzxfzjz006 ~]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
[root@hnxxzxfzjz006 ~]#  rpm -e --nodeps perl-DBD-MySQL-4.013-3.el6.x86_64
[root@hnxxzxfzjz006 ~]# rpm -e --nodeps MySQL-python-1.2.3-0.3.c1.1.el6.x86_64
[root@hnxxzxfzjz006 ~]#  rpm -e --nodeps mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
[root@hnxxzxfzjz006 ~]# rpm -qa | grep -i mysql

  • mysql 安装
# 解压
[root@hnxxzxfzjz006 soft]# tar -xvf mysql-5.7.27-1.el6.x86_64.rpm-bundle.tar 
mysql-community-test-5.7.27-1.el6.x86_64.rpm
mysql-community-embedded-5.7.27-1.el6.x86_64.rpm
mysql-community-server-5.7.27-1.el6.x86_64.rpm
mysql-community-client-5.7.27-1.el6.x86_64.rpm
mysql-community-common-5.7.27-1.el6.x86_64.rpm
mysql-community-devel-5.7.27-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.27-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.27-1.el6.x86_64.rpm
mysql-community-libs-5.7.27-1.el6.x86_64.rpm
# 按顺序安装
[root@hnxxzxfzjz006 soft]# rpm -ivh  mysql-community-common-5.7.27-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-common ########################################### [100%]
[root@hnxxzxfzjz006 soft]# rpm -ivh  mysql-community-libs-5.7.27-1.el6.x86_64.rpm 
warning: mysql-community-libs-5.7.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-libs   ########################################### [100%]
[root@hnxxzxfzjz006 soft]# rpm -ivh  mysql-community-libs-compat-5.7.27-1.el6.x86_64.rpm 
warning: mysql-community-libs-compat-5.7.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-libs-co########################################### [100%]
[root@hnxxzxfzjz006 soft]# rpm -ivh  mysql-community-client-5.7.27-1.el6.x86_64.rpm 
warning: mysql-community-client-5.7.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-client ########################################### [100%]
[root@hnxxzxfzjz006 soft]# rpm -ivh  mysql-community-server-5.7.27-1.el6.x86_64.rpm 
warning: mysql-community-server-5.7.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:mysql-community-server ########################################### [100%]

# 修改配置
[root@hnxxzxfzjz006 soft]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/data/work/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/data/work/mysql/logs/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# 创建工作目录
[root@hnxxzxfzjz006 soft]# mkdir -p /data/work/mysql/logs
[root@hnxxzxfzjz006 soft]# mkdir -p /data/work/mysql/data
[root@hnxxzxfzjz006 soft]# chown -R mysql:mysql /data/work/mysql/
# 启动MYSQL
[root@hnxxzxfzjz006 soft]#  service mysqld start
# 获取默认密码,登陆,修改密码
[root@hnxxzxfzjz006 soft]#  grep 'temporary password'  /data/work/mysql/logs/mysqld.log
2019-08-29T02:23:17.955726Z 1 [Note] A temporary password is generated for root@localhost: l+osa1hi3Lsr
[root@hnxxzxfzjz006 soft]# mysql -uroot -pl+osa1hi3Lsr
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.27

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> alter user root@localhost identified by 'Hnqx@admin123';
Query OK, 0 rows affected (0.00 sec)
#开启远程访问
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host, user from user;
+-----------+---------------+
| host      | user          |
+-----------+---------------+
| %         | root          |
| localhost | mysql.session |
| localhost | mysql.sys     |
+-----------+---------------+
3 rows in set (0.00 sec)

mysql>flush privileges;
  • hive 安装
[root@hnxxzxfzjz006 cloud]# cp /data/soft/apache-hive-3.1.2-bin.tar.gz  .
[root@hnxxzxfzjz006 cloud]# tar -zxvf apache-hive-3.1.2-bin.tar.gz 
[root@hnxxzxfzjz006 cloud]# rm -rf apache-hive-3.1.2-bin.tar.gz 
[root@hnxxzxfzjz006 cloud]# mv apache-hive-3.1.2-bin/ hive
[root@hnxxzxfzjz006 cloud]# mkdir -p /data/work/hive/logs
#在HDFS上创建仓库目录
[root@hnxxzxfzjz004 bin]# hadoop fs -mkdir -p /user/hive/warehouse

# 设置环境变量
# export HIVE_HOME=/data/cloud/hive
# export PATH=$PATH:$HIVE_HOME/bin
[root@hnxxzxfzjz006 cloud]# hive --version
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/data/cloud/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/data/cloud/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Hive 3.1.2
Git git://HW13934/Users/gates/tmp/hive-branch-3.1/hive -r 8190d2be7b7165effa62bd21b7d60ef81fb0e4af
Compiled by gates on Thu Aug 22 15:01:18 PDT 2019
From source with checksum 0492c08f784b188c349f6afb1d8d9847
  • 文件配置
root@hnxxzxfzjz006 conf]# pwd
/data/cloud/hive/conf
[root@hnxxzxfzjz006 conf]# mv hive-env.sh.template hive-env.sh
[root@hnxxzxfzjz006 conf]# mv hive-default.xml.template hive-site.xml
[root@hnxxzxfzjz006 conf]# mv hive-log4j2.properties.template hive-log4j2.properties

hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<configuration>
 <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://10.110.172.156:3306/hive?createDatabaseIfNotExist=true</value>
  </property>
<property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
<property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>root</value>
    <description>Username to use against metastore database</description>
  </property>
<property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>Hnqx@admin123</value>
    <description>password to use against metastore database</description>
  </property>
<property>
    <name>hive.metastore.warehouse.dir</name>
    <value>/user/hive/warehouse</value>
    <description>location of default database for the warehouse</description>
  </property>
</configuration>

下载mysql驱动包

[root@hnxxzxfzjz006 lib]# wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar
# 初始化HIVE表结构
[root@hnxxzxfzjz006 conf]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/data/cloud/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/data/cloud/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:mysql://10.110.172.156:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
····此处省略n个字
Initialization script completed
Thu Aug 29 11:07:03 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
schemaTool completed
# 插卡mysql中表结构
[root@hnxxzxfzjz006 conf]# mysql -uroot -pHnqx@admin123
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 11
Server version: 5.7.27 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> use hive;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------------------+
| Tables_in_hive                |
+-------------------------------+
| AUX_TABLE                     |
| BUCKETING_COLS                |
| CDS                           |
| COLUMNS_V2                    |
| COMPACTION_QUEUE              |
| ····此处省略n个表              |
| WM_MAPPING                    |
| WM_POOL                       |
| WM_POOL_TO_TRIGGER            |
| WM_RESOURCEPLAN               |
| WM_TRIGGER                    |
| WRITE_SET                     |
+-------------------------------+
74 rows in set (0.00 sec)
  • hive测试
[root@hnxxzxfzjz006 conf]#  hive
···此处省略加载信息
hive>  create database hnqx ;
OK
Time taken: 2.48 seconds
hive> show databases ;
OK
2019-08-29 13:33:00,519 INFO  [44d8a432-374f-4b6b-a049-26b1dda56c7c main] mapred.FileInputFormat: Total input files to process : 1
default
hnqx
Time taken: 2.51 seconds, Fetched: 2 row(s)
  • 在HDFS上查看创建的仓库


    image.png
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,793评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,567评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,342评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,825评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,814评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,680评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,033评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,687评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,175评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,668评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,775评论 1 332
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,419评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,020评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,978评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,206评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,092评论 2 351
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,510评论 2 343

推荐阅读更多精彩内容