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
# 創(chuàng)建工作目錄
[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/
# 啟動(dòng)MYSQL
[root@hnxxzxfzjz006 soft]#  service mysqld start
# 獲取默認(rèn)密碼,登陸,修改密碼
[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)
#開啟遠(yuǎn)程訪問
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上創(chuàng)建倉(cāng)庫(kù)目錄
[root@hnxxzxfzjz004 bin]# hadoop fs -mkdir -p /user/hive/warehouse

# 設(shè)置環(huán)境變量
# 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驅(qū)動(dòng)包

[root@hnxxzxfzjz006 lib]# wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar
# 初始化HIVE表結(jié)構(gòu)
[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個(gè)字
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中表結(jié)構(gòu)
[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個(gè)表              |
| WM_MAPPING                    |
| WM_POOL                       |
| WM_POOL_TO_TRIGGER            |
| WM_RESOURCEPLAN               |
| WM_TRIGGER                    |
| WRITE_SET                     |
+-------------------------------+
74 rows in set (0.00 sec)
  • hive測(cè)試
[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上查看創(chuàng)建的倉(cāng)庫(kù)


    image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容