Configuration File

You can use a configuration file to configure the options specific to the NATS Streaming Server.

Use the -sc or --stan_config command line parameter to specify the file to use.

For the embedded NATS Server, you can use another configuration file and pass it to the Streaming Server using -c or --config command line parameters.

Since most options do not overlap, it is possible to combine all options into a single file and specify this file using either the -sc or -c command line parameter.

However, the option named tls is common to NATS Server and NATS Streaming Server. If you plan to use a single configuration file and configure TLS, you should have all the streaming configuration included in a streaming map. This is actually a good practice regardless if you use TLS or not, to protect against possible addition of new options in NATS Server that would conflict with the names of NATS Streaming options.

For instance, you could use a single configuration file with such content:

# Some NATS Server TLS Configuration
listen: localhost:5222
tls: {
    cert_file: "/path/to/server/cert_file"
    key_file: "/path/to/server/key_file"
    verify: true
    timeout: 2
}

# NATS Streaming Configuration
streaming: {
    cluster_id: my_cluster

    tls: {
        client_cert: "/path/to/client/cert_file"
        client_key: "/path/to/client/key_file"
    }
}

However, if you want to avoid any possible conflict, simply use two different configuration files.

Note the order in which options are applied during the start of a NATS Streaming server:

  1. Start with some reasonable default options.

  2. If a configuration file is specified, override those options

    with all options defined in the file. This includes options that are defined

    but have no value specified. In this case, the zero value for the type of the

    option will be used.

  3. Any command line parameter override all of the previous set options.

In general the configuration parameters are the same as the command line arguments. Below is the list of NATS Streaming parameters:

Note: You may need to scroll horizontally to see all columns.

Notes:

(1) The seed file contains the NKey seed from which the Streaming server can extract the public key and the private key used to sign the nonce sent by the NATS Server when accepting connections from the Streaming server. The file is read during the connection process, the key is used to sign but then wiped from memory. The file must contain the seed file with the following format:

-----BEGIN USER NKEY SEED-----
SU<rest of the seed>
------END USER NKEY SEED------

TLS Configuration

Note that the Streaming Server uses a connection to a NATS Server, and so the NATS Streaming TLS Configuration is in fact a client-side TLS configuration.

Store Limits Configuration

{
    streaming: {
        cluster_id: my_cluster
        store_limits {
            max_msgs: 10000
        }
    }
}

Channels

The channels section is a map with the key being the channel name. For instance:

{
    streaming: {
        cluster_id: my_cluster
        store_limits {
            channels: {
                "foo": {
                    max_msgs: 100
                }
            }
        }
    }
}

For a given channel, the possible parameters are:

File Options Configuration

Cluster Configuration

SQL Options Configuration

最后更新于