谷粒商城day67 -全文检索-ElasticSearch-Docker安装ES与Kibana以及设置自动启动

其实步骤与之前安装mysql与redis大同小异,安装,映射端口及文件夹等

安装步骤如下,前面启动以及连接vagrant并使用root用户登录等步骤省略

docker pull elasticsearch:7.4.2
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data

[root@localhost config]# echo "http.host: 0.0.0.0" > /mydata/elasticsearch/config/elasticsearch.yml

echo "http.host: 0.0.0.0" > /mydata/elasticsearch/config/elasticsearch.yml

[root@localhost config]# docker run --name elasticsearch -p 9200:9200 -p 9300:9300 --privileged=true \
> -e "discovery.type=single-node" \
> -e ES_JAVA_OPTS="-Xms128m -Xms256m" \
> -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml   \
> -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
> -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
> -d elasticsearch:7.4.2

[root@localhost elasticsearch]# ll
total 0
drwxr-xr-x. 2 root root 31 Dec  8 03:35 config
drwxr-xr-x. 2 root root  6 Dec  8 03:35 data
drwxr-xr-x. 2 root root  6 Dec 11 13:14 plugins
[root@localhost elasticsearch]# chmod -R 777 /mydata/elasticsearch/
[root@localhost elasticsearch]# ll
total 0
drwxrwxrwx. 2 root root 31 Dec  8 03:35 config
drwxrwxrwx. 2 root root  6 Dec  8 03:35 data
drwxrwxrwx. 2 root root  6 Dec 11 13:14 plugins

[root@localhost elasticsearch]#  docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
839cd69f3610        redis               "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:6379->6379/tcp              redis
862d66567577        mysql:5.7           "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
[root@localhost elasticsearch]#  docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                     PORTS                               NAMES
afaa104678b3        elasticsearch:7.4.2   "/usr/local/bin/dock…"   5 minutes ago       Exited (1) 5 minutes ago                                       elasticsearch
839cd69f3610        redis                 "docker-entrypoint.s…"   2 weeks ago         Up About an hour           0.0.0.0:6379->6379/tcp              redis
862d66567577        mysql:5.7             "docker-entrypoint.s…"   2 weeks ago         Up About an hour           0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
[root@localhost elasticsearch]# docker restart
"docker restart" requires at least 1 argument.
See 'docker restart --help'.

Usage:  docker restart [OPTIONS] CONTAINER [CONTAINER...]

Restart one or more containers
[root@localhost elasticsearch]# docker start afa
afa
[root@localhost elasticsearch]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                            NAMES
afaa104678b3        elasticsearch:7.4.2   "/usr/local/bin/dock…"   6 minutes ago       Up 10 seconds       0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch
839cd69f3610        redis                 "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:6379->6379/tcp                           redis
862d66567577        mysql:5.7             "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:3306->3306/tcp, 33060/tcp                mysql
[root@localhost elasticsearch]# cd ../
[root@localhost mydata]# cd elasticsearch/
[root@localhost elasticsearch]# docker pull kibana:7.4.2
7.4.2: Pulling from library/kibana
Digest: sha256:355f9c979dc9cdac3ff9a75a817b8b7660575e492bf7dbe796e705168f167efc
Status: Image is up to date for kibana:7.4.2
docker.io/library/kibana:7.4.2
[root@localhost elasticsearch]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                            NAMES
afaa104678b3        elasticsearch:7.4.2   "/usr/local/bin/dock…"   15 minutes ago      Up 9 minutes        0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch
839cd69f3610        redis                 "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:6379->6379/tcp                           redis
862d66567577        mysql:5.7             "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:3306->3306/tcp, 33060/tcp                mysql
[root@localhost elasticsearch]# docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.56.10:9200 -p 5601:5601 -
d kibana:7.4.2
abf7546498aef29d87ef465ff96495702b21baaa58ae39430a01630690481b0e
[root@localhost elasticsearch]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                            NAMES
abf7546498ae        kibana:7.4.2          "/usr/local/bin/dumb…"   10 seconds ago      Up 3 seconds        0.0.0.0:5601->5601/tcp                           kibana
afaa104678b3        elasticsearch:7.4.2   "/usr/local/bin/dock…"   17 minutes ago      Up 10 minutes       0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch
839cd69f3610        redis                 "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:6379->6379/tcp                           redis
862d66567577        mysql:5.7             "docker-entrypoint.s…"   2 weeks ago         Up About an hour    0.0.0.0:3306->3306/tcp, 33060/tcp                mysql
[root@localhost elasticsearch]# docker logs abf

设置为自启动

[root@localhost vagrant]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS                     PORTS                                            NAMES
abf7546498ae        kibana:7.4.2          "/usr/local/bin/dumb…"   17 hours ago        Up 4 hours                 0.0.0.0:5601->5601/tcp                           kibana
afaa104678b3        elasticsearch:7.4.2   "/usr/local/bin/dock…"   17 hours ago        Up 4 hours                 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   elasticsearch
839cd69f3610        redis                 "docker-entrypoint.s…"   2 weeks ago         Up 4 hours                 0.0.0.0:6379->6379/tcp                           redis
862d66567577        mysql:5.7             "docker-entrypoint.s…"   2 weeks ago         Up 4 hours                 0.0.0.0:3306->3306/tcp, 33060/tcp                mysql
[root@localhost vagrant]# docker update afa --restart=always
afa
[root@localhost vagrant]# docker update abf --restart=always
abf

http://192.168.56.10:9200/  得到以下响应说明 elasticsearch安装成功

 谷粒商城day67 -全文检索-ElasticSearch-Docker安装ES与Kibana以及设置自动启动_第1张图片

http://192.168.56.10:5601  得到以下响应界面说明kibana安装成功

谷粒商城day67 -全文检索-ElasticSearch-Docker安装ES与Kibana以及设置自动启动_第2张图片

 

你可能感兴趣的:(谷粒商城,elasticsearch,ElasticSearch,Docker安装ES,Docker安装Kibana)