作用:将hive变成一种server服务端对外开放,多个客服端可以连接
启动hiveserver:
bin/hiveserver2
启动后:
启动连接:
bin/beeline -u jdbc:hive2://master.cdh.com:10000 -n root -p 123456
结果如下:
查询表:
0: jdbc:hive2://master.cdh.com:10000> select * from emp;
+------------+-------------+------------+----------+---------------+----------+-----------+-------------+--+
| emp.empno | emp.enname | emp.job | emp.mgr | emp.hiredate | emp.sal | emp.comm | emp.deptno |
+------------+-------------+------------+----------+---------------+----------+-----------+-------------+--+
| 7499 | ALLEN | SALESMAN | 7698 | 1981-02-20 | 1600.0 | 300.0 | 30 |
| 7521 | WARD | SALESMAN | 7698 | 1981-02-22 | 1250.0 | 500.0 | 30 |
| 7566 | JONES | MANAGER | 7839 | 1981-04-02 | 2975.0 | 0.0 | 20 |
| 7654 | MARTIN | SALESMAN | 7698 | 1981-09-28 | 1250.0 | 1400.0 | 30 |
| 7698 | BLAKE | MANAGER | 7839 | 1981-05-01 | 2850.0 | 0.0 | 30 |
| 7782 | CLARK | MANAGER | 7839 | 1981-06-09 | 2450.0 | 0.0 | 10 |
| 7788 | SCOTT | ANALYST | 7566 | 1987-07-13 | 3000.0 | 0.0 | 20 |
| 7839 | KING | PRESIDENT | NULL | 1981-11-07 | 5000.0 | 0.0 | 10 |
| 7844 | TURNER | SALESMAN | 7698 | 1981-09-08 | 1500.0 | 0.0 | 30 |
| 7876 | ADAMS | CLERK | 7788 | 1987-07-13 | 1100.0 | 0.0 | 20 |
| 7900 | JAMES | CLERK | 7698 | 1981-12-03 | 950.0 | 0.0 | 30 |
| 7902 | FORD | ANALYST | 7566 | 1981-12-03 | 3000.0 | 0.0 | 20 |
| 7934 | MILLER | CLERK | 7782 | 1982-01-23 | 1300.0 | 0.0 | 10 |
+------------+-------------+------------+----------+---------------+----------+-----------+-------------+--+