# ES 启动前准备
mkdir -p /Users/lzh/elasticsearch/config
mkdir -p /Users/lzh/elasticsearch/data
mkdir -p /Users/lzh/elasticsearch/plugins

#追加至配置文件的内容,注意冒号后面有空格
echo "http.host: 0.0.0.0" >> /Users/lzh/elasticsearch/config/elasticsearch.yml


#外部文件夹权限修改
chmod -R 777 /Users/lzh/elasticsearch


# ES docker启动
# -e discovery.type指定单节点模式
# -e ES_JAVA_OPTS指定内存
# -v docker内部文件夹映射至宿主机的位置,便于修改保存
# -d 指定镜像
docker run --name es \
--privileged=true \
--restart=always \
-p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms256m -Xmx256m" \
-v /Users/lzh/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /Users/lzh/elasticsearch/data:/usr/share/elasticsearch/data \
-v /Users/lzh/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.12.0

#查看docker日志是否正常
docker logs es

#访问宿主机ip:9200获取数据则正常
{
"name" : "d739c1de4655",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "0SR_rGlSQUqbc8_6ir0MdQ",
"version" : {
"number" : "7.12.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",
"build_date" : "2021-03-18T06:17:15.410153305Z",
"build_snapshot" : false,
"lucene_version" : "8.8.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

 

#docker启动kibana,注意必须-e设置为elastic的宿主ip
docker run --name kibana \
-e ELASTICSEARCH_HOSTS=http://192.168.0.97:9200 \
--restart=always \
-p 5601:5601 \
-d kibana:7.12.0


#访问kibana
http://192.168.0.97:5601/app/kibana

 

#kibana中文支持
#进入docker
docker exec -it kibana bash

#修改配置文件config文件夹下的kibana.yml,末尾添加:
i18n.locale: "zh-CN"

#重启kinaba docker,等待一会儿再访问kibana即为中文
docker restart kibana