安装ElasticSearch
这是个搜索引擎,比MySQL的like命令强大的多。
1、拉取镜像
docker pull elasticsearch:8.12.2
2、创建用户网络
docker network create somenetwork
3、创建elasticsearch.yml
/Users/wang/Documents/docker/elasticsearch/elasticsearch.yml是本地文件
elasticsearch.yml文件内容
http:
host: 0.0.0.0
xpack.security.enabled: false
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: false
http.cors.enabled: true
http.cors.allow-origin: "*"
4、使用上面创建的网络运行
/Users/wang/Documents/docker/elasticsearch/elasticsearch.yml是本地文件
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v /Users/wang/Documents/docker/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml elasticsearch:8.12.2
浏览器访问ElasticSearch
{
"name": "92125190abed",
"cluster_name": "elasticsearch",
"cluster_uuid": "TLLGfodRRjOorRv2VQ6Xeg",
"version": {
"number": "8.12.2",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "48a287ab9497e852de30327444b0809e55d46466",
"build_date": "2024-02-19T10:04:32.774273190Z",
"build_snapshot": false,
"lucene_version": "9.9.2",
"minimum_wire_compatibility_version": "7.17.0",
"minimum_index_compatibility_version": "7.0.0"
},
"tagline": "You Know, for Search"
}
安装ElasticSearch-Head
这是个可视化工具,查看ElasticSearch里面的数据内容的
1、拉取镜像
docker pull mobz/elasticsearch-head:5-alpine
2、启动
docker run -d -p 9100:9100 --name elasticsearch-head mobz/elasticsearch-head:5-alpine
解决ElasticSearch-Head无法跨越访问ElasticSearch问题
进入ElasticSearch容器内部,在config目录下,修改配置文件elasticsearch.yml,添加如下内容并重启容器
http.cors.enabled: true
http.cors.allow-origin: "*"
安装Kibana
1、拉取镜像
docker pull kibana:8.12.2
2、创建kibana.yml
server.host: "0.0.0.0"
server.shutdownTimeout: "5s"
elasticsearch.hosts: [ "http://elasticsearch:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"
3、启动
docker run -d --name kibana --net somenetwork -p 5601:5601 --link elasticsearch:elasticsearch -v /Users/wang/Documents/docker/kibana/kibana.yml:/usr/share/kibana/config/kibana.yml -d kibana:8.12.2