DockerCompose+SpringBoot+Nginx+Mysql实践

news2024/12/24 11:42:45

DockerCompose+SpringBoot+Nginx+Mysql实践

1、Spring Boot案例

首先我们先准备一个 Spring Boot 使用 Mysql 的小场景,我们做这样一个示例,使用 Spring Boot 做一个 Web 应

用,提供一个按照 IP 地址统计访问次数的方法,每次请求时将统计数据存入 Mysql 并展示到页面中。

1.1 pom依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.neo</groupId>
    <artifactId>dockercompose-springboot-mysql-nginx</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>dockercompose-springboot-mysql-nginx</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <defaultGoal>compile</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

主要添加了 Spring Boot Web 支持,使用 Jpa 操作数据库、添加 Myql 驱动包等。

1.2 配置文件

application.properties

spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=true

spring.profiles.active=dev
server.port=8090

application-dev.properties

spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
server.port=8090

application-docker.properties

spring.datasource.url=jdbc:mysql://mysql:3306/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
server.port=8090

配置了数据库的链接信息,以及 Jpa 更新表模式、方言和是否显示Sql。

1.3 核心代码

核心代码很简单,每过来一个请求,判断是否已经统计过,如果没有统计新增数据,如果有统计数据更新数据。

package com.neo.controller;

import com.neo.entity.Visitor;
import com.neo.repository.VisitorRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class VisitorController {

    @Autowired
    private VisitorRepository repository;

    @RequestMapping("/")
    public String index(HttpServletRequest request) {
        String ip = request.getRemoteAddr();
        Visitor visitor = repository.findByIp(ip);
        if (visitor == null) {
            visitor = new Visitor();
            visitor.setIp(ip);
            visitor.setTimes(1);
        } else {
            visitor.setTimes(visitor.getTimes() + 1);
        }
        repository.save(visitor);
        return "I have been seen ip " + visitor.getIp() + " " + visitor.getTimes() + " times.";
    }
}

实体类和 Repository 层代码比较简单。

package com.neo.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
public class Visitor {
    @Id
    @GeneratedValue
    private long id;
    @Column(nullable = false)
    private long times;
    @Column(nullable = false)
    private String ip;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getTimes() {
        return times;
    }

    public void setTimes(long times) {
        this.times = times;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }
}
package com.neo.repository;

import com.neo.entity.Visitor;
import org.springframework.data.jpa.repository.JpaRepository;

public interface  VisitorRepository extends JpaRepository<Visitor, Long> {
    Visitor findByIp(String ip);
}
package com.neo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ComposeApplication {

    public static void main(String[] args) {
        SpringApplication.run(ComposeApplication.class, args);
    }
}

以上内容都完成后,启动项目,访问:http://localhost:8090/ 我们就可以看到这样的返回结果:

I have been seen ip 0:0:0:0:0:0:0:1 1 times.

再访问一次会变成

I have been seen ip 0:0:0:0:0:0:0:1 2 times.

多次访问一直叠加,说明演示项目开发完成。

2、Docker化改造

首先我们将目录改造成这样一个结构

在这里插入图片描述

我们先从最外层说起:

  • docker-compose.yaml:docker-compose 的核心文件,描述如何构建整个服务。

  • nginx:有关 nginx 的配置。

  • app:Spring Boot 项目地址。

如果我们需要对 Mysql 有特殊的定制,也可以在最外层创建 mysql 文件夹,在此目录下进行配置。

2.1 docker-compose.yaml 文件详解

version: '3'
services:
  nginx:
    container_name: v-nginx
    image: nginx:1.13
    restart: always
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d

  mysql:
    container_name: v-mysql
    image: mysql/mysql-server:5.7
    environment:
      MYSQL_DATABASE: test
      MYSQL_ROOT_PASSWORD: root
      MYSQL_ROOT_HOST: '%'
    ports:
      - "3306:3306"
    restart: always

  app:
    container_name: app
    restart: always
    build: ./app
    working_dir: /app
    volumes:
      - ./app:/app
      - /home/zhangshixing/maven/m2:/root/.m2
    expose:
      - "8090"
    depends_on:
      - nginx
      - mysql
    command: mvn clean spring-boot:run -Dspring-boot.run.profiles=docker
  • version: '3': 表示使用第三代语法来构建 docker-compose.yaml 文件。

  • services:用来表示 compose 需要启动的服务,我们可以看出此文件中有三个服务分别为:nginx、

    mysql、app。

  • container_name:容器名称

  • environment:此节点下的信息会当作环境变量传入容器,此示例中 mysql 服务配置了数据库、密码和权限

    信息。

  • ports:表示对外开放的端口

  • restart: always:表示如果服务启动不成功会一直尝试。

  • volumes:加载本地目录下的配置文件到容器目标地址下

  • depends_on:可以配置依赖服务,表示需要先启动 depends_on 下面的服务后,再启动本服务。

  • command: mvn clean spring-boot:run -Dspring-boot.run.profiles=docker :表示以这个命令来启

    动项目,-Dspring-boot.run.profiles=docker表示使用 application-docker.properties文件配置信

    息进行启动。

2.2 Nginx 文件解读

nginx 在目录下有一个文件 app.conf,主要配置了服务转发信息。

server {
    listen 80;
    charset utf-8;
    access_log off;

    location / {
        proxy_pass http://app:8090;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /static {
        access_log   off;
        expires      30d;

        alias /app/static;
    }
}

这块内容比较简单,配置请求转发,将80端口的请求转发到服务 app 的8090端口。其中proxy_pass

http://app:8090这块的配置信息。

需要解释一下,这里使用是app而不是localhost,是因为他们没有在一个容器中,在一组 compose 的服务通

讯需要使用 services 的名称进行访问。

2.3 Spring Boot 项目改造

app目录下也就是和pom.xm文件同级添加Dockerfile文件,文件内容如下:

FROM maven:3.5-jdk-8

只有一句,依赖于基础镜像maven3.5jdk1.8。因为在docker-compose.yaml文件设置了项目启动命令,这

里不需要再添加启动命令。

在项目的resources目录下创建application-dev.propertiesapplication-docker.properties文件

  • application-dev.properties 中的配置信息和上面一致

  • application-docker.properties 中的配置信息做稍微的改造,将数据库的连接信息由

    jdbc:mysql://localhost:3306/test改为jdbc:mysql://mysql:3306/test

这样我们所有的配置都已经完成。

2.4 部署

我们将项目拷贝到服务器中进行测试,服务器需要先安装 Docker 和 Docker Compos 环境。

将项目拷贝到服务器中,进入目录:cd dockercompose-springboot-mysql-nginx

启动服务:docker-compose up

[root@zsx dockercompose-springboot-mysql-nginx]# docker-compose up
[+] Running 4/4
 ⠿ Network dockercompose-springboot-mysql-nginx_default  Created                                                               0.2s
 ⠿ Container v-mysql                                     Created                                                               0.1s
 ⠿ Container v-nginx                                     Created                                                               0.1s
 ⠿ Container app                                         Created                                                               0.3s
Attaching to app, v-mysql, v-nginx
v-mysql  | [Entrypoint] MySQL Docker Image 5.7.41-1.2.11-server
v-mysql  | [Entrypoint] Initializing database
v-mysql  | 2024-01-28T04:06:28.932555Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
v-mysql  | 2024-01-28T04:06:29.181788Z 0 [Warning] InnoDB: New log files created, LSN=45790
v-mysql  | 2024-01-28T04:06:29.273310Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
v-mysql  | 2024-01-28T04:06:29.408225Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9d205946-bd92-11ee-a298-0242ac120003.
v-mysql  | 2024-01-28T04:06:29.416618Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
v-mysql  | 2024-01-28T04:06:29.767946Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
v-mysql  | 2024-01-28T04:06:29.770248Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
v-mysql  | 2024-01-28T04:06:29.770782Z 0 [Warning] CA certificate ca.pem is self signed.
v-mysql  | 2024-01-28T04:06:29.825640Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
app      | [INFO] Scanning for projects...
app      | [INFO]
app      | [INFO] ------------< com.neo:dockercompose-springboot-mysql-nginx >------------
app      | [INFO] Building dockercompose-springboot-mysql-nginx 1.0
app      | [INFO] --------------------------------[ jar ]---------------------------------
app      | [INFO]
app      | [INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ dockercompose-springboot-mysql-nginx ---
app      | [INFO] Deleting /app/target
app      | [INFO]
app      | [INFO] >>> spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) > test-compile @ dockercompose-springboot-mysql-nginx >>>
app      | [INFO]
app      | [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ dockercompose-springboot-mysql-nginx ---
app      | [INFO] Using 'UTF-8' encoding to copy filtered resources.
app      | [INFO] Copying 3 resources
app      | [INFO] Copying 0 resource
app      | [INFO]
app      | [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ dockercompose-springboot-mysql-nginx ---
app      | [INFO] Changes detected - recompiling the module!
app      | [INFO] Compiling 4 source files to /app/target/classes
app      | [INFO]
app      | [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ dockercompose-springboot-mysql-nginx ---
app      | [INFO] Using 'UTF-8' encoding to copy filtered resources.
app      | [INFO] skip non existing resourceDirectory /app/src/test/resources
app      | [INFO]
app      | [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ dockercompose-springboot-mysql-nginx ---
app      | [INFO] Nothing to compile - all classes are up to date
app      | [INFO]
app      | [INFO] <<< spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) < test-compile @ dockercompose-springboot-mysql-nginx <<<
app      | [INFO]
app      | [INFO]
app      | [INFO] --- spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) @ dockercompose-springboot-mysql-nginx ---
v-mysql  | [Entrypoint] Database initialized
v-mysql  | 2024-01-28T04:06:36.934640Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
v-mysql  | 2024-01-28T04:06:36.935929Z 0 [Note] mysqld (mysqld 5.7.41) starting as process 50 ...
v-mysql  | 2024-01-28T04:06:36.947967Z 0 [Note] InnoDB: PUNCH HOLE support available
v-mysql  | 2024-01-28T04:06:36.947993Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
v-mysql  | 2024-01-28T04:06:36.947996Z 0 [Note] InnoDB: Uses event mutexes
v-mysql  | 2024-01-28T04:06:36.947999Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
v-mysql  | 2024-01-28T04:06:36.948001Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.12
v-mysql  | 2024-01-28T04:06:36.948003Z 0 [Note] InnoDB: Using Linux native AIO
v-mysql  | 2024-01-28T04:06:36.948198Z 0 [Note] InnoDB: Number of pools: 1
v-mysql  | 2024-01-28T04:06:36.948282Z 0 [Note] InnoDB: Using CPU crc32 instructions
v-mysql  | 2024-01-28T04:06:36.960215Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
v-mysql  | 2024-01-28T04:06:36.994304Z 0 [Note] InnoDB: Completed initialization of buffer pool
v-mysql  | 2024-01-28T04:06:36.996097Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
v-mysql  | 2024-01-28T04:06:37.009968Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
v-mysql  | 2024-01-28T04:06:37.062369Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
v-mysql  | 2024-01-28T04:06:37.062444Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
v-mysql  | 2024-01-28T04:06:37.109205Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
v-mysql  | 2024-01-28T04:06:37.109985Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
v-mysql  | 2024-01-28T04:06:37.109993Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
v-mysql  | 2024-01-28T04:06:37.110223Z 0 [Note] InnoDB: Waiting for purge to start
v-mysql  | 2024-01-28T04:06:37.166911Z 0 [Note] InnoDB: 5.7.41 started; log sequence number 2762314
v-mysql  | 2024-01-28T04:06:37.167162Z 0 [Note] Plugin 'FEDERATED' is disabled.
v-mysql  | 2024-01-28T04:06:37.176325Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
v-mysql  | 2024-01-28T04:06:37.176340Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
v-mysql  | 2024-01-28T04:06:37.176344Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
v-mysql  | 2024-01-28T04:06:37.176346Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
v-mysql  | 2024-01-28T04:06:37.177082Z 0 [Warning] CA certificate ca.pem is self signed.
v-mysql  | 2024-01-28T04:06:37.177140Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
v-mysql  | 2024-01-28T04:06:37.178061Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
v-mysql  | 2024-01-28T04:06:37.179303Z 0 [Note] InnoDB: Buffer pool(s) load completed at 240128  4:06:37
v-mysql  | 2024-01-28T04:06:37.218314Z 0 [Note] Event Scheduler: Loaded 0 events
v-mysql  | 2024-01-28T04:06:37.218444Z 0 [Note] mysqld: ready for connections.
v-mysql  | Version: '5.7.41'  socket: '/var/lib/mysql/mysql.sock'  port: 0  MySQL Community Server (GPL)
v-mysql  | 2024-01-28T04:06:37.291814Z 3 [Note] InnoDB: Stopping purge
v-mysql  | 2024-01-28T04:06:37.300043Z 3 [Note] InnoDB: Resuming purge
v-mysql  | 2024-01-28T04:06:37.317607Z 3 [Note] InnoDB: Stopping purge
v-mysql  | 2024-01-28T04:06:37.333861Z 3 [Note] InnoDB: Resuming purge
v-mysql  | 2024-01-28T04:06:37.348331Z 3 [Note] InnoDB: Stopping purge
v-mysql  | 2024-01-28T04:06:37.402247Z 3 [Note] InnoDB: Resuming purge
v-mysql  | 2024-01-28T04:06:37.440636Z 3 [Note] InnoDB: Stopping purge
v-mysql  | 2024-01-28T04:06:37.463372Z 3 [Note] InnoDB: Resuming purge
v-mysql  | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
v-mysql  | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
app      |
app      |   .   ____          _            __ _ _
app      |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
app      | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
app      |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
app      |   '  |____| .__|_| |_|_| |_\__, | / / / /
app      |  =========|_|==============|___/=/_/_/_/
app      |  :: Spring Boot ::        (v2.0.0.RELEASE)
app      |
app      | 2024-01-28 04:06:42.640  INFO 1 --- [           main] com.neo.ComposeApplication               : Starting ComposeApplication on 5a1fd4d2cc5a with PID 1 (/app/target/classes started by root in /app)
app      | 2024-01-28 04:06:42.664  INFO 1 --- [           main] com.neo.ComposeApplication               : The following profiles are active: docker
v-mysql  | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
v-mysql  | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
v-mysql  | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
v-mysql  |
v-mysql  | [Entrypoint] ignoring /docker-entrypoint-initdb.d/*
v-mysql  |
v-mysql  | 2024-01-28T04:06:43.208244Z 0 [Note] Giving 0 client threads a chance to die gracefully
v-mysql  | 2024-01-28T04:06:43.208267Z 0 [Note] Shutting down slave threads
v-mysql  | 2024-01-28T04:06:43.208275Z 0 [Note] Forcefully disconnecting 0 remaining clients
v-mysql  | 2024-01-28T04:06:43.208281Z 0 [Note] Event Scheduler: Purging the queue. 0 events
v-mysql  | 2024-01-28T04:06:43.208699Z 0 [Note] Binlog end
v-mysql  | 2024-01-28T04:06:43.209084Z 0 [Note] Shutting down plugin 'ngram'
v-mysql  | 2024-01-28T04:06:43.209092Z 0 [Note] Shutting down plugin 'partition'
v-mysql  | 2024-01-28T04:06:43.209094Z 0 [Note] Shutting down plugin 'BLACKHOLE'
v-mysql  | 2024-01-28T04:06:43.209097Z 0 [Note] Shutting down plugin 'ARCHIVE'
v-mysql  | 2024-01-28T04:06:43.209099Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
v-mysql  | 2024-01-28T04:06:43.209121Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
v-mysql  | 2024-01-28T04:06:43.209125Z 0 [Note] Shutting down plugin 'MyISAM'
v-mysql  | 2024-01-28T04:06:43.209132Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
v-mysql  | 2024-01-28T04:06:43.209135Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
v-mysql  | 2024-01-28T04:06:43.209137Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
v-mysql  | 2024-01-28T04:06:43.209139Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
v-mysql  | 2024-01-28T04:06:43.209141Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
v-mysql  | 2024-01-28T04:06:43.209142Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
v-mysql  | 2024-01-28T04:06:43.209144Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
v-mysql  | 2024-01-28T04:06:43.209146Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
v-mysql  | 2024-01-28T04:06:43.209148Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
v-mysql  | 2024-01-28T04:06:43.209149Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
v-mysql  | 2024-01-28T04:06:43.209151Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
v-mysql  | 2024-01-28T04:06:43.209153Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
v-mysql  | 2024-01-28T04:06:43.209154Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
v-mysql  | 2024-01-28T04:06:43.209156Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
v-mysql  | 2024-01-28T04:06:43.209158Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
v-mysql  | 2024-01-28T04:06:43.209160Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
v-mysql  | 2024-01-28T04:06:43.209161Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
v-mysql  | 2024-01-28T04:06:43.209163Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
v-mysql  | 2024-01-28T04:06:43.209165Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
v-mysql  | 2024-01-28T04:06:43.209167Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
v-mysql  | 2024-01-28T04:06:43.209169Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
v-mysql  | 2024-01-28T04:06:43.209170Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
v-mysql  | 2024-01-28T04:06:43.209172Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
v-mysql  | 2024-01-28T04:06:43.209174Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
v-mysql  | 2024-01-28T04:06:43.209176Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
v-mysql  | 2024-01-28T04:06:43.209178Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
v-mysql  | 2024-01-28T04:06:43.209179Z 0 [Note] Shutting down plugin 'INNODB_CMP'
v-mysql  | 2024-01-28T04:06:43.209181Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
v-mysql  | 2024-01-28T04:06:43.209183Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
v-mysql  | 2024-01-28T04:06:43.209184Z 0 [Note] Shutting down plugin 'INNODB_TRX'
v-mysql  | 2024-01-28T04:06:43.209186Z 0 [Note] Shutting down plugin 'InnoDB'
v-mysql  | 2024-01-28T04:06:43.209230Z 0 [Note] InnoDB: FTS optimize thread exiting.
v-mysql  | 2024-01-28T04:06:43.209911Z 0 [Note] InnoDB: Starting shutdown...
app      | 2024-01-28 04:06:43.222  INFO 1 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@301dca64: startup date [Sun Jan 28 04:06:43 UTC 2024]; root of context hierarchy
v-mysql  | 2024-01-28T04:06:43.311419Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
v-mysql  | 2024-01-28T04:06:43.311649Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 240128  4:06:43
v-mysql  | 2024-01-28T04:06:45.025243Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12184554
v-mysql  | 2024-01-28T04:06:45.029495Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
v-mysql  | 2024-01-28T04:06:45.029524Z 0 [Note] Shutting down plugin 'MEMORY'
v-mysql  | 2024-01-28T04:06:45.029554Z 0 [Note] Shutting down plugin 'CSV'
v-mysql  | 2024-01-28T04:06:45.029560Z 0 [Note] Shutting down plugin 'sha256_password'
v-mysql  | 2024-01-28T04:06:45.029563Z 0 [Note] Shutting down plugin 'mysql_native_password'
v-mysql  | 2024-01-28T04:06:45.029660Z 0 [Note] Shutting down plugin 'binlog'
v-mysql  | 2024-01-28T04:06:45.031085Z 0 [Note] mysqld: Shutdown complete
v-mysql  |
v-mysql  | [Entrypoint] Server shut down
v-mysql  |
v-mysql  | [Entrypoint] MySQL init process done. Ready for start up.
v-mysql  |
v-mysql  | [Entrypoint] Starting MySQL 5.7.41-1.2.11-server
v-mysql  | 2024-01-28T04:06:45.507704Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
v-mysql  | 2024-01-28T04:06:45.509088Z 0 [Note] mysqld (mysqld 5.7.41) starting as process 1 ...
v-mysql  | 2024-01-28T04:06:45.516922Z 0 [Note] InnoDB: PUNCH HOLE support available
v-mysql  | 2024-01-28T04:06:45.516954Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
v-mysql  | 2024-01-28T04:06:45.516958Z 0 [Note] InnoDB: Uses event mutexes
v-mysql  | 2024-01-28T04:06:45.516961Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
v-mysql  | 2024-01-28T04:06:45.516964Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.12
v-mysql  | 2024-01-28T04:06:45.516968Z 0 [Note] InnoDB: Using Linux native AIO
v-mysql  | 2024-01-28T04:06:45.517232Z 0 [Note] InnoDB: Number of pools: 1
v-mysql  | 2024-01-28T04:06:45.517330Z 0 [Note] InnoDB: Using CPU crc32 instructions
v-mysql  | 2024-01-28T04:06:45.518750Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
v-mysql  | 2024-01-28T04:06:45.536989Z 0 [Note] InnoDB: Completed initialization of buffer pool
v-mysql  | 2024-01-28T04:06:45.538826Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
v-mysql  | 2024-01-28T04:06:45.550984Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
v-mysql  | 2024-01-28T04:06:45.600284Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
v-mysql  | 2024-01-28T04:06:45.600371Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
v-mysql  | 2024-01-28T04:06:45.624539Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
v-mysql  | 2024-01-28T04:06:45.625242Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
v-mysql  | 2024-01-28T04:06:45.625253Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
v-mysql  | 2024-01-28T04:06:45.625514Z 0 [Note] InnoDB: Waiting for purge to start
v-mysql  | 2024-01-28T04:06:45.677312Z 0 [Note] InnoDB: 5.7.41 started; log sequence number 12184554
v-mysql  | 2024-01-28T04:06:45.677578Z 0 [Note] Plugin 'FEDERATED' is disabled.
v-mysql  | 2024-01-28T04:06:45.682869Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
v-mysql  | 2024-01-28T04:06:45.682882Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
v-mysql  | 2024-01-28T04:06:45.682886Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
v-mysql  | 2024-01-28T04:06:45.682888Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
v-mysql  | 2024-01-28T04:06:45.686229Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
v-mysql  | 2024-01-28T04:06:45.700961Z 0 [Warning] CA certificate ca.pem is self signed.
v-mysql  | 2024-01-28T04:06:45.701031Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
v-mysql  | 2024-01-28T04:06:45.701413Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
v-mysql  | 2024-01-28T04:06:45.701481Z 0 [Note] IPv6 is available.
v-mysql  | 2024-01-28T04:06:45.701506Z 0 [Note]   - '::' resolves to '::';
v-mysql  | 2024-01-28T04:06:45.701526Z 0 [Note] Server socket created on IP: '::'.
v-mysql  | 2024-01-28T04:06:45.703079Z 0 [Note] InnoDB: Buffer pool(s) load completed at 240128  4:06:45
v-mysql  | 2024-01-28T04:06:45.750076Z 0 [Note] Event Scheduler: Loaded 0 events
v-mysql  | 2024-01-28T04:06:45.750210Z 0 [Note] mysqld: ready for connections.
v-mysql  | Version: '5.7.41'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
app      | 2024-01-28 04:06:45.863  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$ddc5732] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
app      | 2024-01-28 04:06:46.407  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8090 (http)
app      | 2024-01-28 04:06:46.493  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
app      | 2024-01-28 04:06:46.494  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.28
app      | 2024-01-28 04:06:46.511  INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
app      | 2024-01-28 04:06:46.758  INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
app      | 2024-01-28 04:06:46.759  INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3563 ms
app      | 2024-01-28 04:06:47.011  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
app      | 2024-01-28 04:06:47.014  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
app      | 2024-01-28 04:06:47.025  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
app      | 2024-01-28 04:06:47.025  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
app      | 2024-01-28 04:06:47.025  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
app      | 2024-01-28 04:06:47.411  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
app      | Sun Jan 28 04:06:47 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:48.144546Z 2 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | 2024-01-28 04:06:48.229  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
app      | Sun Jan 28 04:06:48 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
app      | 2024-01-28 04:06:48.390  INFO 1 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
v-mysql  | 2024-01-28T04:06:48.429374Z 3 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | 2024-01-28 04:06:48.450  INFO 1 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
app      |      name: default
app      |      ...]
app      | Sun Jan 28 04:06:48 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:48.516220Z 4 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | Sun Jan 28 04:06:48 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:48.579164Z 5 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | Sun Jan 28 04:06:48 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:48.630329Z 6 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | Sun Jan 28 04:06:48 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
app      | 2024-01-28 04:06:48.686  INFO 1 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.14.Final}
app      | 2024-01-28 04:06:48.687  INFO 1 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
v-mysql  | 2024-01-28T04:06:48.696303Z 7 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | Sun Jan 28 04:06:48 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:48.760458Z 8 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | 2024-01-28 04:06:48.797  INFO 1 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
app      | Sun Jan 28 04:06:48 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:48.845433Z 9 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | Sun Jan 28 04:06:49 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:49.049553Z 10 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | Sun Jan 28 04:06:49 UTC 2024 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
v-mysql  | 2024-01-28T04:06:49.106481Z 11 [Warning] Accepted a connection with deprecated protocol 'TLSv1.1' for account `root`@`%` from host `172.18.0.4`. Client supplied username `root`
app      | 2024-01-28 04:06:49.236  INFO 1 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
app      | Hibernate: create table hibernate_sequence (next_val bigint) engine=InnoDB
app      | Hibernate: insert into hibernate_sequence values ( 1 )
app      | Hibernate: create table visitor (id bigint not null, ip varchar(255) not null, times bigint not null, primary key (id)) engine=InnoDB
app      | 2024-01-28 04:06:50.312  INFO 1 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
app      | 2024-01-28 04:06:52.119  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@301dca64: startup date [Sun Jan 28 04:06:43 UTC 2024]; root of context hierarchy
app      | 2024-01-28 04:06:52.213  WARN 1 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
app      | 2024-01-28 04:06:52.283  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.neo.controller.VisitorController.index(javax.servlet.http.HttpServletRequest)
app      | 2024-01-28 04:06:52.294  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
app      | 2024-01-28 04:06:52.294  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
app      | 2024-01-28 04:06:52.358  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
app      | 2024-01-28 04:06:52.364  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
app      | 2024-01-28 04:06:52.431  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
app      | 2024-01-28 04:06:52.826  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
app      | 2024-01-28 04:06:52.827  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
app      | 2024-01-28 04:06:52.849  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
app      | 2024-01-28 04:06:53.015  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8090 (http) with context path ''
app      | 2024-01-28 04:06:53.030  INFO 1 --- [           main] com.neo.ComposeApplication               : Started ComposeApplication in 13.495 seconds (JVM running for 23.292)
app      | 2024-01-28 04:07:05.300  INFO 1 --- [nio-8090-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
app      | 2024-01-28 04:07:05.301  INFO 1 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
app      | 2024-01-28 04:07:05.329  INFO 1 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 28 ms
app      | 2024-01-28 04:07:05.435  INFO 1 --- [nio-8090-exec-1] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
app      | Hibernate: select visitor0_.id as id1_0_, visitor0_.ip as ip2_0_, visitor0_.times as times3_0_ from visitor visitor0_ where visitor0_.ip=?
app      | Hibernate: select next_val as id_val from hibernate_sequence for update
app      | Hibernate: update hibernate_sequence set next_val= ? where next_val=?
app      | Hibernate: insert into visitor (ip, times, id) values (?, ?, ?)

看到信息Tomcat initialized with port(s): 8090 (http)表示服务启动成功。

也可以使用docker-compose up -d后台启动:

[root@zsx dockercompose-springboot-mysql-nginx]# docker-compose up -d
[+] Running 3/3
 ⠿ Container v-nginx  Started                                                                                                  0.8s
 ⠿ Container v-mysql  Started                                                                                                  0.7s
 ⠿ Container app      Started                                                                                                  1.6s

访问服务器地址:http://192.168.136.195/,返回:I have been seen ip 172.19.0.2 1 times.

表示整体服务启动成功。

使用docker-compose ps查看项目中目前的所有容器:

[root@zsx dockercompose-springboot-mysql-nginx]# docker ps
CONTAINER ID   IMAGE                                      COMMAND                  CREATED         STATUS                             PORTS                                                                      NAMES
5a1fd4d2cc5a   dockercompose-springboot-mysql-nginx-app   "/usr/local/bin/mvn-…"   3 minutes ago   Up 24 seconds                      8090/tcp                                                                   app
576607ed0dda   mysql/mysql-server:5.7                     "/entrypoint.sh mysq…"   3 minutes ago   Up 25 seconds (health: starting)   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                       v-mysql
11ae3ff42704   nginx:1.13                                 "nginx -g 'daemon of…"   3 minutes ago   Up 25 seconds                      0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   v-nginx

可以看到项目中服务的状态、命令、端口等信息。

关闭服务docker-compose down

[root@zsx dockercompose-springboot-mysql-nginx]# docker-compose down
[+] Running 4/4
 ⠿ Container app                                         Removed                                                                                                                                                 0.3s
 ⠿ Container v-mysql                                     Removed                                                                                                                                                 3.9s
 ⠿ Container v-nginx                                     Removed                                                                                                                                                 0.2s
 ⠿ Network dockercompose-springboot-mysql-nginx_default  Removed            

2.5 docker-compose 顺序

在使用 docker-compose 启动的时候经常会出现项目报 Mysql 连接异常,跟踪了一天终于发现了问题。 docker-

compose 虽然可以通过depends_on 来定义服务启动的顺序,但是无法确定服务是否启动完成,因此会出现这

样一个现象,Mysql 服务启动比较慢,当 Spring Boot 项目已经启动起来,但是 Mysql 还没有初始化好,这样当

项目连接 Mysql 数据库的时候,就会出现连接数据库的异常。

针对这样的问题,有两种解决方案:

1、足够的容错和重试机制,比如连接数据库,在初次连接不上的时候,服务消费者可以不断重试,直到连接上服

务。也就是在服务中定义: restart: always

2、同步等待,使用wait-for-it.sh或者其他shell脚本将当前服务启动阻塞,直到被依赖的服务加载完毕。这

种方案后期可以尝试使用。

3、总结

没有对比就没有伤害,在没有使用 Docker 之前,我们需要搭建这样一个环境的话,需要安装 Nginx、Mysql ,再

进行一系列的配置调试,还要担心各种环境问题;使用 Docker 之后简单两个命令就完成服务的上线、下线。

# 初始化并启动容器
$ docker-compose up
# 停止容器并且删除容器
$ docker-compose down
# 停止容器
$ docker-compose stop
# 启动容器
$ docker-compose start

其实容器技术对部署运维的优化还有很多,这只是刚刚开始,后面使用了 Swarm 才会真正感受到它的便利和强

大。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1429484.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Docker部署xxl-job调度器并结合SpringBoot测试

文章目录 一、Docker部署1. 创建数据库2. 启动容器3. 访问4. 新建执行器 二、SpringBoot整合1. 模块注册到执行器2. 创建配置类3. 启动测试 三、任务发布-普通任务1. 编写任务代码2. 创建任务3. 启动任务 四、任务发布-分片任务1. 编写任务代码2. 启动多个实例3. 创建任务4. 启…

机器学习复习(2)——线性回归SGD优化算法

目录 线性回归代码 线性回归理论 SGD算法 手撕线性回归算法 模型初始化 定义模型主体部分 定义线性回归模型训练过程 数据demo准备 模型训练与权重参数 定义线性回归预测函数 定义R2系数计算 可视化展示 预测结果 训练过程 sklearn进行机器学习 线性回归代码…

浙政钉(专有钉钉)

专有钉钉是浙政钉的测试版本&#xff0c;可在正式发布之前进行业务开发。 专有钉钉 原名政务钉钉 是高安全、强管控、灵活开放的面向大型组织专有独享的协同办公平台。支持专有云、混合云等多种方式灵活部署&#xff0c;以满足客户特定场景所需为目标&#xff0c;最大化以“平…

elk之简介

写在前面 本文看下es的简介。 1&#xff1a;简介 背后公司&#xff0c;elastic&#xff0c;08年纽交所上市&#xff0c;与腾讯&#xff0c;阿里等云厂商有合作&#xff0c;推出云产品&#xff0c;类似功能的产品由solr&#xff0c;splunk&#xff0c;但使用量es当前遥遥领先…

Vue-52、Vue技术插槽使用

1、默认插槽 App.vue <template><div class"container"><category title"美食"><img src"https://tse2-mm.cn.bing.net/th/id/OIP-C.F0xLT-eKcCSOI5tdjBv9FAHaE8?w303&h202&c7&r0&o5&pid1.7">&l…

网络安全之SSL证书加密

简介 SSL证书是一种数字证书&#xff0c;遵守SSL协议&#xff0c;由受信任的数字证书颁发机构&#xff08;CA&#xff09;验证服务器身份后颁发。它具有服务器身份验证和数据传输加密的功能&#xff0c;能够确保数据在传输过程中的安全性和完整性。 具体来说&#xff0c;SSL证…

番外篇 vue与django 交互流程

学习了一段时间的django和vue&#xff0c;对于前后端开发有了一个初步的了解&#xff0c;这里记录一下编写的流程和思路&#xff0c;主要是为了后面如果遗忘从哪里开始操作做一个起步引导作用 一、Django后端 参考下前面django的文档https://moziang.blog.csdn.net/article/det…

Web实战丨基于django+hitcount的网页计数器

文章目录 写在前面Django简介主要程序运行结果系列文章写在后面 写在前面 本期内容 基于djangohitcount的网页计数器 所需环境 pythonpycharm或vscodedjango 下载地址 https://download.csdn.net/download/m0_68111267/88795611 Django简介 Django 是一个开源的、基于 …

六、Nacos源码系列:Nacos健康检查

目录 一、简介 二、健康检查流程 2.1、健康检查 2.2、客户端释放连接事件 2.3、客户端断开连接事件 2.4、小结 2.5、总结图 三、服务剔除 一、简介 Nacos作为注册中心不止提供了服务注册和服务发现的功能&#xff0c;还提供了服务可用性检测的功能&#xff0c;在Nacos…

【QT+QGIS跨平台编译】之二十二:【FontConfig+Qt跨平台编译】(一套代码、一套框架,跨平台编译)

文章目录 一、FontConfig介绍二、文件下载三、文件分析四、pro文件五、编译实践 一、FontConfig介绍 FontConfig 是一个用于配置和定制字体的库&#xff0c;广泛应用于基于X Window系统的操作系统中&#xff0c;尤其是在Linux和Unix-like系统中。它为应用程序提供了一种统一的…

在VM虚拟机搭建NFS服务器

NFS共享要求如下&#xff1a; &#xff08;1&#xff09;共享“/mnt/自已姓名的完整汉语拼音”目录&#xff0c;允许XXX网段的计算机访问该共享目录&#xff0c;可进行读写操作。&#xff08;说明&#xff1a;XXX网段&#xff0c;请根据你的规划&#xff0c;再具体指定&#xf…

2024美赛数学建模B题思路分析 - 搜索潜水器

# 1 赛题 问题B&#xff1a;搜索潜水器 总部位于希腊的小型海上巡航潜艇&#xff08;MCMS&#xff09;公司&#xff0c;制造能够将人类运送到海洋最深处的潜水器。潜水器被移动到该位置&#xff0c;并不受主船的束缚。MCMS现在希望用他们的潜水器带游客在爱奥尼亚海底探险&…

STM32F1 - 存储器映射

Memory mapping 1> 外设内存地址映射2> GPIO寄存器映射3> 存储器访问 1> 外设内存地址映射 1> STM32F103ZET6的地址线位宽为32位&#xff0c;所以寻址空间为4GB &#xff08;2 ^ 32 4GB&#xff09;&#xff1b; 2> STM32将&#xff0c;Flash&#xff0c;SR…

数仓建模维度建模理论知识

0. 思维导图 第 1 章 数据仓库概述 1.1 数据仓库概述 数据仓库是一个为数据分析而设计的企业级数据管理系统。数据仓库可集中、整合多个信息源的大量数据&#xff0c;借助数据仓库的分析能力&#xff0c;企业可从数据中获得宝贵的信息进而改进决策。同时&#xff0c;随着时间的…

【经典项目】Java小游戏 —— 弹力球

一、功能需求 设计一个Java弹球小游戏的思路如下&#xff1a; 创建游戏窗口&#xff1a;使用Java图形库&#xff08;如Swing或JavaFX&#xff09;创建一个窗口&#xff0c;作为游戏的可视化界面。 绘制游戏界面&#xff1a;在游戏窗口中绘制游戏所需的各个元素&#xff0c;包括…

同城外卖跑腿app开发:重新定义城市生活

随着科技的发展和人们生活节奏的加快&#xff0c;同城外卖跑腿app应运而生&#xff0c;成为现代城市生活中的重要组成部分。本文将探讨同城外卖跑腿app开发的意义、市场需求、功能特点以及未来的发展趋势。 一、同城外卖跑腿app开发的意义 同城外卖跑腿app作为一种便捷的生活…

Visual Studio 2022 查看类关系图

这里写自定义目录标题 右键要查看的项目 -“查看”-“查看类图”效果展示&#xff1a; 原文地址 www.cnblogs.com 步骤1&#xff1a;勾选扩展开发 步骤2: 勾选类设计器 右键要查看的项目 -“查看”-“查看类图” 效果展示&#xff1a;

使用 WebSocket 发送二进制数据:最佳实践

WebSocket 技术提供了一种在客户端和服务器间建立持久连接的方法&#xff0c;使得双方可以在打开连接后随时发送数据&#xff0c;而不必担心建立复杂的持久连接机制。同时&#xff0c;使用二进制数据&#xff0c;如ArrayBuffer&#xff0c;可以更有效率地传送图像、声音等信息。…

MySQL知识点总结(四)——MVCC

MySQL知识点总结&#xff08;四&#xff09;——MVCC 三个隐式字段row_idtrx_idroll_pointer undo logread viewMVCC与隔离级别的关系快照读和当前读 MVCC全称是Multi Version Concurrency Control&#xff0c;也就是多版本并发控制。它的作用是提高事务的并发度&#xff0c;通…

西瓜书学习笔记——主成分分析(公式推导+举例应用)

文章目录 算法介绍实验分析 算法介绍 主成分分析&#xff08;Principal Component Analysis&#xff0c;PCA&#xff09;是一种常用的降维技术&#xff0c;用于在高维数据中发现最重要的特征或主成分。PCA的目标是通过线性变换将原始数据转换成一组新的特征&#xff0c;这些新…