搜尋
首頁php教程php手册php连接hive各种问题记录

一、hive方面 hive有三种模式:cli、hwi、hiveserver; cli:即shell命令行 hwi:是通过浏览器访问 hiveserver:也就是JDBC/ODBC接口 其中hwi没有用到 深入浅出学hive:http://sishuok.com/forum/blogPost/list/6220.html(初学hive,这个系列介绍的很不错)

一、hive方面

hive有三种模式:cli、hwi、hiveserver;

cli:即shell命令行

hwi:是通过浏览器访问

hiveserver:也就是JDBC/ODBC接口

其中hwi没有用到

深入浅出学hive:http://sishuok.com/forum/blogPost/list/6220.html(初学hive,这个系列介绍的很不错)

启动hiveserver:

1.org.apache.thrift.transport.TTransportException: Could not create ServerSocket on address 0.0.0.0/0.0.0.0:10000.

可能原因:默认端口10000已被占用

查看端口是否被占用: netstat -ntulp | grep ':10000'

发现被一个java进程占用

解决方法:另起端口开启hiveserver:hive --service hiveserver -p 10001

2.启动hiveserver卡住

网上一些博客解释说是已经在运行,不用担心http://www.cnblogs.com/sh91/archive/2012/08/03/2621911.html

启动hive(cli)

1.执行语句出错(例如show tables)

FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

可能原因:metadata相关,也就是和连接mysql有关了(采用mysql作为hive的元数据库)

采用debug模式启动hive cli:hive -hiveconf hive.root.logger=DEBUG,console

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Caused by: java.net.ConnectException: 骁豢妤(这边有点乱码问题,是windows下的ssh软件造成的)

Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

Caused by: java.lang.reflect.InvocationTargetException

Caused by: javax.jdo.JDOFatalDataStoreException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
NestedThrowables:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure


二、mysql方面

登陆mysql出错:mysql -uhive -p

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

查看mysql运行状态:/etc/rc.d/init.d/mysqld status

发现mysql已停

root权限下启动mysql:service mysqld start(失败);、etc/init.d/mysqld start(也失败)

提示:Another MySQL daemon already running with the same unix socket.

关闭所有mysqld进程:killall -9 mysqld

考虑卸载原装mysql:http://www.jb51.net/os/RedHat/1146.html  http://www.2cto.com/os/201108/100257.html  http://blog.csdn.net/monkey_d_meng/article/details/5573610

查找mysql相关包:rpm -qa|grep mysql
mysql-server-5.1.71-1.el6.i686   变成not installed(why???)
mysql-connector-java-5.1.17-6.el6.noarch   OK!
mysql-5.1.71-1.el6.i686      OK!
libdbi-dbd-mysql-0.8.3-5.1.el6.i686   OK!
mysql-libs-5.1.71-1.el6.i686     变成not installed(why???)
mod_auth_mysql-3.0.0-11.el6_0.1.i686     OK!
mysql-connector-odbc-5.1.5r1144-7.el6.i686  OK!
php-mysql-5.3.3-26.el6.i686     OK!
mysql-devel-5.1.71-1.el6.i686    OK!
qt-mysql-4.6.2-26.el6_4.i686    OK!
删除相关包的命令: rpm -e --nodeps (包名)
接下来删除mysql:  rm -fr /usr/lib/mysql     rm -fr /usr/include/mysql(/usr/include目录下没有mysql)
rm -f /etc/my.cnf      rm -rf /var/lib/mysql
验证: sudo yum -y remove mysql-5.1.71-1.el6.i686
提示:Loaded plugins: refresh-packagekit, security
      Setting up Remove Process
      No Match for argument: mysql-5.1.71-1.el6.i686
      Package(s) mysql-5.1.71-1.el6.i686 available, but not installed.
      No Packages marked for removal
证明已经删除成功!

再根据官方说明(http://dev.mysql.com/doc/refman/5.6/en/linux-installation-rpm.html)查找了相关目录,都已经没有mysql

接下来,手动安装自己的mysql
mysql官方推荐:

The recommended way to install MySQL on RPM-based Linux distributions that useglibc is by using the RPM packages provided by MySQL. There are two methods for doing so: for EL6-based platforms and Fedora 18 and 19, this can be done using the MySQL Yum repository (seediv 2.5.1, “Installing MySQL on Linux Using the MySQL Yum Repository” for details)

因此,通过rpm来安装,按照官网教程进行安装

安装成功,终于可以正常启动mysql了!

再重新为hive创建用户跟数据库就可以了(注意和配置文件hive-site.xml对应)

3.php连接相关

前提:开启hadoop(2.2.0版本改为start-dfs.sh和start-yarn.sh)

开启hiveserver(当然mysql也是要开起来)

php文件放在/wamp/www/下

在浏览器输入/localhost/hiveconnect.php就可以看到了

问题:

输入url,一直等待localhost,hive日志内容只有session相关信息

解决:

TException TSocket tiomeout:

这个问题最后并没有解决,只是发现hive大多数用于内网应用,于是直接往内网发展,连接一切正常。

4.hadoop方面

启动hadoop:start-dfs.sh start-yarn.sh

各个进程正常启动,但是之后发生问题,nodemanager shutdown:

org.apache.hadoop.yarn.exceptions.YarnRuntimeException: org.apache.hadoop.net.ConnectTimeoutException: Call From sipedi-idc-gysj/220.250.64.225 to 0.0.0.0:8031 failed on socket timeout exception: org.apache.hadoop.net.ConnectTimeoutException: 20000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=0.0.0.0/0.0.0.0:8031];

这个问题也是出现在外网服务器上,和PHP连接的问题一样,改到内网应用,就没有再出现,但是估计这个问题应该是跟服务器的linux版本以及hadoop的具体配置有关,具体YARN的运行机制等到寒假再研究。

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境