Mongodb Mongo 가져오기가 너무 큽니다.오류 구문 분석 실패
나는 유효한 MongoDB 70mb json 파일로 가져오려고 합니다.하지만 이 오류는 반복적으로 발생합니다.
01 11:42:20 exception:BSON representation of supplied JSON is too large: Failure parsing JSON string near: "name": "L
01 11:42:20
01 11:42:20 Assertion: 10340:Failure parsing JSON string near: "link": "h
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 kernel32.dll BaseThreadInitThunk+0x12
01 11:42:20 ntdll.dll RtlInitializeExceptionChain+0xef
01 11:42:20 exception:BSON representation of supplied JSON is too large: Failure parsing JSON string near: "link": "h
01 11:42:20
01 11:42:20 Assertion: 10340:Failure parsing JSON string near: }
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 kernel32.dll BaseThreadInitThunk+0x12
01 11:42:20 ntdll.dll RtlInitializeExceptionChain+0xef
01 11:42:20 exception:BSON representation of supplied JSON is too large: Failure parsing JSON string near: }
01 11:42:20
01 11:42:20 Assertion: 10340:Failure parsing JSON string near: ],
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 mongoimport.exe ???
01 11:42:20 kernel32.dll BaseThreadInitThunk+0x12
01 11:42:20 ntdll.dll RtlInitializeExceptionChain+0xef
01 11:42:20 exception:BSON representation of supplied JSON is too large: Failure parsing JSON string near: ],
JSON(JSON의 작은 예)은 다음과 같은 많은 구조로 구성되어 있습니다.
[
{
"data": [
"id": "xxxxxxxxxxxxxxxxxx",
"from": {
"name": "yyyyyyyyyyy",
"id": "1111111111111"
},
"to": {
"data": [
{
"version": 1,
"name": "1111111111111",
"id": "1111111111111"
}
]
},
"picture": "fffffffffffffffffffffff.jpg",
"link": "http://www.youtube.com/watch?v=qqqqqqqqqqqqq",
"source": "http://www.youtube.com/v/qqqqqqqqqqqqq?version=3&autohide=1&autoplay=1",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"description": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/xxx/r/dddd",
"actions": [
{
"name": "Comment",
"link": "http://www.example.com/1111111111111/posts/1111111111111"
},
{
"name": "Like",
"link": "http://www.example.com/1111111111111/posts/1111111111111"
}
],
"privacy": {
"value": ""
},
"type": "video",
"created_time": 1356953890,
"updated_time": 1356953890,
"likes": {
"data": [
{
"name": "jjj ",
"id": "59xxx67"
},
{
"name": "xxxxx",
"id": "79xxx27"
}
],
"count": 2
},
"comments": {
"count": 0
}
},
....
....
....
}
]
이것은 json ":
[
{
"data": [
{
}
],
"paging": {
"previous": "link",
"next": "link"
}
},
"data": [
{
}
],
"paging": {
"previous": "link",
"next": "link"
}
},
"data": [
{
}
],
"paging": {
"previous": "link",
"next": "link"
}
}
]
다음을 사용하는 대신:
mongoimport -d DATABASE_NAME -c COLLECTION_NAME --file YOUR_JSON_FILE
다음 명령을 사용합니다.
mongoimport -d DATABASE_NAME -c COLLECTION_NAME --file YOUR_JSON_FILE --jsonArray
저의 경우, 제 파일이 실제로 너무 크지 않아서 오류 메시지가 오해를 불러일으켰습니다.각 문서를 한 줄로 묶거나 사용해야 했습니다.--jsonArray
.
다음과 같이 파일을 변경합니다.
{ "_id" : "xxxxxxxx", "foo" : "yyy", "bar" : "zzz" }
또는 가져오기 명령을 다음으로 변경합니다.
mongoimport -d [db_name] -c [col_name] --file [file_with_multi_lined_docs] --jsonArray
내 파일이 다중 행/스캐너 형식으로 유지되는 경우
{
"_id" : "xxxxxxxx",
"foo" : "yyy",
"bar" : "zzz"
}
당신의 json 파일은 오직 레코드 목록을 포함하고 있습니까?data
필드? 이 경우 json 파일을 다음과 같은 레코드 목록으로 다시 포맷해야 합니다.
{
"id": "xxxxxxxxxxxxxxxxxx",
"from": {
"name": "yyyyyyyyyyy",
"id": "1111111111111"
},
"to": {
"data": [
{
"version": 1,
"name": "1111111111111",
"id": "1111111111111"
}
]
},
......
}
{
"id": "xxxxxxxxxxxxxxxxxx",
"from": {
"name": "yyyyyyyyyyy",
"id": "1111111111111"
},
"to": {
"data": [
{
"version": 1,
"name": "1111111111111",
"id": "1111111111111"
}
]
},
......
}
json 파일 형식이 양호한 경우 몇 개의 선행/종결 행만 편집하면 됩니다.
편집: 다음이 필요할 수 있습니다.--jsonArray
유효한 json 파일에서 가져올 옵션입니다.해라
mongoimport --db DATABASE_NAME --collection COLLECTION_NAME --file YOUR_JSON_FILE --jsonArray
mongo 버전을 확인해보세요. mongo 2.6.1에서 json을 내보내고 mongo ~2.4로 가져오려고 하는데 문제가 있었습니다. 더 높은 버전을 설치한 후 작업이 가능했습니다.
이 오류가 발생했을 때 로컬 컴퓨터(vim)에서 원격 서버(vim)로 데이터를 복사하여 붙여넣는 것이 문제였습니다.내가 할 때scp
대신에 그것은 기적적으로 작동했습니다. 그래서 그것을 복사할 때 무엇이 변경되었는지 알 수 없습니다. 특히 Mac에서 Centos로 복사할 때, 라인 종료 문제가 없습니다.
결론: 작성한 파일을 내용이 아닌 사용하세요!
언급URL : https://stackoverflow.com/questions/14109474/mongodb-mongoimport-too-large-failure-parsing-errors
'source' 카테고리의 다른 글
"어레이/포인터 동등성"을 뜻하는 현대 용어는 무엇입니까? (0) | 2023.07.03 |
---|---|
"git reset"과 "git checkout"의 차이점은 무엇입니까? (0) | 2023.07.03 |
도커 컴포지트를 사용하여 mongodb에 연결하는 방법은 무엇입니까? (0) | 2023.07.03 |
분기를 로컬로 제거하는 방법은 무엇입니까? (0) | 2023.07.03 |
Spring Boot 테스트 - bootstrap.properties 재정의 (0) | 2023.07.03 |