Skip to content

Commit 9bdeae8

Browse files
authored
[DOCS] Replace local dev instructions in main README (#111352) (#111580)
1 parent 168b910 commit 9bdeae8

File tree

1 file changed

+113
-45
lines changed

1 file changed

+113
-45
lines changed

README.asciidoc

Lines changed: 113 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,76 +33,144 @@ https://www.elastic.co/downloads/elasticsearch[elastic.co/downloads/elasticsearc
3333
=== Run Elasticsearch locally
3434

3535
////
36-
IMPORTANT: This content is replicated in the Elasticsearch guide.
37-
If you make changes, you must also update setup/set-up-local-dev-deployment.asciidoc.
36+
IMPORTANT: This content is replicated in the Elasticsearch guide. See `run-elasticsearch-locally.asciidoc`.
37+
Both will soon be replaced by a quickstart script.
3838
////
3939

40-
To try out Elasticsearch on your own machine, we recommend using Docker
41-
and running both Elasticsearch and Kibana.
42-
Docker images are available from the https://www.docker.elastic.co[Elastic Docker registry].
40+
[WARNING]
41+
====
42+
DO NOT USE THESE INSTRUCTIONS FOR PRODUCTION DEPLOYMENTS.
4343
44-
NOTE: Starting in Elasticsearch 8.0, security is enabled by default.
45-
The first time you start Elasticsearch, TLS encryption is configured automatically,
46-
a password is generated for the `elastic` user,
47-
and a Kibana enrollment token is created so you can connect Kibana to your secured cluster.
44+
This setup is intended for local development and testing only.
45+
====
4846

49-
For other installation options, see the
50-
https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html[Elasticsearch installation documentation].
47+
The following commands help you very quickly spin up a single-node Elasticsearch cluster, together with Kibana in Docker.
48+
Use this setup for local development or testing.
5149

52-
**Start Elasticsearch**
50+
==== Prerequisites
5351

54-
. Install and start https://www.docker.com/products/docker-desktop[Docker
55-
Desktop]. Go to **Preferences > Resources > Advanced** and set Memory to at least 4GB.
52+
If you don't have Docker installed, https://www.docker.com/products/docker-desktop[download and install Docker Desktop] for your operating system.
5653

57-
. Start an Elasticsearch container:
58-
+
54+
==== Set environment variables
55+
56+
Configure the following environment variables.
57+
58+
[source,sh]
59+
----
60+
export ELASTIC_PASSWORD="<ES_PASSWORD>" # password for "elastic" username
61+
export KIBANA_PASSWORD="<KIB_PASSWORD>" # Used internally by Kibana, must be at least 6 characters long
62+
----
63+
64+
==== Create a Docker network
65+
66+
To run both Elasticsearch and Kibana, you'll need to create a Docker network:
67+
68+
[source,sh]
5969
----
60-
docker network create elastic
61-
docker pull docker.elastic.co/elasticsearch/elasticsearch:{version} <1>
62-
docker run --name elasticsearch --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -t docker.elastic.co/elasticsearch/elasticsearch:{version}
70+
docker network create elastic-net
6371
----
64-
<1> Replace {version} with the version of Elasticsearch you want to run.
65-
+
66-
When you start Elasticsearch for the first time, the generated `elastic` user password and
67-
Kibana enrollment token are output to the terminal.
68-
+
69-
NOTE: You might need to scroll back a bit in the terminal to view the password
70-
and enrollment token.
7172

72-
. Copy the generated password and enrollment token and save them in a secure
73-
location. These values are shown only when you start Elasticsearch for the first time.
74-
You'll use these to enroll Kibana with your Elasticsearch cluster and log in.
73+
==== Run Elasticsearch
74+
75+
Start the Elasticsearch container with the following command:
7576

76-
**Start Kibana**
77+
[source,sh]
78+
----
79+
docker run -p 127.0.0.1:9200:9200 -d --name elasticsearch --network elastic-net \
80+
-e ELASTIC_PASSWORD=$ELASTIC_PASSWORD \
81+
-e "discovery.type=single-node" \
82+
-e "xpack.security.http.ssl.enabled=false" \
83+
-e "xpack.license.self_generated.type=trial" \
84+
docker.elastic.co/elasticsearch/elasticsearch:{version}
85+
----
7786

78-
Kibana enables you to easily send requests to Elasticsearch and analyze, visualize, and manage data interactively.
87+
==== Run Kibana (optional)
7988

80-
. In a new terminal session, start Kibana and connect it to your Elasticsearch container:
81-
+
89+
To run Kibana, you must first set the `kibana_system` password in the Elasticsearch container.
90+
91+
[source,sh]
8292
----
83-
docker pull docker.elastic.co/kibana/kibana:{version} <1>
84-
docker run --name kibana --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:{version}
93+
# configure the Kibana password in the ES container
94+
curl -u elastic:$ELASTIC_PASSWORD \
95+
-X POST \
96+
http://localhost:9200/_security/user/kibana_system/_password \
97+
-d '{"password":"'"$KIBANA_PASSWORD"'"}' \
98+
-H 'Content-Type: application/json'
8599
----
86-
<1> Replace {version} with the version of Kibana you want to run.
87-
+
88-
When you start Kibana, a unique URL is output to your terminal.
100+
// NOTCONSOLE
89101

90-
. To access Kibana, open the generated URL in your browser.
102+
Start the Kibana container with the following command:
91103

92-
.. Paste the enrollment token that you copied when starting
93-
Elasticsearch and click the button to connect your Kibana instance with Elasticsearch.
104+
[source,sh]
105+
----
106+
docker run -p 127.0.0.1:5601:5601 -d --name kibana --network elastic-net \
107+
-e ELASTICSEARCH_URL=http://elasticsearch:9200 \
108+
-e ELASTICSEARCH_HOSTS=http://elasticsearch:9200 \
109+
-e ELASTICSEARCH_USERNAME=kibana_system \
110+
-e ELASTICSEARCH_PASSWORD=$KIBANA_PASSWORD \
111+
-e "xpack.security.enabled=false" \
112+
-e "xpack.license.self_generated.type=trial" \
113+
docker.elastic.co/kibana/kibana:{version}
114+
----
94115

95-
.. Log in to Kibana as the `elastic` user with the password that was generated
96-
when you started Elasticsearch.
116+
.Trial license
117+
[%collapsible]
118+
====
119+
The service is started with a trial license. The trial license enables all features of Elasticsearch for a trial period of 30 days. After the trial period expires, the license is downgraded to a basic license, which is free forever. If you prefer to skip the trial and use the basic license, set the value of the `xpack.license.self_generated.type` variable to basic instead. For a detailed feature comparison between the different licenses, refer to our https://www.elastic.co/subscriptions[subscriptions page].
120+
====
97121

98-
**Send requests to Elasticsearch**
122+
==== Send requests to Elasticsearch
99123

100124
You send data and other requests to Elasticsearch through REST APIs.
101125
You can interact with Elasticsearch using any client that sends HTTP requests,
102126
such as the https://www.elastic.co/guide/en/elasticsearch/client/index.html[Elasticsearch
103127
language clients] and https://curl.se[curl].
128+
129+
===== Using curl
130+
131+
Here's an example curl command to create a new Elasticsearch index, using basic auth:
132+
133+
[source,sh]
134+
----
135+
curl -u elastic:$ELASTIC_PASSWORD \
136+
-X PUT \
137+
http://localhost:9200/my-new-index \
138+
-H 'Content-Type: application/json'
139+
----
140+
// NOTCONSOLE
141+
142+
===== Using a language client
143+
144+
To connect to your local dev Elasticsearch cluster with a language client, you can use basic authentication with the `elastic` username and the password you set in the environment variable.
145+
146+
You'll use the following connection details:
147+
148+
* **Elasticsearch endpoint**: `http://localhost:9200`
149+
* **Username**: `elastic`
150+
* **Password**: `$ELASTIC_PASSWORD` (Value you set in the environment variable)
151+
152+
For example, to connect with the Python `elasticsearch` client:
153+
154+
[source,python]
155+
----
156+
import os
157+
from elasticsearch import Elasticsearch
158+
159+
username = 'elastic'
160+
password = os.getenv('ELASTIC_PASSWORD') # Value you set in the environment variable
161+
162+
client = Elasticsearch(
163+
"http://localhost:9200",
164+
basic_auth=(username, password)
165+
)
166+
167+
print(client.info())
168+
----
169+
170+
===== Using the Dev Tools Console
171+
104172
Kibana's developer console provides an easy way to experiment and test requests.
105-
To access the console, go to **Management > Dev Tools**.
173+
To access the console, open Kibana, then go to **Management** > **Dev Tools**.
106174

107175
**Add data**
108176

0 commit comments

Comments
 (0)