其他分享
首页 > 其他分享> > docker部署elasticsearch的记录

docker部署elasticsearch的记录

作者:互联网

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 映射至宿主机位置

-d 指定镜像

docker run --name es
--privileged=true
-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"
}

标签:Users,部署,lzh,elasticsearch,build,docker,ES
来源: https://www.cnblogs.com/ZhenghuiLyu/p/16492161.html