基于centos7安装docker 并使用docker-compose安装各类中间件

  1. 安装docker源在这里插入图片描述
    在这里插入图片描述

1.sudo yum install -y yum-utils
2.sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  1. 安装docker
    在这里插入图片描述

sudo yum install -y docker-ce-19.03.15 docker-ce-cli-19.03.15 containerd.io-1.4.3

  1. 配置docker开机自启在这里插入图片描述

sudo systemctl enable docker --now

  1. 配置docker从阿里云下载镜像

去自己的阿里云阿里云的容器镜像服务
在这里插入图片描述
直接复制就行

  1. docker就安装成功
  2. 安装Docker-Compose在这里插入图片描述

1.curl -L “https://github.com/docker/compose/releases/download/1.29.2/docker-compose- ( u n a m e − s ) − (uname -s)- (unames)(uname -m)” -o /usr/local/bin/docker-compose
2.chmod +x /usr/local/bin/docker-compose
3.docker-compose --version

  1. 开始使用docker-compose批量安装设置中间件在这里插入图片描述

命令docker-compose -f my-compose.yaml up -d
文件名是my-compose.yaml

services:

  mysql-master: 
    image: mysql:5.7
    restart: always
    ports:
      - 3306:3306
    volumes:
      - mysql-master-log:/var/log/mysql
      - mysql-master-data:/var/lib/mysql
      - mysql-master-conf:/etc/mysql/conf.d
    environment:
      - MYSQL_ROOT_PASSWORD=123456
    networks:
      - mall
  
  mongodb:
    image: mongo:6.0
    ports:
      - 27017:27017
    restart: always
    volumes:
      - mongodb-data:/data/db
      - mongodb-logs:/var/log/mongodb
      - mongodb-conf:/etc/mongo
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: 123456
    networks:
      - mall
      
  redis:
    image: redis:6.2.5
    restart: always
    ports:
      - 6379:6379
    volumes:
      - redis-conf:/etc/redis
      - redis-data:/data
    networks:
      - mall
    command: redis-server /etc/redis/redis.conf

  elasticsearch:
    image: elasticsearch:7.13.4
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - mall
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
      - bootstrap.memory_lock=true
    volumes:
      - es-config:/usr/share/elasticsearch/config
      - es-data:/usr/share/elasticsearch/data
      - es-plugins:/usr/share/elasticsearch/plugins
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65535
        hard: 65535



  kibana:
    image: kibana:7.13.4
    restart: always
    ports:
      - 5601:5601
    networks:
      - mall
    environment:
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    depends_on:
      - elasticsearch
     
  filebeats:
    image: elastic/filebeat:7.13.4
    restart: always
    networks:
      - mall
    volumes:
      - filebeat-conf:/usr/share/filebeat
      - /var/log:/var/filebeat-log
    


  rabbitmq:
    image: rabbitmq:3.8-management
    restart: always
    hostname: mall-rabbit
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - mall
    environment:
      - RABBITMQ_DEFAULT_PASS=admin
      - RABBITMQ_DEFAULT_USER=admin
    volumes:
      - rabbit-conf:/etc/rabbitmq
      - rabbit-data:/var/lib/rabbitmq

  zipkin:
    image: openzipkin/zipkin:2
    restart: always
    ports:
      - 9411:9411
    networks:
      - mall

  sentinel:
    image: leifengyang/sentinel:1.8.2
    restart: always
    ports:
      - 8858:8080
    networks:
      - mall

  nacos:  #nacos把所有数据都保存到mysql
    image: nacos/nacos-server:2.0.2
    restart: always
    ports:
      - 8848:8848
    networks:
      - mall
    environment:
      - MODE=standalone
      - SPRING_DATASOURCE_PLATFORM=mysql
      - MYSQL_SERVICE_HOST=mysql-master
      - MYSQL_SERVICE_PORT=3306
      - MYSQL_SERVICE_DB_NAME=nacos_db
      - MYSQL_SERVICE_USER=root
      - MYSQL_SERVICE_PASSWORD=123456
      - JVM_XMX=256m
      - JVM_XMS=256m
    depends_on:
      - mysql-master

  minio:
    image: minio/minio
    command: server --console-address ":9001" /data
    restart: always
    networks:
      - mall
    ports:
      - 9000:9000
      - 9001:9001
    volumes:
      - minio-conf:/root/.minio
      - minio-data:/data
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MINIO_ACCESS_KEY=admin
      - MINIO_SECRET_KEY=admin123456

   
  nginx:
    image: nginx
    restart: always
    networks:
      - mall
    ports:
      - 80:80
    volumes:
      - nginx-html:/usr/share/nginx/html
      - nginx-conf:/etc/nginx


volumes:
  mysql-master-log:
  mysql-master-data:
  mysql-master-conf:
  mongodb-data:
  mongodb-logs:
  mongodb-conf:
  redis-conf:
  redis-data:
  es-config:
  es-data:
  filebeat-conf:
  rabbit-conf:
  rabbit-data:
  minio-conf:
  minio-data:
  nginx-html:
  nginx-conf:


networks:
  mall:
    ipam:
      driver: default
      config:
        - subnet: "177.10.0.0/16"

等待安装完成之后
查看docker容器列表 和镜像列表即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值