【docker系列】Docker 安装 elasticsearch7.4.2、elasticsearch-analysis-ik分词器、elasticsearch-head

1、拉取docker elasticsearch 镜像

[root@hadoop-keda /]# docker pull elasticsearch:7.4.2
7.4.2: Pulling from library/elasticsearch

2、先配置宿主机的 参数,否则无法启动,会报错:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[root@study-01 ~]# vim /etc/sysctl.conf
vm.max_map_count=655360
[root@study-01 ~]# sysctl -p 

3、先启动简洁版的容器

sudo docker run -id \
--net docker-hadoop-net \
--ip 172.170.0.15 \
--restart=always \
--hostname=hadoop_elasticsearch \
--name=hadoop-elasticsearch \
-p 19200:9200 \
-p 19300:9300 \
-v /etc/localtime:/etc/localtime \
-e ES_JAVA_OPTS="-Xms2g -Xmx2g" \
-e "discovery.type=single-node" \
-e TZ='Asia/Shanghai' \
-e LANG="en_US.UTF-8" \
elasticsearch:7.4.2

4、copy容器中的文件,到宿主机上

[root@hadoop-keda software]# docker cp 97d21381af5a4e49e:/usr/share/elasticsearch/config/ /usr/docker/software/elasticsearch/
[root@hadoop-keda software]# docker cp 97d21381af5a4e49e:/usr/share/elasticsearch/data/ /usr/docker/software/elasticsearch/
[root@hadoop-keda software]# docker cp 97d21381af5a4e49e:/usr/share/elasticsearch/logs/ /usr/docker/software/elasticsearch/
[root@hadoop-keda software]# docker cp 97d21381af5a4e49e:/usr/share/elasticsearch/plugins/ /usr/docker/software/elasticsearch/

5、启动 elasticsearch 容器

sudo docker run -tid \
--net docker-hadoop-net \
--ip 172.170.0.15 \
--restart=always \
--hostname=hadoop_elasticsearch \
--name=hadoop-elasticsearch \
-p 19200:9200 \
-p 19300:9300 \
-v /usr/docker/software/elasticsearch/config/:/usr/share/elasticsearch/config/ \
-v /usr/docker/software/elasticsearch/data/:/usr/share/elasticsearch/data/ \
-v /usr/docker/software/elasticsearch/logs/:/usr/share/elasticsearch/logs/ \
-v /usr/docker/software/elasticsearch/plugins/:/usr/share/elasticsearch/plugins/ \
-v /etc/localtime:/etc/localtime \
-e ES_JAVA_OPTS="-Xms2g -Xmx2g" \
-e "discovery.type=single-node" \
-e TZ='Asia/Shanghai' \
-e LANG="en_US.UTF-8" \
elasticsearch:7.4.2

注:
-e "discovery.type=single-node" 表示 单节点启动。
如果yml文件中,配置是集群环境,需要把这个去掉


6、开放宿主机的端口,(阿里云服务器,需要通过控制台来开启19200端口)
7、访问测试

【docker系列】Docker 安装 elasticsearch7.4.2、elasticsearch-analysis-ik分词器、elasticsearch-head_第1张图片
8、安装 IK 分词器(进入docker容器安装插件)

[root@hadoop-keda config]# docker exec -it 9e4e12672334 bash
[root@hadoop_elasticsearch elasticsearch]# ls
bin  config  data  jdk  lib  LICENSE.txt  logs  modules  NOTICE.txt  plugins  README.textile
[root@hadoop_elasticsearch elasticsearch]# cd bin/
[root@hadoop_elasticsearch bin]# ls
elasticsearch           elasticsearch-cli       elasticsearch-enve      elasticsearch-node           elasticsearch-setup-passwords  elasticsearch-sql-cli-7.4.2.jar  x-pack-env
elasticsearch-certgen   elasticsearch-croneval  elasticsearch-keystore  elasticsearch-plugin         elasticsearch-shard            elasticsearch-syskeygen          x-pack-security-env
elasticsearch-certutil  elasticsearch-env       elasticsearch-migrate   elasticsearch-saml-metadata  elasticsearch-sql-cli          elasticsearch-users              x-pack-watcher-env
[root@hadoop_elasticsearch bin]# elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.4.2/elasticsearch-analysis-ik-7.4.2.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.4.2/elasticsearch-analysis-ik-7.4.2.zip
[=================================================] 100%   
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y
-> Installed analysis-ik

【docker系列】Docker 安装 elasticsearch7.4.2、elasticsearch-analysis-ik分词器、elasticsearch-head_第2张图片
9、安装mobz/elasticsearch-head 容器并连接到 elasticsearch

[root@hadoop-keda ~]# sudo docker run -dit \
> --net docker-hadoop-net \
> --ip 172.170.0.18 \
> --restart=always \
> --hostname=hadoop_elasticsearch_head \
> --name=hadoop-elasticsearch-head \
> -p 19100:9100 \
> -v /etc/localtime:/etc/localtime \
> -e TZ='Asia/Shanghai' \
> -e LANG="en_US.UTF-8" \
> mobz/elasticsearch-head:5

10、开放宿主机的端口,(阿里云服务器,需要通过控制台来开启19100端口)
【docker系列】Docker 安装 elasticsearch7.4.2、elasticsearch-analysis-ik分词器、elasticsearch-head_第3张图片

你可能感兴趣的:(docker,elk,elasticsearch)