安装Hive

安装MySQL

当然你也可以使用默认的数据库Derby,不推荐。

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum install -y mysql-server

systemctl start mysqld

systemctl enable mysqld
###初始化Mysql

/usr/bin/mysql_secure_installation

[...]
Enter current password for root (enter for none):
OK, successfully used password, moving on...
[...]
Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
[...]
Disallow root login remotely? [Y/n] N
[...]
Remove test database and access to it [Y/n] Y
[...]
Reload privilege tables now? [Y/n] Y
All done!

给开放远程权限:

mysql> use mysql;

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

mysql> flush privileges;
#在官网下载hive压缩包,解压
tar -zxvf apache-hive-2.1.0-bin.tar.gz -C /home/hive/

#拷贝mysql-java的连接jar包到hive的lib目录下

#编辑hive-env.sh.xml
cp hive-env.sh.template hive-env.sh.xml
vi hive-env.sh.xml
##修改
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/home/hadoop/hadoop-2.9.2

# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/home/hive/apache-hive-2.1.0-bin/conf


#增加一个hive-site.xml,全部内容下面给出了。

配置hive-site.xml

hive-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
	<property>
	  <name>javax.jdo.option.ConnectionURL</name>
	  <value>jdbc:mysql://192.168.200.111:3306/hive2?createDatabaseIfNotExist=true</value>
	  <description>JDBC connect string for a JDBC metastore</description>
	</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>123456</value>
	  <description>password to use against metastore database</description>
	</property>
	<!--显示相关信息-->
	<property>
		<name>hive.cli.print.header</name>
		<value>true</value>
		<description>Whether to print the names of the columns in query output.</description>
	</property>
	<!--显示相关信息-->
    <property>
		<name>hive.cli.print.current.db</name>
		<value>true</value>
		<description>Whether to include the current database in the Hive prompt.</description>
	</property>
</configuration>

配置环境变量

vi /etc/profile

#JAVA
export JAVA_HOME=/home/java/jdk1.8.0_191
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

#HADOOP
export HADOOP_HOME=/home/hadoop/hadoop-2.9.2
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export HADOOP_CLASSPATH=${JAVA_HOME}/lib/tools.jar

#HIVE
export HIVE_HOME=/home/hive/apache-hive-2.1.0-bin
export PATH=$PATH:$HIVE_HOME/bin

初始化Hive

schematool -dbType mysql -initSchema

附加:

如果spark集成hive:
在spark中执行hive的查询语句,会出现版本不一致的错误:
解决办法1:
在hvie-site.xml中关闭版本验证(本人使用的)

<property>
    <name>hive.metastore.schema.verification</name>
    <value>false</value>
</property>

解决办法2:

    <property>
		<name>hive.metastore.uris</name>
		<value>thrift://master:9083</value>
		<description>None</description>
	</property>

欢迎关注我的动态

欢迎关注我的个人博客网站www.liuzhaopo.top

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值