创建目录
mkdir -p /usr/docker/es/config
mkdir -p /usr/docker/es/data
mkdir -p /usr/docker/es/plugins
echo "http.host: 0.0.0.0" >> /usr/local/docker/es/config/elasticsearch.yml
宿主机权限不够 chmod 777 -R /usr/docker/es/data
启动运行
docker run -d --name xdclass_es7 -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-v /usr/local/docker/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml\
-v/usr/local/docker/es/data:/usr/share/elasticsearch/data \
-v/usr/local/docker/es/plugins:/usr/share/elasticsearch/plugins elasticsearch:7.6.2
参数说明
-e "discovery.type=single-node" 设置为单节点
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" 设置ES的初始内存和最大内存,否则过大启动不了ES
- 验证
-
http://120.79.150.146:9200/_cat/nodes?v=true&pretty