mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
adding JetStream Docs
This commit is contained in:
3
jetstream/getting_started/getting_started.md
Normal file
3
jetstream/getting_started/getting_started.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## Getting Started
|
||||
|
||||
This tech preview is limited to a single server and defaults to the global account. JetStream is NATS 2.0 aware and is scoped to accounts from a resource limit perspective. This is not the same as an individual server's resources, but may feel that way starting out. Don't worry, clustering is coming next but we wanted to get input early from the community.
|
||||
50
jetstream/getting_started/using_docker.md
Normal file
50
jetstream/getting_started/using_docker.md
Normal file
@@ -0,0 +1,50 @@
|
||||
### Using Docker
|
||||
|
||||
The `synadia/jsm:latest` docker image contains both the JetStream enabled NATS Server and the `nats` utility this guide covers.
|
||||
|
||||
In one window start JetStream:
|
||||
|
||||
```
|
||||
$ docker run -ti -p 4222:4222 --name jetstream synadia/jsm:latest server
|
||||
[1] 2020/01/20 12:44:11.752465 [INF] Starting nats-server version 2.2.0-beta
|
||||
[1] 2020/01/20 12:44:11.752694 [INF] Git commit [19dc3eb]
|
||||
[1] 2020/01/20 12:44:11.752875 [INF] Starting JetStream
|
||||
[1] 2020/01/20 12:44:11.753692 [INF] ----------- JETSTREAM (Beta) -----------
|
||||
[1] 2020/01/20 12:44:11.753794 [INF] Max Memory: 1.46 GB
|
||||
[1] 2020/01/20 12:44:11.753822 [INF] Max Storage: 1.00 TB
|
||||
[1] 2020/01/20 12:44:11.753860 [INF] Store Directory: "/tmp/jetstream"
|
||||
[1] 2020/01/20 12:44:11.753893 [INF] ----------------------------------------
|
||||
[1] 2020/01/20 12:44:11.753988 [INF] JetStream state for account "$G" recovered
|
||||
[1] 2020/01/20 12:44:11.754148 [INF] Listening for client connections on 0.0.0.0:4222
|
||||
[1] 2020/01/20 12:44:11.754279 [INF] Server id is NDYX5IMGF2YLX6RC4WLZA7T3JGHPZR2RNCCIFUQBT6C4TP27Z6ZIC73V
|
||||
[1] 2020/01/20 12:44:11.754308 [INF] Server is ready
|
||||
```
|
||||
|
||||
And in another log into the utilities:
|
||||
|
||||
```
|
||||
$ docker run -ti --link jetstream synadia/jsm:latest
|
||||
```
|
||||
|
||||
This shell has the `nats` utility and all other NATS cli tools used in the rest of this guide.
|
||||
|
||||
Now skip to the `Administer JetStream` section.
|
||||
|
||||
### Using Docker with NGS
|
||||
|
||||
You can join a JetStream instance to your [NGS](https://synadia.com/ngs/pricing) account, first we need a credential for testing JetStream:
|
||||
|
||||
```
|
||||
$ nsc add user -a YourAccount --name leafnode --expiry 1M
|
||||
```
|
||||
|
||||
You'll get a credential file somewhere like `~/.nkeys/creds/synadia/YourAccount/leafnode.creds`, mount this file into the docker container for JetStream using `-v ~/.nkeys/creds/synadia/YourAccount/leafnode.creds:/leafnode.creds`.
|
||||
|
||||
```
|
||||
$ docker run -ti -v ~/.nkeys/creds/synadia/YourAccount/leafnode.creds:/leafnode.creds --name jetstream synadia/jsm:latest server
|
||||
[1] 2020/01/20 12:44:11.752465 [INF] Starting nats-server version 2.2.0-beta
|
||||
...
|
||||
[1] 2020/01/20 12:55:01.849033 [INF] Connected leafnode to "connect.ngs.global"
|
||||
```
|
||||
|
||||
Your JSM shell will still connect locally, other connections in your NGS account can use JetStream at this point.
|
||||
65
jetstream/getting_started/using_source.md
Normal file
65
jetstream/getting_started/using_source.md
Normal file
@@ -0,0 +1,65 @@
|
||||
### Using Source
|
||||
|
||||
You will also want to have installed from the nats.go repo the examples/tools such as nats-pub, nats-sub, nats-req and possibly nats-bench. 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.
|
||||
|
||||
```
|
||||
$ git clone https://github.com/nats-io/nats-server.git
|
||||
$ cd nats-server
|
||||
$ git checkout master
|
||||
$ go build
|
||||
$ 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.
|
||||
|
||||
```
|
||||
$ ./nats-server -js
|
||||
|
||||
[16928] 2019/12/04 19:16:29.596968 [INF] Starting nats-server version 2.2.0-beta
|
||||
[16928] 2019/12/04 19:16:29.597056 [INF] Git commit [not set]
|
||||
[16928] 2019/12/04 19:16:29.597072 [INF] Starting JetStream
|
||||
[16928] 2019/12/04 19:16:29.597444 [INF] ----------- JETSTREAM (Beta) -----------
|
||||
[16928] 2019/12/04 19:16:29.597451 [INF] Max Memory: 96.00 GB
|
||||
[16928] 2019/12/04 19:16:29.597454 [INF] Max Storage: 1.00 TB
|
||||
[16928] 2019/12/04 19:16:29.597461 [INF] Store Directory: "/var/folders/m0/k03vs55n2b54kdg7jm66g27h0000gn/T/jetstream"
|
||||
[16928] 2019/12/04 19:16:29.597469 [INF] ----------------------------------------
|
||||
[16928] 2019/12/04 19:16:29.597732 [INF] Listening for client connections on 0.0.0.0:4222
|
||||
[16928] 2019/12/04 19:16:29.597738 [INF] Server id is NAJ5GKP5OBVISP5MW3BFAD447LMTIOAHFEWMH2XYWLL5STVGN3MJHTXQ
|
||||
[16928] 2019/12/04 19:16:29.597742 [INF] Server is ready
|
||||
```
|
||||
|
||||
You can override the storage directory if you want.
|
||||
|
||||
```
|
||||
$ ./nats-server -js -sd /tmp/test
|
||||
|
||||
[16943] 2019/12/04 19:20:00.874148 [INF] Starting nats-server version 2.2.0-beta
|
||||
[16943] 2019/12/04 19:20:00.874247 [INF] Git commit [not set]
|
||||
[16943] 2019/12/04 19:20:00.874273 [INF] Starting JetStream
|
||||
[16943] 2019/12/04 19:20:00.874605 [INF] ----------- JETSTREAM (Beta) -----------
|
||||
[16943] 2019/12/04 19:20:00.874613 [INF] Max Memory: 96.00 GB
|
||||
[16943] 2019/12/04 19:20:00.874615 [INF] Max Storage: 1.00 TB
|
||||
[16943] 2019/12/04 19:20:00.874620 [INF] Store Directory: "/tmp/test/jetstream"
|
||||
[16943] 2019/12/04 19:20:00.874625 [INF] ----------------------------------------
|
||||
[16943] 2019/12/04 19:20:00.874868 [INF] Listening for client connections on 0.0.0.0:4222
|
||||
[16943] 2019/12/04 19:20:00.874874 [INF] Server id is NCR6KDDGWUU2FXO23WAXFY66VQE6JNWVMA24ALF2MO5GKAYFIMQULKUO
|
||||
[16943] 2019/12/04 19:20:00.874877 [INF] Server is ready
|
||||
```
|
||||
|
||||
These options can also be set in your configuration file:
|
||||
|
||||
```
|
||||
// enables jetstream, an empty block will enable and use defaults
|
||||
jetstream {
|
||||
// jetstream data will be in /data/nats-server/jetstream
|
||||
store_dir: "/data/nats-server"
|
||||
|
||||
// 1GB
|
||||
max_memory_store: 1073741824
|
||||
|
||||
// 10GB
|
||||
max_file_store: 10737418240
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user