The hive build is divided into three modes: 1, embedded,2, local,3, remote server
In this case, the main configuration is the 3rd mode: remote Server mode
My environment is a total of three virtual machines: HOST0,HOST2,HOST3
In remote server mode, the Host0:hive-server2
Host2:hive-metastore
Host3:mysql Server
1, respectively in the Host0,host2 and Host3 installed Hive-server2,hive-metastore,mysql-server
Yum Install hive-server2-y
Yum Install Hive-metastore-y
Yum Install Mysql-server-
2. Create hive database and hive user in MySQL server, and set hive user to Telnet
Create DatabaseHive;Create UserHive identified by '123456';Grant All Privileges on *.* to[Email protected] '%' Identified by‘123456'; FlushPrivileges;
3. Set the hive configuration file in Hive-metastore so that it can connect to MySQL server
Hive configuration file Location:/etc/hive/conf/hive-site.xml
Add the following to Hive-site.xml
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://host3:3306/hive?characterencoding=utf-8</value><DESCRIPTION>JDBC Connectstring forA JDBC metastore</description></property><property> <name> Javax.jdo.option.connectiondrivername</name> <value>com.mysql.jdbc.Driver</value> < Description>driver class Name forA JDBC metastore</description></property><property> <name> Javax.jdo.option.connectionusername</name> <value>hive</value></property><property > <name>javax.jdo.option.ConnectionPassword</name> <value>123456</value></property><property> <name>hive.metastore.warehouse.dir</name> <!--base HDFs path-----<value>/user/hive/warehouse</value> <description> Location of the default database forThe warehouse</description></property>
4. Create the Hive.metastore.warehouse.dir directory on HDFs and modify the permissions
sudo -u hdfs Hadoop FS-mkdir -p/user/hive/warehousesudo -u hdfs Hadoop FS-Chown -R hive:hive/user/hive
5. Set the hive configuration file in Hive-server2 so that it can connect to the Hive-metastore
Hive configuration file Location:/etc/hive/conf/hive-site.xml
Add the following to Hive-site.xml
<property> <name>hive.metastore.uris</name> <value>thrift://Host2 :9083</value></property>
6. Start the Hive-server2,hive-metastore in Host0,host2 respectively
Service hive-server2 startservice hive-metastore Start
7. Test in another virtual machine (hive installation required)
[[Email protected] ~]# Beelinewhich: No HBaseinch(/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.8.0_60/bin:/root/bin) Beeline version1.1.0-cdh5.8.0by Apache Hivebeeline>!connect jdbc:hive2://host0:10000Scan completeinch11msConnecting to Jdbc:hive2://host0:10000Enter username forJdbc:hive2://host0:10000:1Enter Password forJdbc:hive2://host0:10000: *Connected To:apache Hive (version1.1.0-cdh5.8.0) driver:hive JDBC (version1.1.0-cdh5.8.0) Transaction Isolation:transaction_repeatable_read0: jdbc:hive2://host0:10000> show tables;info:compiling Command (queryid=hive_20160912015858_bd9495d2-191f-429c-bf01-a165821b6d9a): Show tablesinfo:semantic analysis completedinfo:returning Hive Schema:schema (Fieldschemas:[fiel Dschema (Name:tab_name, type:string, Comment:from Deserializer)], properties:NULL) info:completed compiling command (Queryid=HIVE_20160912015858_BD9495D2-191F-429C-BF01-A165821B6D9A); Time Taken:0.027secondsinfo:concurrency mode is disabled, not creating a lock managerinfo:executing command (Queryid=hive_20160912015858_bd9495d2-191f-429c-bf01-a165821b6d9a): Show tablesinfo:starting task [Stage-0:D DL]inchserial modeinfo:completed Executing command (Queryid=HIVE_20160912015858_BD9495D2-191F-429C-BF01-A165821B6D9A); Time Taken:0.061Secondsinfo:ok+-----------+--+| Tab_name |+-----------+--++-----------+--+No rows Selected (0.389Seconds
It is important to note that if Kerberos is not used in the Hiveserver2 mode, the above password is free to write
8. Create a table in hive and import the data into the table
CREATE TABLE Test (IDintint int. int',' '/user/sqoop/sample' into table test;
The data format in the/user/sqoop/sample table is: 11419,9,160,48 format
When the load data inpath '/user/sqoop/sample ' into table test is executed, the/user/sqoop/sample in the MV to the/user/hive/warehouse/test,/ The User/sqoop/sample directory is empty.
CentOS Configuration Hive