Linux中SparkSQL分布式SQL引擎部署RDB|安裝MySQL+Hive(教程),sparksqlrdb

來源:互聯網
上載者:User

Linux中SparkSQL分布式SQL引擎部署RDB|安裝MySQL+Hive(教程),sparksqlrdb
部署MySQL

# 尋找並刪除本地MySQLrpm -qa | grep mysqlrpm -e mysql-libs-5.1.66-2.el6_3.i686 --nodeps# 安裝指定版本MySQLrpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm rpm -ivh MySQL-client-5.1.73-1.glibc23.i386.rpm # 修改mysql的密碼(直接輸入以下命令執行)/usr/bin/mysql_secure_installation(注意:設定root密碼 並選擇刪除匿名使用者,允許使用者遠端連線)# 登陸mysqlmysql -u root -p

完成基本的MySQL安裝。

接著給Spark SQL添加帳號並開通帳號許可權。預設使用的DB名是hiveMetadata,假設帳號和密碼都是spark,授權SQL可以這樣寫:

mysql> grant all on hiveMetastore.* to spark@'localhost' identified by 'spark';mysql> flush privileges;
準備設定檔conf/hive-site.xml

接下來,我們準備啟動JDBC/ODBC Server,在啟動之前,需要準備以下設定檔。

如果是與現有的Hive一起工作,直接實用Hive的設定檔conf/hive-site.xml即可,或者建立一個,在conf目錄下準備一個名為hive-site.xml的設定檔,其內容如下:

            javax.jdo.option.ConnectionURL        jdbc:mysql://localhost:3306/hiveMetastore?createDatabaseIfNotExist=true        JDBC connect string for a JDBC metastore                javax.jdo.option.ConnectionDriverName        com.mysql.jdbc.Driver        Driver class name for a JDBC metastore                javax.jdo.option.ConnectionUserName        spark        username to use against metastore database                javax.jdo.option.ConnectionPassword        spark        password to use against metastore database                 hive.hwi.war.file        lib/hive-hwi-0.12.0.war        This sets the path to the HWI war file, relative to ${HIVE_HOME}.                 hive.hwi.listen.host        0.0.0.0        This is the host address the Hive Web Interface will listen on                 hive.hwi.listen.port         9999         This is the port the Hive Web Interface will listen on    
啟動JDBC/ODBC Server

現在可以啟動JDBC/ODBC Server了,其命令是:

./sbin/start-thriftserver.sh
使用beeline互動式工具

JDBC/ODBC Server啟動之後,我們可以用beeline來測試啟動是否正常:

./bin/beeline

下面的命令可以串連到JDBC/ODBC Server:

beeline> !connect jdbc:hive2://localhost:10000

也可以在啟動beeline時,直接指定JDBC Server:

./bin/beeline -u 'jdbc:hive2://localhost:10000'

可以修改系統編碼,防止SQL查詢結果中文顯示亂碼。

LANG=zh_CN.UTF-8; ./bin/beeline -u 'jdbc:hive2://localhost:10000'
運行Spark SQL命令列介面
./bin/spark-sql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.