Reprint please indicate the original address is: https://dongkelun.com/2018/03/24/hiveConf/
Preface:
Because you only learn hive on your own VM, you only need to configure hive in the simplest way. Other complex configuration files are not configured.
1, the premise
1.1 Installing and Configuring JDK1.8
1.2 installation hadoop2. X
Hadoop single-machine deployment mode For details, see Centos7 Hadoop single-machine deployment mode
Install mysql and configure myQL to allow remote access. Mysql 5.7.18
For details about how to install the mysql database, see Centos 7.2 Installing mysql 5.7.13
2. Download Hive
Download address: mirror.bit.edu.cn/apache/hive… I downloaded apache-hive-2.3.2-bin.tar.gz.
Wget download http://mirror.bit.edu.cn/apache/hive/hive-2.3.2/apache-hive-2.3.2-bin.tar.gz or to the local, through to the virtual machine toolsCopy the code
3, decompress to /opt directory (according to your own habit)
Tar -zxvf apache-hive-2.1.2-bin.tar. gz -c /opt/Copy the code
4. Configure Hive environment variables
vim /etc/profile
Copy the code
exportHIVE_HOME = / opt/apache - hive - 2.3.2 - binexport PATH=$PATH:$HIVE_HOME/bin
Copy the code
source /etc/profile
Copy the code
5. Configure Hive
Hive – site. 5.1 configuration XML
ConnectionUserName and ConnectionPassword are the user name and password for remote access to the mysql database, and hive_metadata is the mysql database.
cd/ opt/apache - hive - 2.3.2 - bin/conf/vim hive - site. XMLCopy the code
<? xml version="1.0" encoding="UTF-8" standalone="no"? > <? xml-stylesheettype="text/xsl" href="configuration.xsl"? > <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> < value > JDBC: mysql: / / 192.168.44.128:3306 / hive_metadata? & createDatabaseIfNotExist=true& characterEncoding=UTF-8& useSSL=false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>Root-123456</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>datanucleus.schema.autoCreateAll</name>
<value>true</value> </property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
Copy the code
Hive – site. 5.2 configuration XML
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
Copy the code
HADOOP_HOME = / opt/hadoop - 2.7.5exportHIVE_CONF_DIR = / opt/apache - hive - 2.3.2 - bin/confCopy the code
The specific location is shown as follows:
6. Load the mysql driver (with the mysql version you installed).
Download address: dev.mysql.com/downloads/c… Mysql: mysql-connector-java-5.1.46.tar.gz: mysql-connector-java-5.1.46-bin.jar: mysql-connector-java-5.1.46-bin.jar: mysql-connector-java-5.1.46-bin. / opt/apache – hive – 2.3.2 – bin/lib
Initialize the database
schematool -initSchema -dbType mysql
Copy the code
8. Start Hive
Run the JPS command to check whether Hadoop is started successfully and start Hive. If hadoop is not started, Connection refused will be reported
hive
Copy the code
Then a simple test:
show databases;
Copy the code
If the following figure is displayed, the configuration is successful!
9. Simple Hive statement test
Build tables:
CREATE TABLE IF NOT EXISTS test (id INT,name STRING)ROW FORMAT DELIMITED FIELDS TERMINATED BY "" LINES TERMINATED BY "\n";
Copy the code
Insert data
insert into test values(1,'Joe');
Copy the code
The query
select * from test;
Copy the code