docker compose安装elasticsearch
程序员文章站
2022-03-12 15:33:52
...
docker compose安装 elasticsearch
安装
创建目录 es:
mkdir es
cd es
创建挂载目录 data
mkdir data
创建 docker-compose.yml
文件:
version: '3'
services:
# search engine
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.1
# image: elasticsearch:7.9.0
container_name: elasticsearch
environment:
- discovery.type=single-node
- http.port=9200
- http.cors.enabled=true
# - http.cors.allow-origin=http://192.168.93.139:1358
- http.cors.allow-origin=*
# - http.cors.allow-origin=http://localhost:1358,http://127.0.0.1:1358
- http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
- http.cors.allow-credentials=false
- bootstrap.memory_lock=true
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
volumes:
- $PWD/data:/usr/share/elasticsearch/data
ports:
- '9200:9200'
- '9300:9300'
# elasticsearch browser
dejavu:
image: appbaseio/dejavu:3.2.3
container_name: dejavu
ports:
- '1358:1358'
links:
- elasticsearch
其中 dejavu
是es的可视化Web管理台
启动
docker-compose up -d
测试 es是否启动成功,访问: http://192.168.93.130:9200/?pretty
:
{
"name": "5c7ade417dc7",
"cluster_name": "docker-cluster",
"cluster_uuid": "NrFq1k24RLaD5EhRf6kKuA",
"version": {
"number": "7.0.1",
"build_flavor": "oss",
"build_type": "docker",
"build_hash": "e4efcb5",
"build_date": "2019-04-29T12:56:03.145736Z",
"build_snapshot": false,
"lucene_version": "8.0.0",
"minimum_wire_compatibility_version": "6.7.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
说明启动成功
创建索引
PUT http://192.168.93.130:9200/test , 结果
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "test"
}
获取索引
GET http://192.168.93.130:9200/test, 结果:
{
"test": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"creation_date": "1598768222773",
"number_of_shards": "1",
"number_of_replicas": "1",
"uuid": "nA152EH8QXmdbWDRDwr1eA",
"version": {
"created": "7000199"
},
"provided_name": "test"
}
}
}
}
es可视化管理 dejavu
老是报403, 解决方案, 将http.cors.allow-origin设置为*
http.cors.allow-origin=*
问题
当将es挂载宿主机目录时,会报错
java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
解决方案
原因是 自建的在宿主机上的 目录 data
,没有足够的权限
执行
[aaa@qq.com es]# chmod 777 data
推荐阅读
-
Docker安装nginx
-
docker/compose中links/external_links的区别
-
Docker容器安装的mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'
-
Docker虚拟化容器技术简介及安装/卸载
-
docker容器间使用network通信,示例:elasticsearch & kibana
-
Windows下安装ElasticSearch的方法(图文)
-
Windows下安装ElasticSearch的方法(图文)
-
ElasticSearch的完整安装教程
-
win7下docker安装与报错问题的解决方法
-
CentOS7安装使用Docker的步骤