docker 容器内数据映射到容器外

2023-12-13 05:36:13

es 暴露的端口很多

es 十分的耗内存

es 的数据一般需要放置到安全目录!挂载

启动elasticsearch

[root@iZbp1guc0wov85gocdqeaiZ home]# docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2

启动了 linux卡住了 docker stats 查看 cpu的状态

docker stars	//查看cpu
CONTAINER ID   NAME            CPU %     MEM USAGE / LIMIT    MEM %     NET I/O         BLOCK I/O       PIDS
0a1ced4464b5   elasticsearch   0.24%     1.237GiB / 3.56GiB   34.74%    1.18kB / 942B   705kB / 696kB   43
	# es 十分的耗内存。启动了1点多G 1核1G的会卡住

访问9200

[root@iZbp1guc0wov85gocdqeaiZ home]# curl localhost:9200
{
  "name" : "0a1ced4464b5",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "X86tg4kJR4i5xr7SduAbKg",
  "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"
}

修改配置文件 -e 环境配置修改

[root@iZbp1guc0wov85gocdqeaiZ home]# docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2

[root@iZbp1guc0wov85gocdqeaiZ home]# docker  ps
CONTAINER ID   IMAGE                 
633e9b2666bf   elasticsearch:7.6.2   
[root@iZbp1guc0wov85gocdqeaiZ home]# docker stats 633e9b2666bf
CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT    MEM %     NET I/O     BLOCK I/O        PIDS
633e9b2666bf   elasticsearch02   0.49%     354.8MiB / 3.56GiB   9.73%     656B / 0B   1.58MB / 729kB   44
[root@iZbp1guc0wov85gocdqeaiZ home]# curl localhost:9200
{
  "name" : "633e9b2666bf",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "Gsvwb9ICRACD-HR-E3jILg",
  "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"
}

一样的可以访问,而且占用的‘内存’小了很多;这就可以完成数据互通了

文章来源:https://blog.csdn.net/xubaodong_1/article/details/134807648
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。