01.安装Docker

1.1 yum安装docker

[root@k8s-master ~]##  yum -y install wget
[root@k8s-master ~]##  wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
[root@k8s-master ~]##  yum -y install docker-ce
[root@k8s-master ~]##  systemctl enable docker && systemctl start docker
  • 配置镜像下载加速器:
[root@k8s-master ~]##  cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"]
}
EOF
[root@k8s-master ~]##  systemctl restart docker
[root@k8s-master ~]##  docker info

1.2 添加阿里云YUM软件源

[root@k8s-master ~]##  cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

02.docker安装ES

2.1 docker安装es

  • docker安装es
[root@k8s-node2 ~]##  docker pull elasticsearch:7.2.0
[root@k8s-node2 ~]##  docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -d elasticsearch:7.2.0
  • 修改配置,解决跨域访问问题
    • 首先进入到容器中,然后进入到指定目录修改elasticsearch.yml文件
[root@k8s-node2 ~]##  docker pull elasticsearch:7.2.0
 
[root@k8s-node2 ~]##  docker exec -it elasticsearch /bin/bash
[root@de5bba3e2d81 elasticsearch]##  cd /usr/share/elasticsearch/config/
[root@de5bba3e2d81 elasticsearch]##  vi elasticsearch.yml
## 追加一下内容,解决跨域问题
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@de5bba3e2d81 elasticsearch]##  exit
[root@k8s-node2 ~]##   docker restart elasticsearch

2.2 安装ik分词器

  • es自带的分词器对中文分词不是很友好,所以我们下载开源的IK分词器来解决这个问题。

  • 首先进入到plugins目录中下载分词器,下载完成后然后解压,再重启es即可。

  • 注意:elasticsearch的版本和ik分词器的版本需要保持一致,不然在重启的时候会失败。

[root@k8s-node2 ~]##  cd /usr/share/elasticsearch/plugins/
[root@de5bba3e2d81 elasticsearch]## elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.2.0/elasticsearch-analysis-ik-7.2.0.zip
[root@de5bba3e2d81 elasticsearch]##  exit
[root@k8s-node2 ~]##  docker restart elasticsearch   ## 然后可以在kibana界面的dev tools中验证是否安装成功;

2.3 安装kinaba

[root@k8s-node2 ~]## docker pull kibana:7.2.0
[root@k8s-node2 ~]## docker run --name kibana --link=elasticsearch:test  -p 5601:5601 -d kibana:7.2.0
[root@k8s-node2 ~]## docker start kibana

__END__