docker安装elasticsearch

一、docker安装elasticsearch

docker pull elasticsearch:7.4.2					存储和检索数据
docker pull kibana:7.4.2								可视化检索数据


# 创建自己的目录
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml
# /kikiguli/mydata/elasticsearch/config
# -p 9200:9200  容器内部端口映射到linux的端口  9200是后端发送请求restAPI使用的
# -p 9300:9300	9300是es在分布式集群下节点间的通信端口
# -e "discovery.type = single-node"	指定单节点模式运行
# -e ES_JAVA_OPTS="-Xms64m -Xmx128m" 如果不指定会将整个内存全部占用 初始64m最大占用128 上线一般32G
docker run --name elasticsearch -p 9200:9200 -p 9300:9300
-e "discovery.type=single-node"
-e ES_JAVA_OPTS="-Xms64m -Xmx128m"
-v /kikiguli/mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /kikiguli/mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /kikiguli/mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.6.2

注意:

如果启动失败,可以调整ES_JAVA_OPTS=“-Xms64m -Xmx128m"加大内存
如果加大内存后仍启动失败使用命令:docker logs kiki-es 查看日志
如果是ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes];”,
使用chmod -R 777 /kikiguli/mydata/elasticsearch 递归改变该文件夹下的所有文件

二、访问

输入http:ip:9200 回车后得到 则es配置成功

{
  "name" : "a3ee6db0578f",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "1mdrZmc8RcafI30PYKE8Lg",
  "version" : {
    "number" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "build_date" : "2020-03-26T06:34:37.794943Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

你可能感兴趣的:(即使再小的帆也能远航,java,spring,boot,docker,分布式,es)