#前言html
今天被問題卡了半天,最後察覺會不會datanode訪問不了呢?在團哥的指導下...才發現本身犯了個愚蠢的錯誤,哎,不說罷。丟人,太粗心了。通過這幾天,終於把Hadoop 3.0.3 和 Hive 3.0 搭建好了..不容易啊,搭建好了以後如何使用呢?木知....java
#上碼node
1,下載,解壓,變名 wget http://mirrors.hust.edu.cn/apache/hive/hive-3.0.0/apache-hive-3.0.0-bin.tar.gz tar -xzvf apache-hive-3.0.0-bin.tar.gz mv apache-hive-3.0.0-bin hive 2,配置環境 vim /etc/profile (在後面追加) export HIVE_HOME=/home/hive 3,安裝Mysql sudo apt-get install mysql-server sudo apt-get install libmysql-java ln -s /usr/share/java/mysql-connector-java.jar $HIVE_HOME/lib/mysql-connector-java.jar 4,導入數據 $ mysql -u root -p mysql> CREATE DATABASE metastore; mysql> USE metastore; mysql> SOURCE $HIVE_HOME/scripts/metastore/upgrade/mysql/hive-schema-3.0.0.mysql.sql; mysql> CREATE USER 'hive'@'%' IDENTIFIED BY 'hive'; mysql> GRANT all on *.* to 'hive'@localhost identified by 'hive'; mysql> flush privileges; 5,配置hive 環境 (/home/hive/conf) cp hive-env.sh.template hive-env.sh vim hive-env.sh export HADOOP_HOME=/home/hadoop export HIVE_CONF_DIR=/home/hive/conf cp hive-default.xml.template hive-site.xml vim hive-site.xml (配置路徑與mysql) <property> <name>system:java.io.tmpdir</name> <value>/user/hive/warehouse</value> </property> <property> <name>system:user.name</name> <value>${user.name}</value> </property> <property> <name>hive.metastore.db.type</name> <value>mysql</value> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/metastore?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> <description>user name for connecting to mysql server</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> <description>password for connecting to mysql server</description> </property> 6, 建立臨時目錄 $HADOOP_HOME/bin/hadoop fs -mkdir -p /tmp $HADOOP_HOME/bin/hadoop fs -mkdir -p /user/hive/warehouse $HADOOP_HOME/bin/hadoop fs -chmod g+w /tmp $HADOOP_HOME/bin/hadoop fs -chmod g+w /user/hive/warehouse 7,初始化hive schematool -dbType mysql -initSchema 8,啓動 metastore服務 (不啓用會報:HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient。) ./hive --service metastore & 9,進入Hive $HIVE_HOME/bin/hive #建立表 hive (default)> CREATE TABLE IF NOT EXISTS test_table (col1 int COMMENT 'Integer Column', col2 string COMMENT 'String Column' ) COMMENT 'This is test table' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE; hive (default)> show tables; tab_name test_table #寫入 hive (default)> insert into test_table values(1,'aaa'); MapReduce Jobs Launched: Stage-Stage-1: Map: 1 Reduce: 1 Cumulative CPU: 5.54 sec HDFS Read: 15408 HDFS Write: 243 SUCCESS Total MapReduce CPU Time Spent: 5 seconds 540 msec OK col1 col2 Time taken: 26.271 seconds #查詢 hive (default)> select * from test_table; test_table.col1 test_table.col2 2 bbb 3 ccc 4 ddd Time taken: 0.205 seconds, Fetched: 3 row(s) 10,had001 jps root@had001:/home/hive# jps 6675 SecondaryNameNode 6426 NameNode 6908 ResourceManager 8382 Jps 11,had002,had003 jps root@had002:~# jps 3300 DataNode 3430 NodeManager 5610 Jps #查看是否能鏈接had001 root@had002:~# /home/hadoop/bin/hdfs dfsadmin -report root@had003:~# /home/hadoop/bin/hdfs dfsadmin -report #正常有data目錄 root@had002:~# tree /usr/local/hadoop/tmp /usr/local/hadoop/tmp ├── dfs │ └── data │ ├── current │ │ ├── BP-1834162669-172.17.252.52-1532682436448 │ │ │ ├── current │ │ │ │ ├── finalized 12,錯誤 1,Exception in thread "main" java.lang.RuntimeException: com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x8 at [row,col,system-id]: [3213,96,"file:/home/appleyuchi/apache-hive-3.0.0-bin/conf/hive-site.xml"] 解決: /home/appleyuchi/apache-hive-3.0.0-bin/conf/hive-site.xml 上面的第3213行,第96個字符是非法字符,註釋掉就好了 2,hadoop cluder could only be written to 0 of the 1 minReplication nodes 緣由是had002,had003連不了had001
參考mysql
https://dzone.com/articles/how-configure-mysql-metastoresql
http://dwgeek.com/hive-create-table-command-examples.html/apache
https://blog.csdn.net/yuyanhsf/article/details/81000522vim
您有什麼不一樣的意見或見解? 歡迎留言共同窗習,謝謝。app
本文連接:http://www.hihubs.com/article/343ide
關鍵字:Hadoop 3.0.3 + Hive3.0安裝oop
若無特別註明,文章皆爲Hubs'm原創,轉載請註明出處...O(∩_∩)O