DockerCompose+SpringBoot+Nginx+Mysql实践

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=truespring.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 {@Autowiredprivate 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@GeneratedValueprivate 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-nginximage: nginx:1.13restart: alwaysports:- 80:80- 443:443volumes:- ./nginx/conf.d:/etc/nginx/conf.dmysql:container_name: v-mysqlimage: mysql/mysql-server:5.7environment:MYSQL_DATABASE: testMYSQL_ROOT_PASSWORD: rootMYSQL_ROOT_HOST: '%'ports:- "3306:3306"restart: alwaysapp:container_name: apprestart: alwaysbuild: ./appworking_dir: /appvolumes:- ./app:/app- /home/zhangshixing/maven/m2:/root/.m2expose:- "8090"depends_on:- nginx- mysqlcommand: 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.hqwc.cn/news/448424.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

企业中不同大数据迁移的区别是什么?

在大数据时代&#xff0c;企业面临着海量数据的管理、分析和应用挑战。为了克服数据存储、传输和处理中的难题&#xff0c;如数据量巨大、网络环境多变、存储成本高昂以及安全风险上升等&#xff0c;企业必须对数据进行备份、同步、分发或归档。这一过程中&#xff0c;数据的复…

前端换肤的五种思路和优缺点

一、什么是前端换肤 前端换肤是指在前端开发中&#xff0c;通过改变网页的样式来实现不同的主题或皮肤效果。通过换肤&#xff0c;可以改变网页的颜色、字体、背景等样式&#xff0c;以适应不同的用户喜好或实现特定的设计需求。 静态换肤&#xff1a; 是指在网页加载时&…

6、基于机器学习的预测

应用机器学习的任何预测任务与这四个策略。 文章目录 1、简介1.1定义预测任务1.2准备预测数据1.3多步预测策略1.3.1多输出模型1.3.2直接策略1.3.3递归策略1.3.4DirRec 策略2、流感趋势示例2.1多输出模型2.2直接策略1、简介 在第二课和第三课中,我们将预测视为一个简单的回归问…

安卓SurfaceTexture中updateTexImage使用及源码分析

文章目录 引言updateTexImage 简单使用SurfaceTexture 初始化相关源码分析Surface 绘制流程源码分析createBufferQueue 源码分析SurfaceTexture 之 updateTexImage 源码分析结尾 本文首发地址 https://h89.cn/archives/140.html 最新更新地址 https://gitee.com/chenjim/chenji…

Javaweb之SpringBootWeb案例之yml配置文件的详细解析

4.2 yml配置文件 前面我们一直使用springboot项目创建完毕后自带的application.properties进行属性的配置&#xff0c;那其实呢&#xff0c;在springboot项目当中是支持多种配置方式的&#xff0c;除了支持properties配置文件以外&#xff0c;还支持另外一种类型的配置文件&am…

你们看好鸿蒙开发嘛?反正我是看透了

前端也好Android、Java也罢。都逃不过市场的需求&#xff0c;岗位是市场需求决定的。现在的整个IT行情来看&#xff0c;互联网市场并不太好&#xff0c;所以如果要短时间内打破这一条例&#xff1b;那就是新型技术的突破。 鸿蒙的未来好不好&#xff0c;能不能入&#xff1f; …

店群如何防关联?抖音小店被限流怎么办?——站斧浏览器云桌面

无论是抖音小店店铺&#xff0c;还是其他店铺&#xff1b;使用相同法人、相同类目&#xff0c;多开都会被限流&#xff0c;甚至严重到全部店铺迟迟不出单。 下面小编根据不同情况给出解决方案&#xff1a; 1.不同法人、相同类目的情况 使用云服务器&#xff08;站斧云桌面&am…

【Java网络编程04】网络原理进阶(二)

1. 前言 在网络原理进阶&#xff08;一&#xff09;部分我们详细介绍了UDP/TCP两大协议及其相关特性&#xff0c;本章我们会讨论网络层、数据链路层、物理层相关协议。但是需要注意的是&#xff0c;如果有小伙伴们未来是想成为Java后端开发工程师的&#xff0c;那么未来工作中…

3D打印技术在建筑业中的潜力有哪些?HOOPS又是如何应用其中的?

近年来&#xff0c;3D打印技术以其独特的优势逐渐渗透到各行各业&#xff0c;而在建筑业中&#xff0c;其应用正呈现出巨大的潜力。本文将探讨3D打印技术在建筑领域中的各种可能性&#xff0c;同时关注于HOOPS在这一领域中的应用&#xff0c;如何推动和优化3D打印的实施。 一、…

Spring速成(一)

文章目录 Spring速成&#xff08;一&#xff09;1&#xff0c;课程介绍1.1 为什么要学?1.2 学什么?1.3 怎么学? 2&#xff0c;Spring相关概念2.1 初识Spring2.1.1 Spring家族2.1.2 了解Spring发展史 2.2 Spring系统架构2.2.1 系统架构图2.2.2 课程学习路线 2.3 Spring核心概…

ELK集群搭建(基础教程)

ELK集群搭建(基础教程) 目录&#xff1a; 机器准备 集群内各台机器安装Elasticsearch 安装部署Kafka&#xff08;注&#xff1a;每个节点都配置&#xff0c;注意ip不同&#xff09; 安装logstash工具 安装filebeat ELK收集Nginx的json日志 ELK收集Nginx正常日志和错误日…

在windows和Linux中的安装 boost 以及 安装 muduo 和 mysql

一、CMake安装 Ubuntu Linux 下安装和卸载cmake 3.28.2版本-CSDN博客https://blog.csdn.net/weixin_41987016/article/details/135960115?spm1001.2014.3001.5501二、安装boost boost官网&#xff1a;boost官网 我下载的boost版本&#xff1a; windows:boost_1_84_0.zipli…