6.配置hive-log4j.properties
log4j.appender.EventCounter=org.apache.Hadoop.log.metrics.EventCounter 修改这一行
这里请注意,我修改后启动hive报错,恢复原状就没事了,大家可以试试
7.检查hadoop集群状态
[grid@h1 conf]$ hadoop dfsadmin -report
Configured Capacity: 19865944064 (18.5 GB)
Present Capacity: 8831234048 (8.22 GB)
DFS Remaining: 8816201728 (8.21 GB)
DFS Used: 15032320 (14.34 MB)
DFS Used%: 0.17%
Under replicated blocks: 4
Blocks with corrupt replicas: 0
Missing blocks: 0
-------------------------------------------------
Datanodes available: 2 (2 total, 0 dead) 没有问题2个slave运行正常
Name: 192.168.2.103:50010
Decommission Status : Normal
Configured Capacity: 9932972032 (9.25 GB)
DFS Used: 7516160 (7.17 MB)
Non DFS Used: 5402759168 (5.03 GB)
DFS Remaining: 4522696704(4.21 GB)
DFS Used%: 0.08%
DFS Remaining%: 45.53%
Last contact: Mon Nov 19 17:51:50 CST 2012
Name: 192.168.2.105:50010
Decommission Status : Normal
Configured Capacity: 9932972032 (9.25 GB)
DFS Used: 7516160 (7.17 MB)
Non DFS Used: 5631950848 (5.25 GB)
DFS Remaining: 4293505024(4 GB)
DFS Used%: 0.08%
DFS Remaining%: 43.22%
Last contact: Mon Nov 19 17:51:48 CST 2012
8.修改MySQL字符集
mysql> use hive;
Database changed
mysql> alter database hive character set latin1;
Query OK, 1 row affected (0.11 sec)
9.启动hive
[grid@h1 bin]$ pwd
/home/grid/hive-0.8.1/bin
[grid@h1 bin]$ ./hive
[grid@h1 bin]$ ./hive
Logging initialized using configuration in file:/home/grid/hive-0.8.1/conf/hive-log4j.properties
Hive history file=/tmp/grid/hive_job_log_grid_201211191942_411407039.txt
hive> show tables; 显示表,没有创建当然没有
OK
Time taken: 3.2 seconds
hive> create table leo1 (x int,y int); 创建表
OK
Time taken: 1.191 seconds
hive> show tables; 可以显示出来了
OK
leo1
Time taken: 0.148 seconds
已经进入hive模式,还可以创建表
注明:
当你设置的为本地模式时候
<property>
<name>hive.metastore.local</name>
<value>true</value>
<description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</description>
</property>
[grid@h1 bin]$ ./hive
Logging initialized using configuration in file:/home/grid/hive-0.8.1/conf/hive-log4j.properties
Hive history file=/tmp/grid/hive_job_log_grid_201211231243_664195168.txt
hive> show tables;
OK
leo1
Time taken: 21.218 seconds
直接进入hive命令行shell,后台自动启动metestore服务和hive服务而且这2个服务还是同在一个进程中,不用手工启动,这点和远程模式还是有点不同的。
当你设置的为远程模式时候
[grid@h1 bin]$ ./hive --service hiveserver 这是启动hive服务
Starting Hive Thrift Server
[grid@h1 bin]$ ./hive --service metastore 这是启动元数据存储服务
Starting Hive Metastore Server
正常情况是都在这卡住了,相当于前台启动,如果有异常请关闭当前窗口,另开一个窗口重新启动这2个服务。为什么要手动启动这2个服务呢,因为这2个服务都是相互独立的进程,可以部署在不同的机器上
[grid@h1 bin]$ ./hive
Logging initialized using configuration in file:/home/grid/hive-0.8.1/conf/hive-log4j.properties
Hive history file=/tmp/grid/hive_job_log_grid_201211231324_199334603.txt
hive> show tables; 这里显示创建了2个表,这2个表都是建在HDFS文件系统上的
OK mysql只保存hive用户创建表的元数据
leo1
leo2
Time taken: 0.538 seconds
hive> create table leo2 (x int);
OK
Time taken: 0.317 seconds
进入mysql数据库查看hive创建表的元数据
mysql> use hive;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_hive |
+--------------------+
| bucketing_cols |
| cds |
| columns_v2 |
| database_params |
| dbs |
| idxs |
| index_params |
| part_col_privs |
| part_privs |
| partition_key_vals |
| partition_keys |
| partition_params |
| partitions |
| sd_params |
| sds |
| sequence_table |
| serde_params |
| serdes |
| sort_cols |
| table_params |
|tbl_col_privs |
|tbl_privs |
|tbls |
+--------------------+ 红色的就是hive的数据字典表,这些表第一次连接时就已经创建了,后面就会一直存在,只是里面的元数据内容会跟着hive操作而变化。
23 rows in set (0.00 sec)
mysql> select * from tbls;
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
| TBL_ID | CREATE_TIME | DB_ID | LAST_ACCESS_TIME | OWNER | RETENTION | SD_ID | TBL_NAME | TBL_TYPE | VIEW_EXPANDED_TEXT | VIEW_ORIGINAL_TEXT |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
| 6 | 1353597034 | 1 | 0 | grid | 0 | 6 |leo1 | MANAGED_TABLE | NULL | NULL |
| 11 | 1353648090 | 1 | 0 | grid | 0 | 11 |leo2 | MANAGED_TABLE | NULL | NULL |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
2 rows in set (0.00 sec)
hive> drop table leo2; 我删除了leo2表
OK
Time taken: 1.796 seconds
mysql> select * from tbls; 注意提示符
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
| TBL_ID | CREATE_TIME | DB_ID | LAST_ACCESS_TIME | OWNER | RETENTION | SD_ID | TBL_NAME | TBL_TYPE | VIEW_EXPANDED_TEXT | VIEW_ORIGINAL_TEXT |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
| 6 | 1353597034 | 1 | 0 | grid | 0 | 6 |leo1 | MANAGED_TABLE | NULL | NULL |
+--------+-------------+-------+------------------+-------+-----------+-------+----------+---------------+--------------------+--------------------+
1 row in set (0.00 sec)
Leo2表的元数据也跟着没有了
