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.mzph.cn/news/664792.shtml

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

相关文章

linux交叉编译方法——虚拟机编译,在树莓派平台上运行

一、 交叉编译是什么 交叉编译 是在一个平台上生成另一个平台上的可执行代码。 我们再windows上面编写C51代码&#xff0c;并编译成可执行代码&#xff0c;如xx.hex, 是在c51上面运行&#xff0c;不是在windows上面运行 我们在ubuntu上面编写树…

Kubernetes k8s

Kubernetes k8s 一个开源的容器编排引擎&#xff0c;用来对容器化应用进行自动化部署、 扩缩和管理。 从架构设计层面&#xff0c;k8s能很好的解决可用性&#xff0c;伸缩性&#xff1b;从部署运维层面&#xff0c;服务部署&#xff0c;服务监控&#xff0c;应用扩容和故障处…

springboot并mybatis入门启动

pom.xml,需要留意jdk的版本&#xff08;11&#xff09;和springboot版本要匹配&#xff08;2.7.4&#xff09;&#xff0c;然后还要注意mybatis启动l类的版本&#xff08;2.2.2&#xff09; <?xml version"1.0" encoding"UTF-8"?> <project xm…

MAX31865读取PT100/PT1000电阻值

1、芯片介绍 MAX31865是简单易用的热敏电阻至数字输出转换器,优化用于铂电阻温度检测器(RTD)。外部电阻设置RTD灵敏度,高精度Δ- Σ ADC将RTD电阻与基准电阻之比转换为数字输出。MAX31865输入具有高达45V的过压保护,提供可配置的RTD及电缆开路、短路条件检测。 2、芯片特点…

解决Docker打包Eureka注册中心,其他服务无法注册问题

​前言 本文主要是介绍利用docker打包Eureka注册中心&#xff0c;并且发布镜像到服务器&#xff0c;遇到的一个比较坑的问题。主要是服务镜像部署完毕之后&#xff0c;docker容器都能启动&#xff0c;并且也能访问&#xff0c;但是其他服务就是无法注册到注册中心。排除问题&a…

查看阿里云maven仓中某个库有哪些版本

起因 最近项目上有做视频业务&#xff0c;方案是使用阿里云的短视频服务&#xff0c;其中也有使用到阿里云的上传SDK&#xff0c;过程中有遇一个上传SDK的内部崩溃&#xff0c;崩溃栈如下&#xff1a; Back traces starts. java.lang.NullPointerException: Attempt to invok…

只用一台服务器部署上线(宝塔面板) 前后端+数据库

所需材料 工具&#xff1a;安装宝塔面板服务器至少一台、域名一个 前端&#xff1a;生成dist文件&#xff08;前端运行build命令&#xff09; 后端&#xff1a;生成jar包&#xff08;maven运行package命令&#xff09; 准备&#xff1a; 打开宝塔面板&#xff0c;点击进入软…

2、安全开发-Python-Socket编程端口探针域名爆破反弹Shell编码免杀

用途&#xff1a;个人学习笔记&#xff0c;欢迎指正&#xff01; 目录 主要内容&#xff1a; 一、端口扫描(未开防火墙情况) 1、Python关键代码: 2、完整代码&#xff1a;多线程配合Queue进行全端口扫描 二、子域名扫描 三、客户端&#xff0c;服务端Socket编程通信cmd命…

Nginx简单阐述及安装配置

目录 一.什么是Nginx 二.Nginx优缺点 1.优点 2.缺点 三.正向代理与反向代理 1.正向代理 2.反向代理 四.安装配置 1.添加Nginx官方yum源 2.使用yum安装Nginx 3.配置防火墙 4.启动后效果 一.什么是Nginx Nginx&#xff08;“engine x”&#xff09;是一个高性能的HTTP…

Linux Zip解压缩命令

Zip 用法 $ zip [-选项] [-b 路径] [-t 日期] [-n 后缀名] [压缩文件列表] [-xi 列表] 默认操作是添加或替换压缩文件列表中的压缩文件条目&#xff0c;压缩文件列表可以包括特殊名称 -&#xff0c;压缩标准输入数据 Zip 是一个创建和管理 zip 文件的压缩工具 Unzip 是一个用…

算法day10

算法day10 20 有效的括号1047 删除字符串中的所有相邻重复性150 逆波兰表达式求值 20 有效的括号 拿到这个题的想法&#xff0c;首先我在想我能不能用数组的操作来扫描做。后来想想&#xff0c;如果这样做那特判也太多了&#xff0c;不好做。然后第二个想法就是用栈来做&…

机器学习-基础分类算法-KNN详解

KNN-k近邻算法 k-Nearest Neighbors 思想极度简单应用数学只是少效果好可以解释机器学习算法使用过程中的很多细节问题更完整的刻画机器学习应用的流程 创建简单测试用例 import numpy as np import matplotlib.pyplot as plt raw_data_X [[3.393533211, 2.331273381],[3.1…

ubuntu20.04安装sumo

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 有问题&#xff0c;请大家指出&#xff0c;争取使方法更完善。这只是ubuntu安装sumo的一种方法。一、注意事项1、首先明确你的ubuntu的用户名是什么 二、sumo安装1.…

基于springboot篮球论坛系统源码和论文

首先,论文一开始便是清楚的论述了系统的研究内容。其次,剖析系统需求分析,弄明白“做什么”,分析包括业务分析和业务流程的分析以及用例分析,更进一步明确系统的需求。然后在明白了系统的需求基础上需要进一步地设计系统,主要包罗软件架构模式、整体功能模块、数据库设计。本项…

国家博物馆逆向抢票协议

逆向工程的具体步骤可以因项目和目标系统的不同而有所变化。然而&#xff0c;以下是一般逆向工程的一般步骤&#xff1a; 1. 分析目标系统&#xff1a;对待逆向的系统进行调研和了解&#xff0c;包括其架构、功能、使用的技术等方面的信息。 2. 反汇编或反编译&#xff1a;使…

保姆级CDN使用教程,解决可能出现的各种问题

如果你还没有注册雨云&#xff08;rainyun&#xff09;&#xff0c;可以通过该链接进行注册雨云 - 新一代云服务提供商 通过该链接注册是可以白嫖到优惠券的&#xff0c;可以白嫖CDN。 比直接注册划算。 雨云的cdn在国内表现是非常不错的&#xff0c;而且不需要域名进行备案 在…

如何创建长期有效的文件二维码?支持多文件批量生成单独二维码

现在很多人为了避免文件通过文件有时效的问题&#xff0c;会将文件生成二维码之后来使用&#xff0c;将文件存入二维码中通过扫码调取云端的储存的数据来实现文件的预览或者下载。那么对于想要学习文件二维码制作的小伙伴&#xff0c;可以学习下面的方法来制作&#xff0c;利用…

flask基于django大数据的证券股票分析系统python可视化大屏

证券分析系统采用B/S架构&#xff0c;数据库是MySQL。网站的搭建与开发采用了先进的Python进行编写&#xff0c;使用了Django框架。该系统从两个对象&#xff1a;由管理员和用户来对系统进行设计构建。主要功能包括&#xff1a;个人信息修改&#xff0c;对股票信息、股票买入、…

XML传参方式

export function groupLoginAPI(xmlData) {return http.post(/tis/group/1.0/login, xmlData, {headers: {Content-Type: application/xml,X-Requested-With: AAServer/4.0,}}) }import {groupLoginAPI} from "../api/user"; function (e) { //xml格式传参let groupX…

网络安全全栈培训笔记(60-服务攻防-中间件安全CVE复现WeblogicJenkinsGlassFish)

第60天 服务攻防-中间件安全&CVE复现&Weblogic&Jenkins&GlassFish 知识点: 中间件及框架列表: lIS,Apache,Nginx,Tomcat,Docker,Weblogic,JBoos,WebSphere,Jenkins, GlassFish,Jira,Struts2,Laravel,Solr,Shiro,Thinkphp,Sprng,Flask,jQuery 1、中间件-Web…