elasticsearch和kibana安裝

董雷發表於2021-11-22

elasticsearch安裝

compose配置

兩個版本需要保持一致

  elasticsearch:
    image: elasticsearch:6.8.13
    restart: always
    hostname: es1
    container_name: es-single
    volumes:
        - ./elasticsearch/data:/usr/share/elasticsearch/data
        - ./elasticsearch/plugins:/usr/share/elasticsearch/plugins
        - ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
    environment:
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - discovery.type=single-node
    ports:
      - '9200:9200'     #java、叢集通訊埠
      - '9300:9300'     #http通訊埠
    privileged: true    #環境變數
  kibana:
    image: kibana:6.8.13
    restart: always
    container_name: kibana
    volumes:
        - ./kibana/kibana.yml:/usr/share/kibana/config/kibana.yml
    ports:
      - '5601:5601'     #java、叢集通訊埠
    privileged: true    #環境變數

目錄結構如下

luwei@luweideMacBook-Pro-2 lnmp % pwd
/Users/myself/vagrant/php/machine/Pro1/docker_lnmp/lnmp
luwei@luweideMacBook-Pro-2 lnmp % 
luwei@luweideMacBook-Pro-2 lnmp % 
luwei@luweideMacBook-Pro-2 lnmp % 
luwei@luweideMacBook-Pro-2 lnmp % ls
data                    golang                  mysql                   oracle                  php72                   zookeeper
docker-compose.yaml     kafka                   mysql57                 php56                   readme.md
elasticsearch           mongodb                 nginx                   php71                   redis
luwei@luweideMacBook-Pro-2 lnmp % cd elasticsearch 
luwei@luweideMacBook-Pro-2 elasticsearch % tree
.
├── config
│   ├── elasticsearch.yml
├── data
└── plugins

6 directories, 5 files
luwei@luweideMacBook-Pro-2 elasticsearch % 

elasticsearch.yml內容如下

# 叢集名稱
cluster.name: elasticsearch-cluster
# 節點名稱
node.name: es-node-1
# 繫結host,0.0.0.0代表當前節點的ip
network.host: 0.0.0.0
# 設定其它節點和該節點互動的ip地址,如果不設定它會自動判斷,值必須是個真實的ip地址(本機ip)
network.publish_host: 192.168.110.147
# 設定對外服務的http埠,預設為9200
http.port: 9200
# 設定節點間互動的tcp埠,預設是9300
transport.tcp.port: 9300
# 是否支援跨域,預設為false
http.cors.enabled: true
# 當設定允許跨域,預設為*,表示支援所有域名,如果我們只是允許某些網站能訪問,那麼可以使用正規表示式。比如只允許本地地址。 /https?:\/\/localhost(:[0-9]+)?/
http.cors.allow-origin: "*"
# 表示這個節點是否可以充當主節點
node.master: true
# 是否充當資料節點
node.data: true
# 所有主從節點ip:port
#discovery.seed_hosts: ["192.168.110.147:9300"]  #本地只有一個節點,無法正常啟動,先註釋
# 這個引數決定了在選主過程中需要 有多少個節點通訊  預防腦裂 N/2+1
discovery.zen.minimum_master_nodes: 1
#初始化主節點
#cluster.initial_master_nodes: ["es-node-1"]  #本地只有一個節點,無法正常啟動,先註釋

啟動es

docker-compose up -d elasticsearch

檢視容器

luwei@luweideMacBook-Pro-2 /tmp % docker ps -a
CONTAINER ID   IMAGE                                                  COMMAND                  CREATED             STATUS                           PORTS                                                NAMES
d935883a08f1   elasticsearch:6.8.13                                   "/usr/local/bin/dock…"   About an hour ago   Up 10 minutes                    0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp       es-single
28a2a3b33856   sheepkiller/kafka-manager                              "./start-kafka-manag…"   2 hours ago         Exited (255) 11 minutes ago      0.0.0.0:9091->9000/tcp                               lnmp_kafka-manager_1
d6ae300116f3   wurstmeister/zookeeper                                 "/bin/sh -c '/usr/sb…"   2 hours ago         Exited (255) 11 minutes ago      22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp   lnmp_zookeeper_1
c9de041d5ace   wurstmeister/kafka                                     "start-kafka.sh"         2 hours ago         Exited (255) 11 minutes ago      0.0.0.0:9092->9092/tcp                               lnmp_kafka_1

kibana目錄結構

luwei@luweideMacBook-Pro-2 kibana % tree
.
└── kibana.yml
0 directories, 1 file

啟動容器

luwei@luweideMacBook-Pro-2 lnmp % docker-compose up -d kibana
Starting kibana ... done
luwei@luweideMacBook-Pro-2 lnmp %

最終結果

luwei@luweideMacBook-Pro-2 /tmp % docker ps
CONTAINER ID   IMAGE                                                  COMMAND                  CREATED          STATUS                                    PORTS                                            NAMES
6b0f04545e93   kibana:6.8.13                                          "/usr/local/bin/kiba…"   20 minutes ago   Up 4 minutes                              0.0.0.0:5601->5601/tcp                           kibana
d935883a08f1   elasticsearch:6.8.13                                   "/usr/local/bin/dock…"   2 hours ago      Up 3 seconds                              0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   es-single
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章