您好,登錄后才能下訂單哦!
這篇文章主要介紹“Hive數據庫的安裝”,在日常操作中,相信很多人在Hive數據庫的安裝問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Hive數據庫的安裝”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
======一.Hive數據庫的安裝======
1.首先需要安裝以上hadoop環境。
2.安裝mysql環境存儲Hive的元數據,因為默認的元數據是存放在derby(只支持一個鏈接,用于測試)實際環境用mysql。
3.安裝環境使用centos 6.5 IP為:192.168.0.12
======二.安裝mysql數據庫存儲Hive元數據======
yum install mysql-server
mysql -uroot -p
create database hive;
update mysql.user set password=PASSWORD ('root') where User='root';
flush privileges;
======三.安裝Hive======
需要Java環境,上述Hadoop已經配置。
cd /data/hadoop
wget -c http://114.242.101.2:808/hive/apache-hive-2.3.2-bin.tar.gz
tar xf apache-hive-2.3.2-bin.tar.gz
mv apache-hive-2.3.2-bin hive
chown -R hadoop:hadoop hive
設置Hive環境變量hadoop我已經設置
vim /etc/profile
#hive
export HIVE_HOME=/data/hadoop/hive
export PATH=$HIVE_HOME/bin:$PATH
soure /etc/profile
======四.修改Hive配置文件======
su - hadoop
cd /data/hadoop/hive/conf
mv hive-default.xml.template hive-site.xml
清空文件中<configuration></configuration>之間的內容并加入下列內容:
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1:3306/hive?characterEncoding=UTF-8</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>
把MySQL的JDBC驅動包復制到Hive的lib目錄下
cd /data/hadoop/hive/lib/
wget -c http://114.242.101.2:808/hive/mysql-connector-java-5.1.44-bin.jar
======五. Hive在HDFS上的默認存儲路徑======
官網說明:
Hive uses Hadoop, so:
you must have Hadoop in your path OR
export HADOOP_HOME=<hadoop-install-dir>
In addition, you must use below HDFS commands to create
/tmp and /user/hive/warehouse (aka hive.metastore.warehouse.dir)
and set them chmod g+w before you can create a table in Hive.
su - hadoop
cd /data/hadoop/hadoop-2.7.4
./bin/hadoop fs -mkdir /tmp
./bin/hadoop fs -mkdir -p /user/hive/warehouse
./bin/hadoop fs -chmod g+w /tmp
./bin/hadoop fs -chmod g+w /user/hive/warehouse
======六.運行Hive======
出現以下表明運行成功。
[hadoop@localhost hadoop]$ hive
which: no hbase in (/data/hadoop/hadoop-2.7.4/bin:/data/hadoop/hive/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el6_9.x86_64/bin:/home/hadoop/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/data/hadoop/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/data/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Logging initialized using configuration in jar:file:/data/hadoop/hive/lib/hive-common-2.3.2.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive>
>
>
>
======七.初始化Hive數據庫======
su -hadoop
schematool -initSchema -dbType mysql
======八.運行Hive操作命令======
hive> CREATE TABLE pokes (foo INT, bar STRING);
hive> CREATE TABLE invites (foo INT, bar STRING) PARTITIONED BY (ds STRING);
hive> SHOW TABLES;
hive> SHOW TABLES '.*s';
hive> DESCRIBE invites;
hive> ALTER TABLE events RENAME TO 3koobecaf;
hive> ALTER TABLE pokes ADD COLUMNS (new_col INT);
hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 'a comment');
hive> ALTER TABLE invites REPLACE COLUMNS (foo INT, bar STRING, baz INT COMMENT 'baz replaces new_col2');
hive> ALTER TABLE invites REPLACE COLUMNS (foo INT COMMENT 'only keep the first column');
hive> DROP TABLE pokes;
到此,關于“Hive數據庫的安裝”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。