# How should I loading data

**URL:** <https://discuss.dgraph.io/t/how-should-i-loading-data/10006>\
**Category:** Dgraph\
**Tags:** dataset, kind:question\
**Created:** [September 3, 2020, 4:10pm UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006 "2020-09-03T16:10:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![youyin123](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/youyin123/32/4685_2.png) [@youyin123](https://discuss.dgraph.io/u/youyin123)\
**Post date:** [September 3, 2020, 4:10pm UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006/1 "2020-09-03T16:10:20Z")

</div>

I loading rdf data always wrong!!

I want to load a rdf data:  
first, I run :

```auto
docker run --rm -it -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ~/dgraph:/dgraph dgraph/standalone:v20.03.0

```

second, I tried run :

```auto
dgraph bulk -f 1million.rdf -s 1million.schema --map_shards=4 --reduce_shards=1 --zero=localhost:5080

```

then tell wrong:

```auto
\pard\intbl\itap1\pardeftab720\partightenfactor0
\cf4 \cell 
\pard\intbl\itap1\pardeftab720\partightenfactor0
\cf2 \cb3 email : string @index(exact) @upsert .\cell \lastrow\row
} at line 1 column 1: Invalid schema. Unexpected \
github.com/dgraph-io/dgraph/lex.(*Lexer).ValidateResult
	/ext-go/1/src/github.com/dgraph-io/dgraph/lex/lexer.go:199
github.com/dgraph-io/dgraph/schema.Parse
	/ext-go/1/src/github.com/dgraph-io/dgraph/schema/parse.go:443
github.com/dgraph-io/dgraph/dgraph/cmd/bulk.readSchema
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/bulk/loader.go:168

```

so I tried another way:

```auto
dgraph live -f 1million.rdf

```

then tell wrong:

```auto
Error while mutating: Uid: [11975888102877534808] cannot be greater than lease: [10000] s.Code Unknown

```

I tried :

```auto
curl "http://localhost:6080/assign?what=uids&num=10000000000000000000"

```

this result is :

```auto
{"startId":"9997475252299124063","endId":"1550731178589572446"}(base) MacBook-Pro:~ dengjun$ 

```

then I tried agian:

```auto
dgraph live -f 1million.rdf

```

it is also said “cannot be greater than lease: [10000] s.Code Unknown”  
呵呵哒！！  
吐血了！！  
some one could tell me why???  
I just want to load data!!  
哭

---

<div class="post-metadata">

**Author:** ![ajeet](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/ajeet/32/4161_2.png) [@ajeet](https://discuss.dgraph.io/u/ajeet)\
**Post date:** [September 3, 2020, 5:14pm UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006/2 "2020-09-03T17:14:05Z")

</div>

Hey @youyin123,

In the bulk loader command, you’re using port 5080, but you haven’t exposed it via Docker. You might need to add `-p 5080:5080` before you’re able to access that port.

Additionally, you’re using the Dgraph standalone image, which starts up a Zero as well as an Alpha instance. The bulk loader is supposed to be run before the cluster is set up (that is, before the Alpha is started). If your cluster is already set up, you should use the Live Loader instead.

Here’s the bulk loader documentation: [https://dgraph.io/docs/deploy/fast-data-loading/#bulk-loader](https://dgraph.io/docs/deploy/fast-data-loading/#bulk-loader)

The error you’ve shown, though, seems to be a parse error which shouldn’t be happening unless the schema file has been modified - could you redownload the schema and check?

In the live loader command you’ve used, you’re missing the schema file (`-s 1million.schema`).

---

<div class="post-metadata">

**Author:** ![youyin123](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/youyin123/32/4685_2.png) [@youyin123](https://discuss.dgraph.io/u/youyin123)\
**Post date:** [September 3, 2020, 11:31pm UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006/3 "2020-09-03T23:31:54Z")

</div>

@ajeet  
sorry, I have no idea what’s your mean.  
I’m not a profession.  
could you tell me What terminal command to run, I mean starting from zero…

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [September 5, 2020, 4:36am UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006/4 "2020-09-05T04:36:06Z")

</div>

> [@youyin123](#):
>
> could you tell me What terminal command to run, I mean starting from zero…

If you are running docker, you should load it inside the container. You can’t do (you can, but you will complicate the whole process) a Bulkload from an external place to a “remote” (in this case, Docker is our “remote” as it lives inside a virtual machine).

What you have to do is to copy the data into the container. There are two ways to do it.

1. Using Docker copy [docker cp | Docker Docs](https://docs.docker.com/engine/reference/commandline/cp/)  
e.g:

```auto
docker cp 1million.rdf mycontainer:/1million.rdf
docker cp 1million. schema mycontainer:/1million. schema

```

That way you have the files transferred from the host to the docker container.

1. Use some download tool like curl. In the case of Dgraph’s docker image, you have only curl available. You can do the following.

```auto
curl -L -o 1million.rdf.gz "https://github.com/dgraph-io/tutorial/blob/master/resources/1million.rdf.gz?raw=true"

```

As said Ajeet. You can’t run a Dgraph Alpha at the same time you use the bulkloader. So, you have to start the Alpha after the load. Also you probably know that the bulkload separates the posting list files at `out/${a number here starting from zero}/p/*`. You have or use this path or move the p directory to a path of your choice. And then start the Alpha pointing to that path.

If you wanna make things easy, you should use Liveloader instead. Using liveloader you can just start you cluster and load the data “remotely”. From the host to the container pointing to the localhost or (in case of a Virtual Machine) to the VM IP.

If your docker is native and runs at localhost

```auto
dgraph live -a localhost:9080 -z localhost:5080 -f 1million.rdf -s 1million. schema

```

If your docker isn’t native, you have to find its IP. In general, is something like 192.168.99.100

```auto
dgraph live -a 192.168.99.100:9080 -z 192.168.99.100:5080 -f 1million.rdf -s 1million. schema

```

> [@youyin123](#):
>
> `Error while mutating: Uid: [11975888102877534808] cannot be greater than lease: [10000] s.Code Unknown`

This is probably happening due to some confusion about one of the tools (live and bulk). If you use bulkloader with a zero that already has been used, this error may happen. You should start from scratch in both cases. Unless you are used to Dgraph you can try other ways of loading data with an already running cluster.

Cheers.

---

<div class="post-metadata">

**Author:** ![youyin123](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/youyin123/32/4685_2.png) [@youyin123](https://discuss.dgraph.io/u/youyin123)\
**Post date:** [September 6, 2020, 4:27am UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006/5 "2020-09-06T04:27:59Z")

</div>

@MichelDiz  
thank you!  
finally I used curl -H “Content-Type: application/rdf” “localhost:8080/mutate?commitNow=true” -XPOST -d $’ to load data, it worked!

but now I have another question:  
when I load data, may have 1000000 rows, I don’t know exact rows, anyway load failed.  
but when I load 10000 rows , it worked… why???

may be I load too much data, now I can not run dgraph.  
I used

```auto
docker run --rm -it -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ~/dgraph:/dgraph dgraph/standalone:v20.03.0

```

to run dgraph, but there have error:

```auto
time" > > tablets:<key:"starring" value:<group_id:1 predicate:"starring" > > tablets:<key:"studyAt" value:<group_id:1 predicate:"studyAt" > > tablets:<key:"tag_name" value:<group_id:1 predicate:"tag_name" > > tablets:<key:"tagged" value:<group_id:1 predicate:"tagged" > > tablets:<key:"tagline" value:<group_id:1 predicate:"tagline" > > tablets:<key:"title" value:<group_id:1 predicate:"title" > > tablets:<key:"type" value:<group_id:1 predicate:"type" > > tablets:<key:"url" value:<group_id:1 predicate:"url" > > tablets:<key:"workAt" value:<group_id:1 predicate:"workAt" > > tablets:<key:"workFrom" value:<group_id:1 predicate:"workFrom" > > snapshot_ts:392 checksum:17010297955161069008 > > zeros:<key:1 value:<id:1 addr:"localhost:5080" leader:true > > maxLeaseId:18446055125929158704 maxTxnTs:270000 maxRaftId:1 cid:"e327aa51-9f33-40af-9a52-3dd9e1bfaa73" license:<maxNodes:18446744073709551615 expiryTs:1601690748 enabled:true > 
I0906 04:21:04.080012 14 log.go:34] 1 is starting a new election at term 31
I0906 04:21:04.080052 14 log.go:34] 1 became pre-candidate at term 31
I0906 04:21:04.080059 14 log.go:34] 1 received MsgPreVoteResp from 1 at term 31
I0906 04:21:04.080209 14 log.go:34] 1 became candidate at term 32
I0906 04:21:04.080243 14 log.go:34] 1 received MsgVoteResp from 1 at term 32
I0906 04:21:04.080571 14 log.go:34] 1 became leader at term 32
I0906 04:21:04.080734 14 log.go:34] raft.node: 1 elected leader 1 at term 32
I0906 04:21:04.080919 14 groups.go:856] Leader idx=0x1 of group=1 is connecting to Zero for txn updates
I0906 04:21:04.080950 14 groups.go:865] Got Zero leader: localhost:5080
W0906 04:21:04.082166 14 draft.go:1146] Raft.Ready took too long to process: Timer Total: 5.162s. Breakdown: [{advance 5.162s} {disk 0s} {proposals 0s}] Num entries: 0. MustSync: false
W0906 04:21:04.348876 14 draft.go:1146] Raft.Ready took too long to process: Timer Total: 219ms. Breakdown: [{proposals 219ms} {disk 1ms} {sync 0s} {advance 0s}] Num entries: 1. MustSync: true
W0906 04:21:04.647158 14 draft.go:1146] Raft.Ready took too long to process: Timer Total: 274ms. Breakdown: [{proposals 274ms} {disk 0s} {advance 0s}] Num entries: 0. MustSync: false

```

I restart the computer. It doesn’t work.  
do you know why???

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [September 6, 2020, 4:34am UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006/6 "2020-09-06T04:34:23Z")

</div>

> [@youyin123](#):
>
> I used curl -H “Content-Type: application/rdf” “localhost:8080/mutate?commitNow=true” -XPOST -d $’ to load data, it worked!
> 
> but now I have another question:  
> when I load data, may have 1000000 rows, I don’t know exact rows, anyway load failed.  
> but when I load 10000 rows , it worked… why???

We recommend for clusters with few resources, that you create batches transactions between 1k and 5k n-triples. 1 million is too much for a single transaction. If you use cURL, you will end up creating a huge transaction that your instances can’t handle.

You could do this if you have a lot of resources or if you use ludicrous mode. Otherwise, please, use the liveloader with the default values.

Cheers.

PS

> [@youyin123](#):
>
> `-p 8080:8080 -p 9080:9080 -p 8000:8000`

Feels like you’re not exposing the Zero port 5080. You need this port to use in the liveload remotely.

---

<div class="post-metadata">

**Author:** ![youyin123](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/youyin123/32/4685_2.png) [@youyin123](https://discuss.dgraph.io/u/youyin123)\
**Post date:** [September 6, 2020, 7:23am UTC](https://discuss.dgraph.io/t/how-should-i-loading-data/10006/7 "2020-09-06T07:23:01Z")

</div>

thank you
