mysql5.6分布式_MySQL 部署

使用 mysql 部署

duic 支持使用 MySQL 存储配置数据(兼容 MariaDB)。

前提Java >= 1.8

MySQL >= 5.6

创建数据库CREATE DATABASE IF NOT EXISTS`duic`CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

启动配置

application.yml

spring:

datasource:

url:jdbc:mysql://127.0.0.1:3306/duic?autoReconnect=true&useServerPrepStmts=true

username:root

password:root

参数详细解释-

spring.datasource 数据源

-

url mysql 连接地址

-

username mysql 连接用户

-

password mysql 连接用户密码

docker 部署启动镜像

$ docker run-d-p7777:7777-e DUIC_OPTS=-Dspring.profiles.active=mysql-v $(pwd)/config:/app/config zhudyos/duic

Tip

将 application.yml 配置文件所在目录挂载到容器的 /app/config 目录中

通过 DUIC_OPTS 环境变量设置数据库类型

测试

$ curl http://localhost:7777/index.html

传统 java 方式部署确认 java 环境至少是 1.8 或以上的版本

$ java-version

java version"1.8.0_151"

Java(TM)SERuntimeEnvironment(build1.8.0_151-b12)

JavaHotSpot(TM)64-BitServerVM(build25.151-b12,mixed mode)

创建 duic 目录

$ mkdir/opt/duic

进入 duic 目录

$ cd/opt/duic

在 GitHub Releases 页面获取 duic-[version].jar 并放置在 /opt/duic 目录中

$ wget https://github.com/zhudyos/duic/releases/download/[version]/duic-[version].jar -O duic.jar

Tip

在部署时需要将 url 中的版本替换为你需要的版本号,最好从 GitHub Releases 找到合适的版本后复制下载地址

创建配置文件目录

$ mkdir config

Tip

确保 config 是 /opt/duic 的子目录

进入配置文件目录

$ cd config

创建启动配置文件/并将数据库连接配置写入文件

$ touch application.yml

启动 duic

$ java-Dspring.profiles.active=mysql-jar duic.jar

Tip

spring.profiles.active

mysql 使用 mysql 存储配置数据时该参数必须增加

在控制台看见如下日志输出即启动成功

______ _ ______

|_ _`. (_) .' ___ |

| | `.\ __ _ __/.' \_|

| | | |[ | | | [ || |

_| |_.'/|\_/|,||\`.___.'\

|______.' '.__.'_/[___]`.____.'

:: duic :: (v1.5.2-SNAPSHOT)

2018-05-03 07:06:05,980 INFO i.z.d.server.Application$Companion - Starting Application.Companion v1.5.2-SNAPSHOT on ubuntu with PID 47440 (/opt/duic/duic.jar started by zy in /opt/duic)

2018-05-03 07:06:05,984 INFO i.z.d.server.Application$Companion - The following profiles are active: mysql,prod

2018-05-03 07:06:09,595 INFO r.i.netty.tcp.BlockingNettyContext - Started HttpServer on /0:0:0:0:0:0:0:0%0:7777

2018-05-03 07:06:09,596 INFO o.s.b.w.e.netty.NettyWebServer - Netty started on port(s): 7777

2018-05-03 07:06:09,600 INFO i.z.d.server.Application$Companion - Started Application.Companion in 4.192 seconds (JVM running for 4.864)

测试

$ curl http://localhost:7777/index.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值