一、安装docker
1.更新yum包
sudo yum update
2.卸载旧版本(如果安装过旧版本的话)
sudo yum remove docker docker-common docker-selinux docker-engine
3.安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
4.设置yum源
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
5.安装docker-ce
sudo yum install docker-ce
6.启动并加入开机启动
sudo systemctl start docker sudo systemctl enable docker
7.验证安装
sudo docker version
二、安装docker-compose
1. 安装指定版本(替换1.23.2为自己需要安装的版本)
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2. 执行命令,赋权
sudo chmod +x /usr/local/bin/docker-compose
3.验证安装
docker-compose version
三、docker安装elasticsearch、kibana
1. 拉取指定版本elasticsearch镜像文件
docker pull elasticsearch:7.3.0
2. 拉取指定版本kibana镜像文件
docker pull kibana:7.3.0
3.验证镜像
docker images
四、docker-compose启动elasticsearch、kibana
1. 在linux的root根目录(随你心意)创建app目录,并在app目录下创建一下目录结构
/app/
-docker-compose.yml
docker-compose的启动文件
-es/
elastic的配置文件目录
---es.yml
es的启动文件
---data/
存放es数据
---logs/
存放es日志
---plugins/
存放es插件
-------ik/
ik分词插件
-kibana/
kibana的配置文件目录
---kibana.yml
kibana的启动文件
1.1 下载ik分支插件,解压到/app/es/plugins/ik/目录下
elasticsearch-analysis-ik-7.3.0.zip
unzip elasticsearch-analysis-ik-7.3.0.zip
2. 配置文件
2.1 es.yml
cluster.name: my-elasticsearch
node.name: master
node.master: true
node.data: true
bootstrap.memory_lock: false
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["192.168.125.5:9200"]
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes:
- master
2.2 kibana.yml
2.3 docker-compose.yml
version: "2"
services:
elastic:
image: elasticsearch:7.3.0
container_name: es
environment:
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
volumes:
- /etc/localtime:/etc/localtime
- /app/es/data:/usr/share/elasticsearch/data
- /app/es/logs:/usr/share/elasticsearch/logs
- /app/es/plugins/ik:/usr/share/elasticsearch/plugins/ik
- /app/es/es.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- 9200:9200
- 9300:9300
3.启动docker-compose
docker-compose up -d
4.停止docker-compose
docker-compose down