1. First Download hive
Choose the bin option, or compile it yourself later
Unzip the installation move to/usr/local/hive
Go to Hive directory and enter CONF
CP hive-env.sh.template HIVE-ENV.SHCP hive-default.xml.template HIVE-SITE.XMLCP hive-log4j2.properties.template hive-log4j2.properties
CP Hive-exec-log4j.properties.template Hive-exec-log4j.properties
Configure the hive/conf/hive-env.sh, remove the following three comments and add the address
Hadoop_home=/usr/local/hadoop Export hive_conf_dir=/usr/local/hive/conf Export hive_aux_jars_path=/usr/local/hive
Configure Hive/conf/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 are not a use of this file except in compliance with the License. Obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 unless required by applicable l AW or agreed to writing, software distributed under the License are distributed on a "as is" BASIS, without WARRANT IES or CONDITIONS of any KIND, either express OR implied. See the License for the specific language governing permissions and limitations under the License.--><configuratio n><!--<property><name>hive.metastore.warehouse.dir≪/name><value>/user/hive/warehouse</value></property><property> <name> Hive.metastore.local</name><value>true</value></property>-<!-- If it is a remote MySQL database, you need to write to the remote IP or hosts--><property><name>javax.jdo.option.connectionurl</name> <value>jdbc:mysql://localhost/hive?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>root</value></property><property><name> Javax.jdo.option.connectionpassword</name><value>root</value></property><property > <name>hive.metastore.schema.verification</name> <value>false</value> </property& Gt;<property> <name>datanucleus.readonlydatastore</name> <value>false</value> </property> <property> &L T;name>datanucleus.fixeddatastore</name> <value>false</value> </property> <property> <name>datanucleus.autoCreateSchema</name> <value>true</value> ; </property> <property> <name>datanucleus.autoCreateTables</name> < value>true</value> </property> <property> <name>datanucleus.autocreatecolu mns</name> <value>true</value> </property> </configuration>
Configure hive/bin/hive-config.sh at the end of the add
Export Java_home=/usr/local/javaexport Hive_home=/usr/local/hiveexport Hadoop_home=/usr/local/hadoop
It is important to note that when using MySQL, hive needs to copy the MySQL JDBC package to hive/lib, MySQL package download link https://www.mysql.com/products/connector/
Start the MySQL service
Service mysqld Start
If the login test is successful with Mysql-uroot, if the root password is successfully modified:
Mysql>use mysql;mysql> Update user set Password=password ("test") where user= ' root ';mysql> flush privileges; Mysql> exit;
Under start of the Hadoop service, in which hive:
To start the Hive service:
Start hive service runs in the background:
Hive--service hiveserver2 &
Then start the Hive client:
Hive
If the entry into the hive> shell proves that the start was successful;
First create the table:
hive> CREATE EXTERNAL TABLE MYTEST (num INT, name STRING) > ROW FORMAT delimited fields TERMINATED by ' \ t ' // Delimiter ' \ t ' >;
Import data:
hive> Load Data local inpath '/tmp/hive.txt ' overwrite into table MYTEST; Copying data from file:/tmp/hive.txtcopying file:file:/tmp/hive.txtloading data to table default.mytestdeleted hdfs:// Localhost:9000/user/hive/warehouse/mytestoktime taken:0.402 seconds
View data:
Hive> SELECT * from Mytest;oknull NULL22 world33
Finally look at the/tmp/hive.txt documentation:
[Email protected]:~/hive/conf$ cat/tmp/hive.txt 11,hello22 world33
Hive configuration MySQL in Hadoop