Install hive manually

This article mainly introduces the detailed process of installing on the basis of the previously built cluster.
Experimental environment
hive version: apache-hive-2.3.0-bin.tar.gz
 hadoop: hadoop-2.7.3 (please install in advance)
Install hive
and upload the hive file to /hasoft.
Unzip the command: tar -zxvf apache-hive-2.3. 0-bin.tar.gz


Configure environment variables
Command: vi /etc/profile
 
export HIVE_HOME=/hasoft/apache-hive-2.3.0-bin
export PATH=${HIVE_HOME}/bin:$PATH

The configuration takes effect
Command: source /etc/profile

For details on installing mysql,
please refer to the MYSQL installation documentation

Set startup
command: chkconfig mysql on 

Install the mysql client
Command: yum install -y mysql-connector-java


Copy the mysql connector to the lib package of hive
Command: cp /usr/share/java/mysql-connector-java.jar /hasoft/apache-hive-2.3.0-bin/lib
 
Create the hive element on mysql, create hive account and authorize the
command: mysql -u root -p
 
After entering mysql, execute the following commands in sequence:
create database if not exists hive_metadata;
grant all privileges on hive_metadata.* to 'hive'@'%' identified by 'hive';
grant all privileges on hive_metadata.* to 'hive'@'localhost' identified by 'hive';
grant all privileges on hive_metadata.* to 'hive'@'sparkproject1' identified by 'hive';
flush privileges;
use hive_metadata;

 
Configuration file
Configure hive-site.xml
cd /hasoft/apache-hive-2.3.0-bin/conf
mkdir ../tmp
cp hive-default.xml.template hive-site.xml
vi hive-site.xml
 
Execute the following VI Command (replace temporary file address):
:%s#${system:java.io.tmpdir}#/hasoft/apache-hive-2.3.0-bin/tmp

修改以下属性内容:
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://ha1.ry600.com:3306/hive_metadata?createDatabaseIfNotExist=true</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>com.mysql.jdbc.Driver</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>hive</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>hive</value>
</property>


configure hive-env.sh
cp hive-env.sh.template hive-env.sh

Place hive-env.sh
vi hive-env.sh

export JAVA_HOME=/hasoft/jdk1.8.0_131
export HIVE_HOME=/hasoft/apache-hive-2.3.0-bin
export HADOOP_HOME=/hasoft/hadoop-2.7.3


Fix jar package version conflict:
cd /hasoft/hadoop-2.7.3/share/hadoop/yarn/lib
mv jline-0.9.94.jar jline-0.9.94.jar.bak
cd /hasoft/apache-hive-1.2. 2-bin/lib
cp jline-2.12.jar /hasoft/hadoop-2.6.4/share/hadoop/yarn/lib
Test whether hive is installed successfully
First upload users.txt file to /hasoft/tmpfile
users.txt The content format is as follows:
1 adas
2 ladkda
3 hahah
4 kissyou
5 wan
6 nnds

Then start the hive
command: hive
 
*If there is an error in line 2784, add it here

create table  users(id int, name string)  row format delimited fields terminated by ' ';
load data local inpath '/hasoft/tmpfile/users.txt' into table users;

select * from users;
select name from users;
If there is no error in the middle and the following query is obtained, it means that the hive installation is successful.

 
Exit command: exit


 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325968216&siteId=291194637