直接安装运行es(会出现Linux系统卡死,下面有解决方案)
bash
[root@wq ~]# docker run -d --name elasticsearch -p 8020: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
e8d19d871e4e7f718343c3239456c5aa19c70e8135fdf0fc5bcef5b7b455217c
es这个东西很耗内存的,启动es的时候,整个Linux可能会卡住,所以需要进行限制内存的使用
先停止es容器
docker stop id号
解决方案:限制内存,运行es容器
bash
[root@wq ~]# docker run -d --name elasticsearch02 -p 8021:9200 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2
8dbbbdc4c0d8ef5fc69ca525b434195fe25404aff74abd7a11d8aaa1c81192aa
[root@wq ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8dbbbdc4c0d8 elasticsearch:7.6.2 "/usr/local/bin/dock..." 3 seconds ago Up 2 seconds 9300/tcp, 0.0.0.0:8021->9200/tcp, :::8021->9200/tcp elasticsearch02
查看容器使用内存
验证是否安装成功
bash
[root@wq ~]# curl localhost:8021
{
"name" : "8dbbbdc4c0d8",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "3mXb1WBDRO-uqxphRuOcIQ",
"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@wq ~]#