1、由於hive的元數據存儲在關系型數據庫中,先安裝mysql
解壓:tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
創建data文件:mkdir data #路徑為/usr/local/src/mysql/data
需要創建mysql用戶和用戶組:
groupadd mysql
useradd -r -g mysql mysql
將安裝文件和data文件修改為mysql用戶:
chown -R mysql:mysql /usr/local/src/mysql
chmod -R 777 data /usr/local/src/mysql/data
修改配置:
./mysql_ssl_rsa_setup --datadir=/usr/local/src/mysql/data
vi /etc/my.cnf 修改為:(修改datadir的存儲位置)
basedir=/usr/local/src/mysql/mysql
datadir=/usr/local/src/mysql/data
port = 3306
socket=/tmp/mysql.sock
pid-file=/tmp/mysqld/mysqld.pid
character-set-server = utf8
log-error=/var/log/mysqld.log
創建/tmp/mysql.sock、/tmp/mysqld/mysqld.pid、/var/log/mysqld.log,並分別修改mysql用戶權限:
cd /tmp
touch mysql.sock
chown mysql:mysql mysql.sock
chmod 755 mysql.sock
cd /tmp/mysqld/
touch mysqld.pid
chown -R mysql:mysql mysqld.pid
chmod 755 mysqld.pid
cd /var/log/
touch mysqld.log
chown -R mysql:mysql /var/log
chmod 755 mysqld.log
修改環境變量:vi ~/.bash_profile
修改為:PATH=$PATH:$HOME/bin:/usr/local/src/mysql/mysql/bin
然后source ~/.bash_profile
初始化:./mysqld --initialize --user=root --basedir=/usr/local/src/mysql/mysql --datadir=/usr/local/src/mysql/data --lc_messages_dir=/usr/local/src/mysql/mysql/share --lc_messages=en_US
進入mysql的bin目錄下,./mysqld_safe --user=mysql啟動mysql,在/var/log/mysqld.log中找生成的臨時密碼:
然后mysql -uroot -p輸入臨時密碼,即進入mysql命令終端;
設置密碼,安裝完成:
use mysql
update user set host='%' where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '......' WITH GRANT OPTION;(或者是:grant all privileges on *.* to root@'%' identified by "新密碼";)
FLUSH PRIVILEGES;
設置開機自動啟動:
cp /usr/local/src/mysql/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig --list mysql
service mysql start
service mysql stop
2、安裝hive
tar -zxvf apache-hive-3.1.1-bin.tar.gz
ln -s apache-hive-3.1.1-bin hive
修改環境變量:/etc/profile,添加
#hive
export HIVE_HOME=/usr/local/src/hive/hive
export PATH=$PATH:$HIVE_HOME/bin
然后: source /etc/profile
hive --version
進入conf目錄,進行設置:cd /usr/local/src/hive/hive/conf
cp hive-default.xml.template hive-site.xml
vi hive-site.xml,增加:
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
進入mysql數據庫,創建hive數據:
create database hive;
進入lib目錄,cd ../lib,下載mysql的連接包:
進入hive安裝目錄bin目錄下:執行schematool -dbType mysql -initSchema
初始化成功:
[root@master bin]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/src/hive/apache-hive-3.1.1-bin/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/src/hadoop-3.0.2/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://localhost:3306/hive
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: root
Thu Dec 13 22:35:42 CST 2018 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.
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.mysql.sql
Thu Dec 13 22:35:43 CST 2018 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.
hive自動創建的表:
mysql> show tables;
+-------------------------------+
| Tables_in_hive |
+-------------------------------+
| AUX_TABLE |
| BUCKETING_COLS |
| CDS |
| COLUMNS_V2 |
| COMPACTION_QUEUE |
| COMPLETED_COMPACTIONS |
| COMPLETED_TXN_COMPONENTS |
| CTLGS |
| DATABASE_PARAMS |
| DBS |
| DB_PRIVS |
| DELEGATION_TOKENS |
| FUNCS |
| FUNC_RU |
| GLOBAL_PRIVS |
| HIVE_LOCKS |
| IDXS |
| INDEX_PARAMS |
........
由於已經新建了環境變量,直接輸入hive進入命令終端:
出現了大量的warn信息,是由於 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,在hive的hive-site.conf中加上useSSL=false,即不啟用SSL連接就可以:
再連接就沒有了:
create database test;
然后在hdfs 上查看目錄:

后續研究下 hive-site的其他配置項的含義。