• 微服务基础设施配置


     

    #基础设施

    #本节视频

    #概述

    本章节为开发所需各种服务的docker-compose.yml 配置文件

    #MySQL 8.x

    version: '3.1'
    services:
      db:
        image: mysql
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: 123456
        command:
          --default-authentication-plugin=mysql_native_password
          --character-set-server=utf8mb4
          --collation-server=utf8mb4_general_ci
          --explicit_defaults_for_timestamp=true
          --lower_case_table_names=1
        ports:
          - 3306:3306
        volumes:
          - ./data:/var/lib/mysql
    
      adminer:
        image: adminer
        restart: always
        ports:
          - 8080:8080
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23

    #GitLab

    参考 GitLab 章节

    
    version: '3'
    services:
        web:
          image: 'twang2218/gitlab-ce-zh'
          restart: always
          hostname: '192.168.10.132'
          environment:
            TZ: 'Asia/Shanghai'
            GITLAB_OMNIBUS_CONFIG: |
              external_url 'http://192.168.10.132:8080'
              gitlab_rails['gitlab_shell_ssh_port'] = 2222
              unicorn['port'] = 8888
              nginx['listen_port'] = 8080
          ports:
            - '8080:8080'
            - '8443:443'
            - '2222:22'
          volumes:
            - ./config:/etc/gitlab
            - ./data:/var/opt/gitlab
            - ./logs:/var/log/gitlab
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22

    #Nexus

    参考 Nexus 章节

    version: '3.1'
    services:
      nexus:
        restart: always
        image: sonatype/nexus3
        container_name: nexus
        ports:
          - 8081:8081
        volumes:
          - data:/nexus-data
    
    volumes:
      data:
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

    #Registry

    参考 Registry 章节

    version: '3.1'
    services:
      registry:
        image: registry
        restart: always
        container_name: registry
        ports:
          - 5000:5000
        volumes:
          - ./data:/var/lib/registry
    
      frontend:
        image: konradkleine/docker-registry-frontend:v2
        restart: always
        ports:
          - 8080:80
        volumes:
          - ./certs/frontend.crt:/etc/apache2/server.crt:ro
          - ./certs/frontend.key:/etc/apache2/server.key:ro
        environment:
          - ENV_DOCKER_REGISTRY_HOST=192.168.10.139
          - ENV_DOCKER_REGISTRY_PORT=5000
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22

    #Jenkins

    参考 Jenkins 章节

    version: '3.1'
    services:
      jenkins:
        restart: always
        image: jenkinsci/jenkins
        container_name: jenkins
        ports:
          - 8080:8080
          - 50000:50000
        environment:
          TZ: Asia/Shanghai
        volumes:
          - data:/var/jenkins_home
    
    volumes:
      data:
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    #SkyWalking

    操作步骤同 SkyWalking 服务端配置 ,执行的脚本为 startup.sh,在此之前别忘记在 Linux 上安装 Java 哦!

    #RocketMQ

    参考 RocketMQ 章节

    ./data/brokerconf/broker.conf

    brokerClusterName=DefaultCluster
    brokerName=broker-a
    brokerId=0
    brokerIP1=192.168.10.149
    defaultTopicQueueNums=4
    autoCreateTopicEnable=true
    autoCreateSubscriptionGroup=true
    listenPort=10911
    deleteWhen=04
    fileReservedTime=120
    mapedFileSizeCommitLog=1073741824
    mapedFileSizeConsumeQueue=300000
    diskMaxUsedSpaceRatio=88
    maxMessageSize=65536
    brokerRole=ASYNC_MASTER
    flushDiskType=ASYNC_FLUSH
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    docker-compose.yml

    version: '3.5'
    services:
      rmqnamesrv:
        image: foxiswho/rocketmq:server
        container_name: rmqnamesrv
        restart: always
        ports:
          - 9876:9876
        volumes:
          - ./data/logs:/opt/logs
          - ./data/store:/opt/store
        networks:
            rmq:
              aliases:
                - rmqnamesrv
    
      rmqbroker:
        image: foxiswho/rocketmq:broker
        container_name: rmqbroker
        restart: always
        ports:
          - 10909:10909
          - 10911:10911
        volumes:
          - ./data/logs:/opt/logs
          - ./data/store:/opt/store
          - ./data/brokerconf/broker.conf:/etc/rocketmq/broker.conf
        environment:
            NAMESRV_ADDR: "rmqnamesrv:9876"
            JAVA_OPTS: " -Duser.home=/opt"
            JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
        command: mqbroker -c /etc/rocketmq/broker.conf
        depends_on:
          - rmqnamesrv
        networks:
          rmq:
            aliases:
              - rmqbroker
    
      rmqconsole:
        image: styletang/rocketmq-console-ng
        container_name: rmqconsole
        restart: always
        ports:
          - 8080:8080
        environment:
            JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
        depends_on:
          - rmqnamesrv
        networks:
          rmq:
            aliases:
              - rmqconsole
    
    networks:
      rmq:
        name: rmq
        driver: bridge
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58

    #Nacos

    参考 Nacos 章节

    git clone https://github.com/nacos-group/nacos-docker.git
    cd nacos-docker
    docker-compose -f example/standalone-mysql.yaml up
    
    1
    2
    3

    控制台:http://127.0.0.1:8848/nacos/

    #Sentinel

    操作步骤同 使用熔断器仪表盘监控 ,在此之前别忘记在 Linux 上安装 Java 和 Maven 哦!

    #Nginx

    参考 Nginx 章节

    version: '3.1'
    services:
      nginx:
        restart: always
        image: nginx
        container_name: nginx
        ports:
          - 80:80
        volumes:
          - ./conf/nginx.conf:/etc/nginx/nginx.conf
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    #Redis HA

    参考 Redis 章节

    version: '3.1'
    services:
      master:
        image: redis
        container_name: redis-master
        ports:
          - 6379:6379
    
      slave1:
        image: redis
        container_name: redis-slave-1
        ports:
          - 6380:6379
        command: redis-server --slaveof redis-master 6379
    
      slave2:
        image: redis
        container_name: redis-slave-2
        ports:
          - 6381:6379
        command: redis-server --slaveof redis-master 6379
    
      sentinel1:
        image: redis
        container_name: redis-sentinel-1
        ports:
          - 26379:26379
        command: redis-sentinel /usr/local/etc/redis/sentinel.conf
        volumes:
          - ./sentinel1.conf:/usr/local/etc/redis/sentinel.conf
    
      sentinel2:
        image: redis
        container_name: redis-sentinel-2
        ports:
          - 26380:26379
        command: redis-sentinel /usr/local/etc/redis/sentinel.conf
        volumes:
          - ./sentinel2.conf:/usr/local/etc/redis/sentinel.conf
    
      sentinel3:
        image: redis
        container_name: redis-sentinel-3
        ports:
          - 26381:26379
        command: redis-sentinel /usr/local/etc/redis/sentinel.conf
        volumes:
          - ./sentinel3.conf:/usr/local/etc/redis/sentinel.conf
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48

    sentinel.conf

    port 26379
    dir /tmp
    # 自定义集群名,其中 127.0.0.1 为 redis-master 的 ip,6379 为 redis-master 的端口,2 为最小投票数(因为有 3 台 Sentinel 所以可以设置成 2)
    sentinel monitor mymaster 127.0.0.1 6379 2
    sentinel down-after-milliseconds mymaster 30000
    sentinel parallel-syncs mymaster 1
    sentinel failover-timeout mymaster 180000
    sentinel deny-scripts-reconfig yes
    
    1
    2
    3
    4
    5
    6
    7
    8

    #附:环境变量配置

    /etc/environment

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    
    export JAVA_HOME=/usr/local/jdk1.8.0_152
    export JRE_HOME=/usr/local/jdk1.8.0_152/jre
    export MAVEN_HOME=/usr/local/apache-maven-3.5.3
    export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$MAVEN_HOME/bin
    
    1
    2
    3
    4
    5
    6

    /etc/profile

    export JAVA_HOME=/usr/local/jdk1.8.0_152
    export JRE_HOME=/usr/local/jdk1.8.0_152/jre
    export MAVEN_HOME=/usr/local/apache-maven-3.5.3
    export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
    export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin:$MAVEN_HOME/bin
    
    1
    2
    3
    4
    5
    上次更新: 1/22/2019, 2:30:23 AM
  • 相关阅读:
    BP神经网络模型
    支持向量机-分类器之王
    逻辑回归
    git常用命令总结持续更新
    gitlap安装配置网络这个坑
    mysql简单备份脚本
    mysql的my.cnf文件详解
    二进制部署mysql5.6
    CMDB学习之七-实现采集错误捕捉,日志信息处理
    CMDB学习之八,完成所有资产采集信息的收集
  • 原文地址:https://www.cnblogs.com/leigepython/p/11009875.html
Copyright © 2020-2023  润新知