[hadoop@admin1 bin]$ ./beeline
Beeline version 1.2.1 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: hadoop
Enter password for jdbc:hive2://localhost:10000:
Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000: java.net.ConnectException: 拒绝连接 (state=08S01,code=0)
0: jdbc:hive2://localhost:10000 (closed)>
这里默认的用户名就是启用hadoop的用户名 : hadoop
Enter username for jdbc:hive2://localhost:10000: hadoop
如果在这里面没有密码直接enter即可:
Enter password for jdbc:hive2://localhost:10000:
出现上面的报错原因最有可能的就是没有开启服务:
解决方法:新打开一个窗口,输入如下所示 :
[hadoop@admin1 apache-hive-1.2.1-bin]$ bin/hiveserver2
然后重新启动得到以下结果:
[hadoop@admin1 bin]$ ./beeline
Beeline version 1.2.1 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: hadoop
Enter password for jdbc:hive2://localhost:10000:
Connected to: Apache Hive (version 1.2.1)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000>
到此,Hadoop中的hiveserver2 就能启动端口 10000 开启服务。