|
| 1 | +## Run {{es}} from the command line [windows-running] |
| 2 | + |
| 3 | +Run the following command to start {{es}} from the command line: |
| 4 | + |
| 5 | +```sh |
| 6 | +.\bin\elasticsearch.bat |
| 7 | +``` |
| 8 | + |
| 9 | +When starting {{es}} for the first time, security features are enabled and configured by default. The following security configuration occurs automatically: |
| 10 | + |
| 11 | +* Authentication and authorization are enabled, and a password is generated for the `elastic` built-in superuser. |
| 12 | +* Certificates and keys for TLS are generated for the transport and HTTP layer, and TLS is enabled and configured with these keys and certificates. |
| 13 | +* An enrollment token is generated for {{kib}}, which is valid for 30 minutes. |
| 14 | + |
| 15 | +The password for the `elastic` user and the enrollment token for {{kib}} are output to your terminal. |
| 16 | + |
| 17 | +We recommend storing the `elastic` password as an environment variable in your shell. Example: |
| 18 | + |
| 19 | +```sh |
| 20 | +$ELASTIC_PASSWORD = "your_password" |
| 21 | +``` |
| 22 | + |
| 23 | +If you have password-protected the {{es}} keystore, you will be prompted to enter the keystore’s password. See [Secure settings](../../security/secure-settings.md) for more details. |
| 24 | + |
| 25 | +By default {{es}} prints its logs to the console (`STDOUT`) and to the `<cluster name>.log` file within the [logs directory](important-settings-configuration.md#path-settings). {{es}} logs some information while it is starting, but after it has finished initializing it will continue to run in the foreground and won’t log anything further until something happens that is worth recording. While {{es}} is running you can interact with it through its HTTP interface which is on port `9200` by default. |
| 26 | + |
| 27 | +To stop {{es}}, press `Ctrl-C`. |
| 28 | + |
| 29 | + |
| 30 | +### Enroll nodes in an existing cluster [_enroll_nodes_in_an_existing_cluster_2] |
| 31 | + |
| 32 | +When {{es}} starts for the first time, the security auto-configuration process binds the HTTP layer to `0.0.0.0`, but only binds the transport layer to localhost. This intended behavior ensures that you can start a single-node cluster with security enabled by default without any additional configuration. |
| 33 | + |
| 34 | +Before enrolling a new node, additional actions such as binding to an address other than `localhost` or satisfying bootstrap checks are typically necessary in production clusters. During that time, an auto-generated enrollment token could expire, which is why enrollment tokens aren’t generated automatically. |
| 35 | + |
| 36 | +Additionally, only nodes on the same host can join the cluster without additional configuration. If you want nodes from another host to join your cluster, you need to set `transport.host` to a [supported value](asciidocalypse://docs/elasticsearch/docs/reference/elasticsearch/configuration-reference/networking-settings.md#network-interface-values) (such as uncommenting the suggested value of `0.0.0.0`), or an IP address that’s bound to an interface where other hosts can reach it. Refer to [transport settings](asciidocalypse://docs/elasticsearch/docs/reference/elasticsearch/configuration-reference/networking-settings.md#transport-settings) for more information. |
| 37 | + |
| 38 | +To enroll new nodes in your cluster, create an enrollment token with the `elasticsearch-create-enrollment-token` tool on any existing node in your cluster. You can then start a new node with the `--enrollment-token` parameter so that it joins an existing cluster. |
| 39 | + |
| 40 | +1. In a separate terminal from where {{es}} is running, navigate to the directory where you installed {{es}} and run the [`elasticsearch-create-enrollment-token`](asciidocalypse://docs/elasticsearch/docs/reference/elasticsearch/command-line-tools/create-enrollment-token.md) tool to generate an enrollment token for your new nodes. |
| 41 | + |
| 42 | + ```sh |
| 43 | + bin\elasticsearch-create-enrollment-token -s node |
| 44 | + ``` |
| 45 | + |
| 46 | + Copy the enrollment token, which you’ll use to enroll new nodes with your {{es}} cluster. |
| 47 | + |
| 48 | +2. From the installation directory of your new node, start {{es}} and pass the enrollment token with the `--enrollment-token` parameter. |
| 49 | + |
| 50 | + ```sh |
| 51 | + bin\elasticsearch --enrollment-token <enrollment-token> |
| 52 | + ``` |
| 53 | + |
| 54 | + {{es}} automatically generates certificates and keys in the following directory: |
| 55 | + |
| 56 | + ```sh |
| 57 | + config\certs |
| 58 | + ``` |
| 59 | + |
| 60 | +3. Repeat the previous step for any new nodes that you want to enroll. |
0 commit comments