lease 메커니즘으로 hdfs 파일 만들기 실패

3493 단어 hadoop
최근에 hadoop에 관한 임대 문제가 생겼는데, 지금 그것을 기록합니다
12716 [main] WARN  org.apache.sqoop.tool.EvalSqlTool  - SQL exception executing statement: org.postgresql.util.PSQLException: , error: Failed to CREATE_FILE /hawq_data/ExtErrTbl/36f70260-6e94-44d0-900c-9d9210eeac5e/1545749452717109 for libhdfs3_client_random_1582511411_count_2_pid_506717_tid_140176099782080 on  

because this file lease is currently owned by libhdfs3_client_random_1582511411_count_2_pid_506733_tid_140176099782080 on  (extfmtcsv.c:189)  (seg1 :40000 pid=506717)
   :

	at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.recoverLeaseInternal(FSNamesystem.java:3190)
	at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInternal(FSNamesystem.java:2809)
	at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInt(FSNamesystem.java:2698)
	at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFile(FSNamesystem.java:2582)
	at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.create(NameNodeRpcServer.java:736)
	at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.create(ClientNamenodeProtocolServerSideTranslatorPB.java:409)
	at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
	at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:640)
	at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:982)
	at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2351)
	at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2347)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1866)
	at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2347)
 (786949)

위의 문제에서 알 수 있듯이 파일이hdfs에 잠겨서 다시 만들 수 없어서 sql 오류가 발생했습니다.그것은 왜 임대되었을까요? 이것은 hdfs의 임대 메커니즘을 말해야 합니다.다음은 한 사나이의 해답이다
1.Lease의 메커니즘:hdfs는 write-once-read-many를 지원한다. 즉, 병행 쓰기를 지원하지 않는다. 그러면 읽기와 쓰기에 대한 상호 배척 동기화는 Lease에 의해 이루어진다.Lease가 말하자면 시간의 제약이 있는 자물쇠다.클라이언트가 파일을 쓸 때 먼저 Lease를 신청해야 합니다.namenode의 Lease Manager에 대응하면 클라이언트의clientname는lease의holder, 즉 임대차 계약 소지자로서 사용됩니다.LeaseManager는 파일의 path와lease의 대응 관계, 그리고clientname->lease의 대응 관계를 유지합니다.LeaseManager에는 두 가지 시간 제한이 있습니다: soft Limitand hard Limit.소프트 제한은 파일을 쓸 때 규정된 임대차 계약 시간 초과이고, 하드 제한은 파일close시 미래에lease를 방출해야 하는 상황을 고려하여 임대차 계약을 강제로 회수하는 것이다.LeaseManager에는 Lease가 hardLimit을 초과하는지 확인하는 모니터 라인이 있습니다.소프트웨어 임대 계약의 시간 초과 검사는 DFSClient의 LeaseChecker에서 진행된다.클라이언트(DFSClient)가 파일을 만들 때, RPC를 통해namenode의createFile 방법을 호출하여 파일을 만듭니다.더 나아가 FSNameSystem의 startFile 방법을 호출하고, LeaseManager의addLease 방법을 호출하여 새로 만든 파일에lease를 추가합니다.lease가 존재하면, 이 lease의lastUpdate (최근 업데이트 시간) 값을 업데이트하고, 이 파일의 path를 lease에 맞춥니다.그런 다음 DFSClient는 LeaseChecker에 이 파일의 path를 추가합니다.파일이 생성되면 수호 스레드 LeaseChecker는 DFSClient가 가지고 있는 lease를 일정 시간 간격으로 갱신합니다.LeaseManagement는 HDFS의 동기화 메커니즘으로 같은 시간에 클라이언트 하나만 파일을 쓰거나 만들 수 있도록 합니다.만약 새 파일 f를 만들 때,client가 NameNode에create 요청을 하면,lease Manager는 이 클라이언트가 f 파일의lease를 분배할 것이라고 생각합니다.client는 이lease로 파일 생성 작업을 완성합니다.이 때 다른 클라이언트는 f를 얻을 수 없습니다. 클라이언트가 장시간 (기본적으로 1min을 초과함) 작업을 하지 않을 때 발급된lease는 회수됩니다.
최종 해결 방법
우리는 단지 소프트 시간 초과 기본 시간을 원래의 1분에서 줄이기만 하면 된다. dfs 클라이언트가 1분 안에 조작하지 않으면lease 자물쇠를 회수할 수 있다
hdfs.regionserver.lease.period=60000 기본값 60000ms
 
참조 주소:http://www.aboutyun.com/thread-17620-1-1.html

좋은 웹페이지 즐겨찾기