IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 大数据 -> Docker安装es -> 正文阅读

[大数据]Docker安装es

# es 暴露的端口很多

# es 十分耗内存

# es 的数据一般需要放置到安全的目录!(通过挂载)

# 启动es
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:tag

# 解释
--net somenetwork  ? 网络配置 (后期学,先去掉)
"discovery.type=single-node" 集群单节点

[root@qiaoyanjie ~]# docker run -d --name elasticsearch01  -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch    #默认下载最新版本
Unable to find image 'elasticsearch:latest' locally
latest: Pulling from library/elasticsearch
05d1a5232b46: Pull complete 
5cee356eda6b: Pull complete 
89d3385f0fd3: Pull complete 
65dd87f6620b: Pull complete 
78a183a01190: Pull complete 
1a4499c85f97: Pull complete 
2c9d39b4bfc1: Pull complete 
1b1cec2222c9: Pull complete 
59ff4ce9df68: Pull complete 
1976bc3ee432: Pull complete 
5af49e8af381: Pull complete 
42c8b75ff7af: Pull complete 
7e6902915254: Pull complete 
99853874fa54: Pull complete 
596fbad6fcff: Pull complete 
Digest: sha256:a8081d995ef3443dc6d077093172a5931e02cdb8ffddbf05c67e01d348a9770e
Status: Downloaded newer image for elasticsearch:latest
5cfc15cf31a91e25674338960975736f9bd7d235a061d8eb30eaee3e1616742d
[root@qiaoyanjie ~]# docker ps -a    #最新版起不来
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS                     PORTS                    NAMES
5cfc15cf31a9   elasticsearch   "/docker-entrypoint.…"   9 seconds ago   Exited (1) 8 seconds ago                            elasticsearch01
21d3be4a9e4c   tomcat          "catalina.sh run"        7 hours ago     Up 7 hours                 0.0.0.0:3345->8080/tcp   tomcat01
10987a6f0593   nginx           "/docker-entrypoint.…"   6 days ago      Up 6 hours                 0.0.0.0:3344->80/tcp     nginx01
[root@qiaoyanjie ~]# docker ps 
CONTAINER ID   IMAGE     COMMAND                  CREATED       STATUS       PORTS                    NAMES
21d3be4a9e4c   tomcat    "catalina.sh run"        7 hours ago   Up 7 hours   0.0.0.0:3345->8080/tcp   tomcat01
10987a6f0593   nginx     "/docker-entrypoint.…"   6 days ago    Up 6 hours   0.0.0.0:3344->80/tcp     nginx01
[root@qiaoyanjie ~]# docker rm -f 5cfc15cf31a9
5cfc15cf31a9
[root@qiaoyanjie ~]# docker images
REPOSITORY      TAG       IMAGE ID       CREATED        SIZE
nginx           latest    605c77e624dd   4 months ago   141MB
tomcat          latest    fb5657adc892   4 months ago   680MB
elasticsearch   latest    5acf0e8da90b   3 years ago    486MB
[root@qiaoyanjie ~]# docker run -d --name elasticsearch01  -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch
a10e3209ee777a80d44fc69091bf8a9596dd76a39aeed52fb38c820f0f59beda
[root@qiaoyanjie ~]# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS                     PORTS                    NAMES
a10e3209ee77   elasticsearch   "/docker-entrypoint.…"   9 seconds ago   Exited (1) 8 seconds ago                            elasticsearch01
21d3be4a9e4c   tomcat          "catalina.sh run"        7 hours ago     Up 7 hours                 0.0.0.0:3345->8080/tcp   tomcat01
10987a6f0593   nginx           "/docker-entrypoint.…"   6 days ago      Up 7 hours                 0.0.0.0:3344->80/tcp     nginx01
[root@qiaoyanjie ~]# docker logs -f a10e3209ee77    #查看日志,内存溢出
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid1.log
[root@qiaoyanjie ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           1.8G        306M        206M        576K        1.3G        1.3G
Swap:            0B          0B          0B
[root@qiaoyanjie ~]# docker images    # 内存溢出???
REPOSITORY      TAG       IMAGE ID       CREATED        SIZE
nginx           latest    605c77e624dd   4 months ago   141MB
tomcat          latest    fb5657adc892   4 months ago   680MB
elasticsearch   7.6.2     f29a1ee41030   2 years ago    791MB
elasticsearch   latest    5acf0e8da90b   3 years ago    486MB
[root@qiaoyanjie ~]# docker run -d --name elasticsearch01  -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2
Unable to find image 'elasticsearch:7.6.2' locally
7.6.2: Pulling from library/elasticsearch
ab5ef0e58194: Pull complete 
c4d1ca5c8a25: Pull complete 
941a3cc8e7b8: Pull complete 
43ec483d9618: Pull complete 
c486fd200684: Pull complete 
1b960df074b2: Pull complete 
1719d48d6823: Pull complete 
Digest: sha256:1b09dbd93085a1e7bca34830e77d2981521a7210e11f11eda997add1c12711fa
Status: Downloaded newer image for elasticsearch:7.6.2
c4ac304a64a3205853ed8c240b9b375664e2b5f9f79a093856acf09fc22e918e
[root@qiaoyanjie ~]# docker ps -a    # 7.6.2版本可以启动成功
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                                            NAMES
c4ac304a64a3   elasticsearch:7.6.2   "/usr/local/bin/dock…"   47 seconds ago   Up 45 seconds   0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch01
21d3be4a9e4c   tomcat                "catalina.sh run"        7 hours ago      Up 7 hours      0.0.0.0:3345->8080/tcp                           tomcat01
10987a6f0593   nginx                 "/docker-entrypoint.…"   6 days ago       Up 7 hours      0.0.0.0:3344->80/tcp                             nginx01

# 测试一下 es 是否已经成功了
[root@qiaoyanjie ~]# curl localhost:9200
{
  "name" : "c4ac304a64a3",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "WM3FfgN5TTKu0G1ManiIug",
  "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"
}
[root@qiaoyanjie ~]# curl localhost:9300    #9300不行
This is not an HTTP port[root@qiaoyanjie ~]#
# es十分耗内存,启动以后,linux(1核2G)就卡住了。  docker stats 查看 cpu 的状态

# es 启动时 cpu 状态
[root@qiaoyanjie ~]# docker stats    
CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O       PIDS
c4ac304a64a3   elasticsearch01   2.46%     1.25GiB / 1.795GiB    69.63%    0B / 0B           368MB / 696kB   42
21d3be4a9e4c   tomcat01          0.09%     124.2MiB / 1.795GiB   6.76%     8.77kB / 129kB    200MB / 0B      28
10987a6f0593   nginx01           0.00%     1.449MiB / 1.795GiB   0.08%     1.88kB / 1.97kB   2.84MB / 0B     2

# es 不启动时 cpu 状态
[root@qiaoyanjie ~]# docker stats 
CONTAINER ID   NAME       CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O     PIDS
21d3be4a9e4c   tomcat01   0.12%     119.3MiB / 1.795GiB   6.49%     8.77kB / 129kB    202MB / 0B    28
10987a6f0593   nginx01    0.00%     1.449MiB / 1.795GiB   0.08%     1.88kB / 1.97kB   2.84MB / 0B   2

# 增加内存的限制,修改配置文件 -e 环境配置修改
[root@qiaoyanjie ~]# docker run -d --name elasticsearch02  -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2
89af9d4d7f34585eec4344b2ea93e0fb7a8520e9292a8698d10189c89bec3d92
[root@qiaoyanjie ~]# docker ps -a
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS                        PORTS                                            NAMES
89af9d4d7f34   elasticsearch:7.6.2   "/usr/local/bin/dock…"   7 seconds ago    Up 6 seconds                  0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch02
c4ac304a64a3   elasticsearch:7.6.2   "/usr/local/bin/dock…"   22 minutes ago   Exited (143) 25 seconds ago                                                    elasticsearch01
21d3be4a9e4c   tomcat                "catalina.sh run"        7 hours ago      Up 7 hours                    0.0.0.0:3345->8080/tcp                           tomcat01
10987a6f0593   nginx                 "/docker-entrypoint.…"   6 days ago       Up 7 hours                    0.0.0.0:3344->80/tcp                             nginx01
[root@qiaoyanjie ~]# docker stats    # cpu 占用率明显减小
CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O        PIDS
89af9d4d7f34   elasticsearch02   97.84%    290.7MiB / 1.795GiB   15.82%    0B / 0B           97.3MB / 246kB   20
21d3be4a9e4c   tomcat01          0.09%     122.2MiB / 1.795GiB   6.65%     8.81kB / 129kB    288MB / 0B       28
10987a6f0593   nginx01           0.00%     1.445MiB / 1.795GiB   0.08%     1.92kB / 1.97kB   2.84MB / 0B      2
[root@qiaoyanjie ~]# curl localhost:9200    # 访问成功
{
  "name" : "89af9d4d7f34",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "nuUXVWS1Q_iTgfLBOlrNDw",
  "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"
}

# ?阿里云开放安全组,网页访问成功

?

?

?

  大数据 最新文章
实现Kafka至少消费一次
亚马逊云科技:还在苦于ETL?Zero ETL的时代
初探MapReduce
【SpringBoot框架篇】32.基于注解+redis实现
Elasticsearch:如何减少 Elasticsearch 集
Go redis操作
Redis面试题
专题五 Redis高并发场景
基于GBase8s和Calcite的多数据源查询
Redis——底层数据结构原理
上一篇文章      下一篇文章      查看所有文章
加:2022-05-07 11:15:14  更:2022-05-07 11:15:25 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 1:28:56-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码