Using Source

One of the design goals of JetStream was to be native to core NATS, so even though we will most certainly add in syntactic sugar to clients to make them more appealing, for this tech preview we will be using plain old NATS.

You will need a copy of the nats-server source locally and will need to be in the jetstream branch.

  1. git clone https://github.com/nats-io/nats-server.git
  2. cd nats-server
  3. git checkout master
  4. go build
  5. ls -l nats-server

Starting the server you can use the -js flag. This will setup the server to reasonably use memory and disk. This is a sample run on my machine. JetStream will default to 1TB of disk and 75% of available memory for now.

  1. nats-server -js

Output

  1. [16928] 2019/12/04 19:16:29.596968 [INF] Starting nats-server version 2.2.0
  2. [16928] 2019/12/04 19:16:29.597056 [INF] Git commit [not set]
  3. [16928] 2019/12/04 19:16:29.597072 [INF] Starting JetStream
  4. [16928] 2019/12/04 19:16:29.597444 [INF] ----------- JETSTREAM (Beta) -----------
  5. [16928] 2019/12/04 19:16:29.597451 [INF] Max Memory: 96.00 GB
  6. [16928] 2019/12/04 19:16:29.597454 [INF] Max Storage: 1.00 TB
  7. [16928] 2019/12/04 19:16:29.597461 [INF] Store Directory: "/var/folders/m0/k03vs55n2b54kdg7jm66g27h0000gn/T/jetstream"
  8. [16928] 2019/12/04 19:16:29.597469 [INF] ----------------------------------------
  9. [16928] 2019/12/04 19:16:29.597732 [INF] Listening for client connections on 0.0.0.0:4222
  10. [16928] 2019/12/04 19:16:29.597738 [INF] Server id is NAJ5GKP5OBVISP5MW3BFAD447LMTIOAHFEWMH2XYWLL5STVGN3MJHTXQ
  11. [16928] 2019/12/04 19:16:29.597742 [INF] Server is ready

You can override the storage directory if you want.

  1. nats-server -js -sd /tmp/test

Output

  1. [16943] 2019/12/04 19:20:00.874148 [INF] Starting nats-server version 2.2.0
  2. [16943] 2019/12/04 19:20:00.874247 [INF] Git commit [not set]
  3. [16943] 2019/12/04 19:20:00.874273 [INF] Starting JetStream
  4. [16943] 2019/12/04 19:20:00.874605 [INF] ----------- JETSTREAM (Beta) -----------
  5. [16943] 2019/12/04 19:20:00.874613 [INF] Max Memory: 96.00 GB
  6. [16943] 2019/12/04 19:20:00.874615 [INF] Max Storage: 1.00 TB
  7. [16943] 2019/12/04 19:20:00.874620 [INF] Store Directory: "/tmp/test/jetstream"
  8. [16943] 2019/12/04 19:20:00.874625 [INF] ----------------------------------------
  9. [16943] 2019/12/04 19:20:00.874868 [INF] Listening for client connections on 0.0.0.0:4222
  10. [16943] 2019/12/04 19:20:00.874874 [INF] Server id is NCR6KDDGWUU2FXO23WAXFY66VQE6JNWVMA24ALF2MO5GKAYFIMQULKUO
  11. [16943] 2019/12/04 19:20:00.874877 [INF] Server is ready

These options can also be set in your configuration file:

  1. // enables jetstream, an empty block will enable and use defaults
  2. jetstream {
  3. // jetstream data will be in /data/nats-server/jetstream
  4. store_dir: "/data/nats-server"
  5. // 1GB
  6. max_memory_store: 1073741824
  7. // 10GB
  8. max_file_store: 10737418240
  9. }