3)hive服務安裝

1.安裝hive

1.1解壓縮(/opt下)java

tar -zxvf apache-hive-1.2.1-bin.tar.gz
mv apache-hive-1.2.1-bin hive

1.2配置環境變量mysql

vi ~/.bashrc

    export HIVE_HOME=/opt/hivesql

    export PATH=$HIVE_HOME/bin數據庫

source ~/.bashrc

2.安裝mysql(hadoop001)

2.1 安裝mysql serverapache

yum install -y mysql-server
service mysqld start
chkconfig mysqld on

2.2 安裝mysql connectorbash

yum install -y mysql-connector-java

2.3 將mysql connector拷貝到hivelib包中ide

cp /usr/share/java/mysql-connector-java-5.1.17.jar /opt/hive/lib

2.4 在mysql上建立hive元數據庫,並對hive進行受權oop

create database if not exists hive;
grant all privileges on hive.* to 'hive'@'%' identified by 'hive';
grant all privileges on hive.* to 'hive'@'localhost' identified by 'hive';
grant all privileges on hive.* to 'hive'@'hadoop001' identified by 'hive';
flush privileges;
use hive_metadata;

3.配置hive-site.xmlspa

3.1 建立hive-site.xml.net

mv hive-default.xml.template hive-site.xml

3.2 修改hive-site.xml中如下幾項

vi hive-site.xml
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://hadoop001:3306/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>hive</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>hive</value>
</property>
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/warehouse</value>
</property>

4.配置hive-env.shhive-config.sh

mv hive-env.sh.template hive-env.sh
vi /opt/hive/bin/hive-config.sh

    export JAVA_HOME=/usr/jdk1.7.0_55

    export HIVE_HOME=/opt/hive

    export HADOOP_HOME=/opt/hadoop

5.使用

    hive

6.Hive報錯處理

[ERROR] Terminal initialization failed; falling back to unsupported

java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected

解決

hive下的新版本jlineJAR包拷貝到hadoop下:

cp /opt/hive/lib/jline-2.12.jar /opt/hadoop/share/hadoop/yarn/lib

---------------------------------

啓動時

Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D

解決:

建立文件夾/opt/hive/iotmp

修改配置文件hive-site.xml

${system:java.io.tmpdir}所在value,替換爲/opt/hive/iotmp/

---------------------------------

建表時

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:For direct MetaStore DB connections, we don't support retries at the client level.)

解決:

這是因爲字符集的問題,須要配置MySQL的字符集:

mysql> alter database hive character set latin1;

相關文章
相關標籤/搜索