hive安装问题01

    1、首先,请打开HADOOP再启动Hive,我一开始就是这么天真的以为Hive可以单独使用,所以疯狂的报错,出现以下的错误。其实认真看看报错信息就知道是与Hadoop相关(前提是你的hadoop本身真的是可用的)。

[hadoop@mini01 bin]$ ./hive

Logging initialized using configuration in jar:file:/home/hadoop/apps/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: java.net.ConnectException: Call From mini01/192.168.176.61 to mini01:9000 failed on connection exception: java.net.ConnectException: 拒绝连接; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused
    at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.net.ConnectException: Call From mini01/192.168.176.61 to mini01:9000 failed on connection exception: java.net.ConnectException: 拒绝连接; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.apache.hadoop.net.NetUtils.wrapWithMessage(NetUtils.java:791)
    at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:731)
    at org.apache.hadoop.ipc.Client.call(Client.java:1473)
    at org.apache.hadoop.ipc.Client.call(Client.java:1400)
    at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:232)
    at com.sun.proxy.$Proxy17.getFileInfo(Unknown Source)
    at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getFileInfo(ClientNamenodeProtocolTranslatorPB.java:752)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:187)
    at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
    at com.sun.proxy.$Proxy18.getFileInfo(Unknown Source)
    at org.apache.hadoop.hdfs.DFSClient.getFileInfo(DFSClient.java:1977)
    at org.apache.hadoop.hdfs.DistributedFileSystem$18.doCall(DistributedFileSystem.java:1118)
    at org.apache.hadoop.hdfs.DistributedFileSystem$18.doCall(DistributedFileSystem.java:1114)
    at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
    at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1114)
    at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1400)
    at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:596)
    at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
    at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
    ... 8 more
Caused by: java.net.ConnectException: 拒绝连接
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:735)
    at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:530)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:494)
    at org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:608)
    at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:706)
    at org.apache.hadoop.ipc.Client$Connection.access$2800(Client.java:369)
    at org.apache.hadoop.ipc.Client.getConnection(Client.java:1522)
    at org.apache.hadoop.ipc.Client.call(Client.java:1439)
    ... 28 more

2、你的mysql没有打开远程登录的权限,报错内容主要选段如下(太长太长了,可能也漏点了一些很重要的):

[hadoop@mini01 bin]$ ./hive

Logging initialized using configuration in jar:file:/home/hadoop/apps/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
    at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

----------------------------------------------------------
Caused by: javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true, username = root. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: null,  message from server: "Host 'mini01' is not allowed to connect to this MySQL server"
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)

---------------------------------------------------------
NestedThrowables:
java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true, username = root. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: null,  message from server: "Host 'mini01' is not allowed to connect to this MySQL server"
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)

----------------------------------------------------------  
Caused by: java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true, username = root. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original 
Exception: ------
java.sql.SQLException: null,  message from server: "Host 'mini01' is not allowed to connect to this MySQL server"
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
---------------------------------------------------------
Caused by: java.sql.SQLException: null,  message from server: "Host 'mini01' is not allowed to connect to this MySQL server"
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)

    开启Mysql中的权限

[hadoop@mini01 ~]$ mysql -uroot -p

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

    3、hive中一个为jline的包与hadoop里yarn的包重复了,yarn中的那个包一搬版本都是有点低的,可删除了然后将hive中的jline包添加进hadoop去。报错信息如下:


 [hadoop@mini01 bin]$ ./hive

Logging initialized using configuration in jar:file:/home/hadoop/apps/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
    at jline.TerminalFactory.create(TerminalFactory.java:101)
    at jline.TerminalFactory.get(TerminalFactory.java:158)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
    at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
    at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:230)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
    at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
    at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

    修改步骤如下:

当前目录是hive的lib目录

[hadoop@mini01 lib]$ rm ~/apps/hadoop-2.6.4/share/hadoop/yarn/lib/jline-0.9.94.jar
[hadoop@mini01 lib]$ cp ./jline-2.12.jar  ~/apps/hadoop-2.6.4/share/hadoop/yarn/lib/

祈祷:仙女一定不会有BUG

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下为 CentOS 7 下安装 Apache Hive 的详细步骤: 1. 确认 Java 版本 Hive 需要 Java 7 或更高版本才能运行。请使用以下命令来检查 Java 版本: ``` java -version ``` 如果 Java安装或版本不符合要求,请安装 Java 并设置 JAVA_HOME 环境变量。 2. 下载和安装 Hive 从官方网站(http://hive.apache.org/downloads.html)下载 Hive 的二进制安装包,解压到指定目录下。可以使用以下命令来下载和解压缩 Hive: ``` wget http://mirrors.advancedhosters.com/apache/hive/hive-3.1.2/apache-hive-3.1.2-bin.tar.gz tar -xzvf apache-hive-3.1.2-bin.tar.gz sudo mv apache-hive-3.1.2-bin /usr/local/hive ``` 3. 配置 Hive 3.1 修改环境变量 将 Hive 的 bin 目录添加到 PATH 环境变量中: ``` export PATH=$PATH:/usr/local/hive/bin ``` 3.2 修改 hive-site.xml 复制 hive-default.xml.template 并重命名为 hive-site.xml: ``` cp /usr/local/hive/conf/hive-default.xml.template /usr/local/hive/conf/hive-site.xml ``` 编辑 hive-site.xml 文件,按照以下配置进行修改: ``` <property> <name>hive.metastore.warehouse.dir</name> <value>/usr/local/hive/warehouse</value> <description>location of Hive table</description> </property> <property> <name>hive.metastore.uris</name> <value>thrift://localhost:9083</value> <description>URI for the remote metastore.</description> </property> ``` 3.3 配置 Hive 元数据库 Hive 默认使用 Derby 作为元数据库。如果需要使用 MySQL 或其他 RDBMS 作为元数据库,则需要进行相应的配置。 首先,安装 MySQL 和 MySQL JDBC 驱动程序: ``` sudo yum install mysql-server mysql-connector-java ``` 然后创建 Hive 元数据库,并授予相应权限(这里假设您的 MySQL 用户名是 hiveuser,密码是 password,数据库名是 hive): ``` mysql -u root -p CREATE DATABASE hive; CREATE USER 'hiveuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON hive.* TO 'hiveuser'@'localhost'; FLUSH PRIVILEGES; exit ``` 现在,将以下配置添加到 hive-site.xml 中,以使用 MySQL 作为 Hive 元数据库: ``` <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value> <description>JDBC connect string for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hiveuser</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>password</value> <description>password to use against metastore database</description> </property> ``` 另外,还需要将 MySQL JDBC 驱动程序拷贝到 Hive 的 lib 目录下: ``` sudo cp /usr/share/java/mysql-connector-java.jar /usr/local/hive/lib/ ``` 4. 启动 Hive 元服务 启动 Hive 元服务,可以使用以下命令: ``` hive --service metastore ``` 5. 启动 Hive shell 现在,可以启动 Hive shell,使用以下命令: ``` hive ``` 6. 示例:创建和查询表 以下示例演示如何使用 Hive 创建和查询表: 创建一个名为 sales 的表: ``` CREATE TABLE sales ( id INT, date STRING, amount FLOAT, category STRING ); ``` 向表中插入一些数据: ``` INSERT INTO sales VALUES (1, '2021-01-01', 1000.0, 'Electronics'); INSERT INTO sales VALUES (2, '2021-01-02', 2500.0, 'Clothing'); INSERT INTO sales VALUES (3, '2021-01-03', 3000.0, 'Electronics'); INSERT INTO sales VALUES (4, '2021-01-04', 1500.0, 'Books'); ``` 查询表中的数据: ``` SELECT * FROM sales; ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值