consistency参数

  • one(primary shard)
  • all(all shard)
  • quorum(default)

部署es

docker

1
2
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.5.4
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.7.0

k8s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: elasticsearch
  labels:
    app: elasticsearch
spec:
  selector:
    matchLabels:
      app: elasticsearch
  template:
    metadata:
      labels:
        app: elasticsearch
    spec:
      initContainers:
      - name: init-sysctl
        image: busybox:1.30.1
        command:
        - sysctl
        - -w
        - vm.max_map_count=262144
        securityContext:
          privileged: true
      containers:
        - name: elasticsearch
          image: docker.elastic.co/elasticsearch/elasticsearch:6.7.0
          ports:
            - containerPort: 9300
              name: es-tran-port
            - containerPort: 9200
              name: es-port
          env:
            - name: discovery.type
              value: "single-node"
            - name: path.data
              value: "/data"
          volumeMounts:
            - name: es-persistent-storage
              mountPath: /data
      volumes:
        - name: es-persistent-storage
          emptyDir: {}

# /usr/share/elasticsearch/

---

apiVersion: v1
kind: Service
metadata:
  name: elasticsearch-svc
  namespace: default
  labels:
    app: elasticsearch
    kubernetes.io/cluster-service: "true"
spec:
  type: NodePort
  selector:
    app: elasticsearch
  ports:
  - port: 9300
    targetPort: 9300
    nodePort: 30093
    name: es-tran-port
  - port: 9200
    targetPort: 9200
    nodePort: 30092
    name: es-port
1
2
# ES修改默认的密码信息 默认账户为 elastic 默认密码为 changme
curl -XPUT -u elastic 'http://localhost:9200/_xpack/security/user/kibana/_password' -d '{"password" : "yourpasswd"}'

部署filebeat

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
curl -L -O https://raw.githubusercontent.com/elastic/beats/6.7/deploy/docker/filebeat.docker.yml


docker run -d \
  --name=filebeat \
  --user=root \
  --volume="/data/filebeat.docker.yml:/usr/share/filebeat/filebeat.yml:ro" \
  --volume="/var/lib/docker/containers:/var/lib/docker/containers:ro" \
  --volume="/var/run/docker.sock:/var/run/docker.sock:ro" \
  docker.elastic.co/beats/filebeat:6.7.1 filebeat -e -strict.perms=false -E output.elasticsearch.hosts=["192.168.33.26:30092"]

部署Kibana

1
docker run -d --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.33.26:30092 -e XPACK_MONITORING_ENABLED=false -p 5601:5601  docker.elastic.co/kibana/kibana:6.7.0
1
{"type":"log","@timestamp":"2019-04-17T08:26:34Z","tags":["info","optimize"],"pid":1,"message":"Optimizing and caching bundles for graph, space_selector, login, logout, logged_out, ml, dashboardViewer, apm, maps, canvas, infra, uptime, kibana, status_page, stateSessionStorageRedirect and timelion. This may take a few minutes"}

参考