Elasticsearch 使用随记

部署 ECK Operator:

1
2
kubectl create -f https://download.elastic.co/downloads/eck/2.16.1/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/2.16.1/operator.yaml

部署单点 ES 集群:

1
2
3
4
5
6
7
8
9
10
11
12
13
cat <<EOF | kubectl apply -f -
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: quickstart
spec:
version: 8.17.1
nodeSets:
- name: default
count: 1
config:
node.store.allow_mmap: false
EOF

对集群发起请求:

1
2
PASSWORD=$(kubectl get secret quickstart-es-elastic-user -o go-template='{{.data.elastic | base64decode}}')
curl -u "elastic:$PASSWORD" -k "https://quickstart-es-http:9200"

部署高可用 ES 集群:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cat <<EOF | kubectl apply -f -
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: quickstart
spec:
version: 8.17.1
nodeSets:
- name: data-nodes
count: 3
config:
node.store.allow_mmap: false
index.number_of_replicas: 1
- name: master-nodes
count: 3
config:
node.master: true
node.data: false
node.ingest: false
heap.size: 2g
EOF
Author

Warner Chen

Posted on

2025-01-31

Updated on

2025-02-27

Licensed under

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.