Centos7使用docker搭建elasticsearch

安装docker

cat >/etc/yum.repos.d/docker.repo<<EOF
[docker-ce-edge]
name=Docker CE Edge - \$basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/\$basearch/edge
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
EOF

yum安装

yum -y install docker-ce

查看docker版本

docker --version

启动docker

systemctl enable docker
systemctl start docker

安装docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

加速docker镜像

可登录阿里云
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
然后获得
https://******.mirror.aliyuncs.com
页面中也有设置加速的代码

启动容器

创建对应文件夹目录
把下面文件保存成docker-compose.yml文件
执行:
docker-compose up
(如果有报错自行百度)

version: '2.2'
services:
  es790:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.0
    container_name: es790
    environment:
      - node.name=es790
      - cluster.initial_master_nodes=es790
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data:/usr/share/elasticsearch790/data
    ports:
      - 9202:9200
    networks:
      - elastic7
  kib01:
    image: docker.elastic.co/kibana/kibana:7.9.0
    container_name: kib01
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_URL: http://es790:9200
      ELASTICSEARCH_HOSTS: '["http://es790:9200"]'
    networks:
      - elastic7
networks:
  elastic7:
    driver: bridge

如果报错
Native controller process has stopped - no new native processes can be started
可以将
- cluster.initial_master_nodes=es790
注释掉
然后添加
- discovery.type=single-node

安装ik分词

切换到docker项目根目录

docker-compose exec es790 /usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.0/elasticsearch-analysis-ik-7.9.0.zip

systemctl restart docker

验证

访问安装机器的
ip:9202 以及 5601是否正常访问

如果正常访问可以停止容器,然后使用
docker-compose up -d
挂在后台运行即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Joshua Burgin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值