一、环境说明
操作系统:macOS High Sierra 10.13.2
hadoop版本:apache hadoop 2.6.0
mysql版本:mysql 5.7.22
hive版本:apache hive 1.2.2
二、安装步骤
在mysql数据库创建hive用户
mysql> create user 'hive' identified by 'hive';
将mysql的所有权限授权给hive用户
mysql> grant all on *.* to 'hive'@'localhost' identified by 'hive';
刷新mysql使1、2步骤生效
mysql> flush privileges;
输入sql语句查询hive用户是否存在
mysql> select host,user,authentication_string from mysql.user; +-----------+---------------+-------------------------------------------+| host | user | authentication_string |+-----------+---------------+-------------------------------------------+| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 || localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE || localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE || % | hive | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC || localhost | hive | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |+-----------+---------------+-------------------------------------------+5 rows in set (0.00 sec)
使用hive用户登录mysql
wudejin:~ oldsix$ mysql -u hive -p Enter password: hive mysql>
创建hive数据库
mysql> create database hive;
查看是否创建成功
mysql> show databases; +--------------------+| Database |+--------------------+| information_schema || feature_ai || hive || mysql || performance_schema || sys |+--------------------+6 rows in set (0.00 sec)
至此,前期的准备工作已完成,接下来,我们进入hive的安装过程。
下载hive安装包,并解压
下载完成后,通过命令行解压:
tar -zxvf apache-hive-1.2.2-bin.tar.gz
解压完成之后,对解压出来的文件夹重命名:
mv apache-hive-1.2.2-bin hive1.2.2
删除没用的hive压缩包:
rm -rf apache-hive-1.2.2-bin.tar.gz
修改hive配置
进入hive1.2.2目录下的bin目录下,修改hive-site.xml配置文件
bin目录下不存在hive-site.xml文件,我们需要先复制一份:
cp hive-default.xml.template hive-site.xml
打开hive-site.xml文件:(找到对应name配置项,修改对应的value属性值)
修改数据库连接驱动名:
<property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description></property>
修改数据库连接URL:
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?characterEncoding=UTF-8</value> <description>JDBC connect string for a JDBC metastore</description></property>
修改数据库连接用户名:
<property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>Username to use against metastore database</description></property>
修改数据库连接密码:
<property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> <description>password to use against metastore database</description></property>
修改hive数据目录(三处):
<property> <name>hive.querylog.location</name> <value>/Users/oldsix/MyApp/data/hive/iotmp</value> <description>Location of Hive run time structured log file</description></property><property> <name>hive.exec.local.scratchdir</name> <value>/Users/oldsix/MyApp/data/hive/iotmp</value> <description>Local scratch space for Hive jobs</description></property><property> <name>hive.downloaded.resources.dir</name> <value>/Users/oldsix/MyApp/data/hive/iotmp</value> <description>Temporary local directory for added resources in the remote file system.</description></property>
注:所修改hive数据目录需提前创建好
配置hive环境变量
cd ~ sudo vi .bash_profile
设置HIVE_HOME,并添加到PATH
export HIVE_HOME=/Users/oldsix/MyApp/hiveexport PATH=$PATH:$HIVE_HOME/bin
保存退出,并使环境变量生效
source .bash_profile
将对应数据库的驱动包放到hive目录下的lib目录下
下载mysql-connector-java-5.1.40.jar,并上传至hive的lib目录下
进入hadoop安装目录,启动hadoop:
/sbin/start-all.sh
命令行输入
jps
命令,查看hadoop是否启动成功启动hive
进入hive的bin目录下,执行命令: ./hive
再执行show tables;
、show databases;
语句
若出现如下面所示,说明hive启动成功:
wudejin:~ oldsix$ hive readlink: illegal option -- f usage: readlink [-n] [file ...] Logging initialized using configuration in jar:file:/Users/oldsix/MyApp/hive/lib/hive-common-1.2.2.jar!/hive-log4j.properties Mon Jul 16 15:15:09 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. Mon Jul 16 15:15:09 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. Mon Jul 16 15:15:09 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. Mon Jul 16 15:15:09 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. Mon Jul 16 15:15:10 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. Mon Jul 16 15:15:10 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. Mon Jul 16 15:15:10 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. Mon Jul 16 15:15:10 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> show tables; OK Time taken: 2.122 seconds hive> show databases; OK default Time taken: 0.047 seconds, Fetched: 1 row(s) hive>
若出现ERROR,hive将启动失败,下面记录了自己在启动hive时遇到的错误以及解决方案:
Found class jline.Terminal, but interface was expected:
问题描述:
[ERROR] Terminal initialization failed; falling back to unsupportedjava.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected at jline.TerminalFactory.create(TerminalFactory.java:101) at jline.TerminalFactory.get(TerminalFactory.java:158) at jline.console.ConsoleReader.<init>(ConsoleReader.java:229) at jline.console.ConsoleReader.<init>(ConsoleReader.java:221) at jline.console.ConsoleReader.<init>(ConsoleReader.java:209) at org.apache.hadoop.hive.cli.CliDriver.getConsoleReader(CliDriver.java:773) at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:715) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
问题原因:
hadoop2.6.0目录中存在较低版本的jline jar包(share/hadoop/yarn/lib/jline-0.9.94.jar),与hive1.2.2的lib目录下的jline jar包版本不符
解决办法:
删除hadoop的share/hadoop/yarn/lib目录下的jline-0.9.94.jar jar包,
将hive的lib目录下的jline-2.12.jar jar包复制到hadoop的share/hadoop/yarn/lib目录下
重启hadoop,再执行hive启动命令
作者:别人说我老六了
链接:https://www.jianshu.com/p/fd99c8670fd3
共同学习,写下你的评论
评论加载中...
作者其他优质文章