• 设备
    • 今日
    • 1

    Ubuntu18上安装Docker-Compose并全自动部署

    cd /home/docker/

    rm -rf *

    1.进入https://github.com/docker/compose/releases 查看最新版本,当前版本为1.23.1
    curl -L https://github.com/docker/compose/releases/download/1.25.0-rc2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    2.设置权限
    sudo chmod +x /usr/local/bin/docker-compose

    3.查看是否安装成功
    docker-compose --version

    4.自定义docker-compose.yml文件
    cd /opt/
    vi docker-compose.yml
    ————————————————
    version: '3'
    services:

    zabbix_mysql:
    container_name: "zabbix_mysql"
    restart: "always"
    image: mariadb
    ports:

    - "3306:3306"

    command: [
    '--character-set-server=utf8',
    '--collation-server=utf8_unicode_ci',
    '--default-time-zone=+8:00'
    ]

    volumes:

    - /etc/localtime:/etc/localtime:ro
    - /home/docker/data/mysql:/var/lib/mysql
    environment:
    MYSQL_ROOT_PASSWORD: "123"
    MYSQL_USER: "zabbix"
    MYSQL_PASSWORD: "123"
    MYSQL_DATABASE: "zabbix"

    zabbix_server:
    container_name: "zabbix_server"
    restart: "always"
    image: zabbix/zabbix-server-mysql
    ports:
    - "10051:10051"
    volumes:
    - /etc/localtime:/etc/localtime:ro
    - /home/docker/data/zabbix:/usr/lib/zabbix
    depends_on:
    - zabbix_mysql
    links:
    - zabbix_mysql:mysql
    environment:
    DB_SERVER_HOST: "mysql"
    MYSQL_USER: "zabbix"
    MYSQL_DATABASE: "zabbix"
    MYSQL_PASSWORD: "123"

    zabbix_web:
    container_name: "zabbix_web"
    restart: "always"
    image: zabbix/zabbix-web-nginx-mysql
    ports:
    - "8443:443"
    - "80:80"
    volumes:
    - /etc/localtime:/etc/localtime:ro
    depends_on:
    - zabbix_mysql
    - zabbix_server
    links:
    - zabbix_mysql:mysql
    - zabbix_server:zabbix_server
    environment:
    DB_SERVER_HOST: "mysql"
    MYSQL_USER: "zabbix"
    MYSQL_PASSWORD: "123"
    MYSQL_DATABASE: "zabbix"
    ZBX_SERVER_HOST: "zabbix_server"
    PHP_TZ: "Asia/Shanghai"

    zabbix-agent:
    image: zabbix/zabbix-agent
    links:
    - zabbix_server:zabbix_server
    container_name: zabbix-agent
    restart: always
    depends_on:
    - zabbix_server
    environment:
    - ZBX_HOSTNAME=VboxUbuntu
    - ZBX_SERVER_HOST=192.168.1.114,172.18.0.1
    ports:
    - "10050:10050"
    volumes:
    - /etc/localtime:/etc/localtime:ro
    ————————————————

    sudo chmod +x /opt/docker-compose.yml
    docker-compose up -d
    ------
    Creating network "opt_default" with the default driver
    Pulling mysql-server-for-z (mysql:5.7)...
    5.7: Pulling from library/mysql
    8f91359f1fff: Pull complete
    6bbb1c853362: Pull complete
    e6e554c0af6f: Pull complete
    f391c1a77330: Pull complete
    414a8a88eabc: Pull complete
    fee78658f4dd: Pull complete
    9568f6bff01b: Pull complete
    ....
    ------
    第一次安装会自动下载数据库和zabbix等依赖文件,会比较慢
    已经下载过的话会直接尝试启动
    启动后,虽然已经提示说done了,但其实docker内部启动app等还是需要点时间的
    如果立即通过网页查看,会看不到,因为还在启动中,需要等2-3分钟再从网页上查看,就能出现zabbix登录页面了
    登录地址是你的本机地址,如果端口(Z_port)改过,就要在浏览器里加上改过的端口 账号密码是admin/zabbix

    检查数据库字体:

     SHOW VARIABLES LIKE 'character_set_%';
    +--------------------------+----------------------------+
    | Variable_name            | Value                      |
    +--------------------------+----------------------------+
    | character_set_client     | latin1                     |
    | character_set_connection | latin1                     |
    | character_set_database   | utf8                       |
    | character_set_filesystem | binary                     |
    | character_set_results    | latin1                     |
    | character_set_server     | latin1                     |
    | character_set_system     | utf8                       |
    | character_sets_dir       | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.00 sec)

    来自:PC 广东省广州市
    上一篇: Docker问题库
    您可能还喜欢这些:

    亲,沙发正空着,还不快来抢?

    评论审核已开启 记住我的个人信息 回复后邮件通知我