The environment of this article is as follows:
Operating system: CentOS 6 32-bit
Hive Version: 2.0.0
JDK version: 1.8.0_77 32-bit
Hadoop version: 2.6.4
1. The required environment
The following operating environments are required for Hive 2.0:
Java 1.7 and above (Java 1.8 is strongly recommended)
Hadoop 2.X
2. Download and unzip the hive installation package
Hive Website Address: http://hive.apache.org/
For example:
"http://mirrors.cnnic.cn/apache/hive/hive-2.0.0/apache-hive-2.0.0-bin.tar.gz"-xzvf apache-hive-2.0.0-bin.tar.gzmv apache-hive-2.0.0-bin /opt/hive-2.0.0
3. Configure environment variables (optional)
Add Hive-2.0.0/bin to path for easy access
vi /etc/profile
Add at the end:
HIVE_HOME=/opt/hive-2.0.0PATH=$PATH:$HIVE_HOME/bin
4. Start the standalone mode
Hive, like Hadoop, has 3 startup modes, namely single-machine mode, pseudo-distribution mode, and distribution mode. Here's a first way to start the stand-alone mode.
4.1 Modifying a configuration file
cd /opt/hive-2.0.0/confvi hive-site.xml //也可以用hive-default.xml.template去改,不过这个文件中的配置项太多了
Save after entering the following:
<?xml version= "1.0" encoding= "UTF-8" standalone= "no"?><?xml-stylesheet type= "text/xsl" href= "configuration.xsl"?><configuration><property > <name>Hive.metastore.warehouse.dir</name> <value>/opt/hive-2.0.0/warehouse</value> <description>Location of the default database for the warehouse</Description></Property ><property > <name>Javax.jdo.option.ConnectionURL</name> <value>Jdbc:derby:/opt/hive-2.0.0/metastore_db;create=true</value> <description>JDBC connect string for a JDBC Metastore</Description></Property ></configuration>
4.2 Initializing the database
-initSchema-dbType derby
The following lines appear to illustrate the success of the initialization:
initializationto2.0.0Initialization script hive-schema-2.0.0.derby.sqlInitialization script completedschemaTool completed
4.3 Starting the program
mkdir -p /opt/hive-2.0.0/warehouse // 创建元数据存储文件夹a+rwx /opt/hive-2.0.0/warehouse // 修改文件权限hive
If a hive>
prompt appears, the startup succeeds
5. Common Error 5.1 Occurs when you run hive
in"main"isnottothetothetotheinstring (e.g. ?createDatabaseIfNotExist=truefor mysql)
Cause of Error:
Database is not initialized, please refer to 4.2
5.2 Occurs when initializing a database with Schematool
Initialization script hive-schema-2.0.0FUNCTION ‘NUCLEUS_ASCII‘ already exists. (state=X0Y68,code=30000)org.apache.hadoop.hive.metastore.HiveMetaException:initialization FAILED! Metastore state would be inconsistent !!*** schemaTool failed ***
Error reason: Some files already exist in the database folder, the workaround is to empty the database folder (that is, the folder that you configured earlier /opt/hive-2.0.0/metastore_db
)
CentOS Hive2.0.0 Stand-alone mode installation detailed