這篇文章主要介紹“Hive數(shù)據(jù)庫的安裝”,在日常操作中,相信很多人在Hive數(shù)據(jù)庫的安裝問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Hive數(shù)據(jù)庫的安裝”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
巨野網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項目制作,到程序開發(fā),運營維護。創(chuàng)新互聯(lián)從2013年成立到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)。
======一.Hive數(shù)據(jù)庫的安裝======
1.首先需要安裝以上hadoop環(huán)境。
2.安裝MySQL環(huán)境存儲Hive的元數(shù)據(jù),因為默認的元數(shù)據(jù)是存放在derby(只支持一個鏈接,用于測試)實際環(huán)境用mysql。
3.安裝環(huán)境使用centos 6.5 IP為:192.168.0.12
======二.安裝mysql數(shù)據(jù)庫存儲Hive元數(shù)據(jù)======
yum install mysql-server
mysql -uroot -p
create database hive;
update mysql.user set password=PASSWORD ('root') where User='root';
flush privileges;
======三.安裝Hive======
需要Java環(huán)境,上述Hadoop已經(jīng)配置。
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
設(shè)置Hive環(huán)境變量hadoop我已經(jīng)設(shè)置
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
清空文件中
把MySQL的JDBC驅(qū)動包復(fù)制到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上的默認存儲路徑======
官網(wǎng)說明:
Hive uses Hadoop, so:
you must have Hadoop in your path OR
export HADOOP_HOME=
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======
出現(xiàn)以下表明運行成功。
[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數(shù)據(jù)庫======
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;
到此,關(guān)于“Hive數(shù)據(jù)庫的安裝”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
本文標題:Hive數(shù)據(jù)庫的安裝
文章分享:http://weahome.cn/article/jheids.html