1. 查看NameNode状态
先来分享两条查看NameNode节点状态的命令:
hdfs haadmin -getServiceState nn1
hdfs haadmin -getServiceState nn2
2. 寻找错误
接着上一篇来吧,不过这次我们通过master001来写入文件,使用lhd数据库,然后使用以下命令创表:
create external table person(
id int,
name string,
age int,
fav array<string>,
addr map<string, string>
)
comment 'This is the person table'
row format delimited fields terminated by '\t'
collection items terminated by '-'
map keys terminated by ':'
stored as textfile
location 'hdfs://master001:9000/input/';
再来查看表目录:
还是没找到,然后我查看person表发现出现了新的bug:
FAILED: SemanticException Unable to determine if hdfs://master001:9000/input is encrypted: java.lang.IllegalArgumentException: Wrong FS: hdfs://master001:9000/input, expected: hdfs://mycluster
出错原因:因为已经设置了NameNode高可用,产生的HDFS路径不对。
查看DBS表:
查看SDS表:
结果发现其LOCATION标记的是master001节点,应该更改为mycluster:
update SDS set LOCATION = REPLACE(LOCATION,'master001:9000','mycluster');
再来查看:
3. 结论
正确的创表语句:
create external table person(
id int,
name string,
age int,
fav array<string>,
addr map<string, string>
)
comment 'This is the person table'
row format delimited fields terminated by '\t'
collection items terminated by '-'
map keys terminated by ':'
stored as textfile
location 'hdfs://mycluster/input/';
location指定的时候应当直接指定mycluster集群,而不是指定集群上某一个节点。