elasticsearch-docker 单机版
创建目录
sudo mkdir -p /app/elasticsearch/{config,data,logs,plugins}
sudo chmod -R 777 /app/elasticsearch/data
sudo chmod -R 777 /app/elasticsearch/logs
系统优化
cat >> /etc/sysctl.conf <<EOF
vm.max_map_count=262144
EOF
sysctl -p
vim /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
创建配置 elasticsearch.yml
cat config/elasticsearch.yml
#################################
# 节点
#################################
cluster.name: es-Qkcloud
node.name: es-node-1
# 单节点模式
discovery.type: single-node
#################################
# 网络
#################################
network.host: 0.0.0.0
http.port: 9200
#################################
# 数据
#################################
path.data: /usr/share/elasticsearch/data
path.logs: /usr/share/elasticsearch/logs
#################################
# 安全
#################################
xpack.security.enabled: true
#################################
# 性能
#################################
bootstrap.memory_lock: true
indices.memory.index_buffer_size: 15%
search.default_search_timeout: 30s
action.auto_create_index: true
# 单机无副本
cluster.routing.allocation.disk.threshold_enabled: true
#################################
# 日志
#################################
logger.level: info
创建compose
cat docker-compose.yaml
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:9.4.3
container_name: elasticsearch
restart: unless-stopped
environment:
- node.name=es-node-1
- cluster.name=es-Qkcloud
- discovery.type=single-node
# JVM
- ES_JAVA_OPTS=-Xms6g -Xmx6g
# 锁定内存
- bootstrap.memory_lock=true
# 密码
- ELASTIC_PASSWORD=${els_pass}
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65535
hard: 65535
ports:
- "9200:9200"
- "9300:9300"
volumes:
- ./data:/usr/share/elasticsearch/data
- ./logs:/usr/share/elasticsearch/logs
- ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
networks:
- es-net
networks:
es-net:
driver: bridge
单机版索引模板优化参考
curl \
-u elastic:StrongPassword@123 \
-X PUT http://127.0.0.1:9200/_index_template/default \
-H "Content-Type: application/json" \
-d '
{
"index_patterns":["*"],
"template":{
"settings":{
"index.merge.scheduler.max_thread_count":1,
"number_of_replicas":0,
"refresh_interval":"30s"
}
}
}
'

浙公网安备 33010602011771号