mktkhr / stamp-iot

MIT License
3 stars 0 forks source link

本番環境のdocker環境を整備する #67

Closed mktkhr closed 1 year ago

mktkhr commented 1 year ago

目的

期待結果

mktkhr commented 1 year ago

runner + docker でサーバーのメモリが圧迫されているため,+ 32GB くらいは増設したい

mktkhr commented 1 year ago

docker-compose 内の java コンテナと redis コンテナの通信に失敗している(localではログインもできるので,通信に成功している)

mktkhr commented 1 year ago

runner + docker でサーバーのメモリが圧迫されているため,+ 32GB くらいは増設したい

  • とりあえず,16GB + 16GB で様子を見る

メモリ増設後,動作が改善された

mktkhr commented 1 year ago

ログ

展開
``` ✔ Network docker_default Created 0.7s ✔ Container redis Created 0.1s ✔ Container postgres Created 0.1s ✔ Container java Created 0.4s ✔ Container redisinsight Created 0.1s ✔ Container nginx Created 0.1s Attaching to java, nginx, postgres, redis, redisinsight redis | 1:C 09 May 2023 16:10:54.876 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo redis | 1:C 09 May 2023 16:10:54.876 # Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started redis | 1:C 09 May 2023 16:10:54.876 # Configuration loaded redis | 1:M 09 May 2023 16:10:54.878 * monotonic clock: POSIX clock_gettime redis | _._ redis | _.-``__ ''-._ redis | _.-`` `. `_. ''-._ Redis 7.0.11 (00000000/0) 64 bit redis | .-`` .-```. ```\/ _.,_ ''-._ redis | ( ' , .-` | `, ) Running in standalone mode redis | |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 redis | | `-._ `._ / _.-' | PID: 1 redis | `-._ `-._ `-./ _.-' _.-' redis | |`-._`-._ `-.__.-' _.-'_.-'| redis | | `-._`-._ _.-'_.-' | https://redis.io redis | `-._ `-._`-.__.-'_.-' _.-' redis | |`-._`-._ `-.__.-' _.-'_.-'| redis | | `-._`-._ _.-'_.-' | redis | `-._ `-._`-.__.-'_.-' _.-' redis | `-._ `-.__.-' _.-' redis | `-._ _.-' redis | `-.__.-' redis | redis | 1:M 09 May 2023 16:10:54.880 # Server initialized redis | 1:M 09 May 2023 16:10:54.880 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. redis | 1:M 09 May 2023 16:10:54.882 * Loading RDB produced by version 7.0.11 redis | 1:M 09 May 2023 16:10:54.882 * RDB age 34 seconds redis | 1:M 09 May 2023 16:10:54.882 * RDB memory usage when created 0.86 Mb redis | 1:M 09 May 2023 16:10:54.882 * Done loading RDB, keys loaded: 0, keys expired: 0. redis | 1:M 09 May 2023 16:10:54.882 * DB loaded from disk: 0.001 seconds redis | 1:M 09 May 2023 16:10:54.882 * Ready to accept connections postgres | postgres | PostgreSQL Database directory appears to contain a database; Skipping initialization postgres | postgres | 2023-05-09 16:10:55.166 UTC [1] LOG: starting PostgreSQL 14.7 (Debian 14.7-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit postgres | 2023-05-09 16:10:55.168 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgres | 2023-05-09 16:10:55.169 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgres | 2023-05-09 16:10:55.185 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres | 2023-05-09 16:10:55.206 UTC [27] LOG: database system was shut down at 2023-05-09 16:10:20 UTC postgres | 2023-05-09 16:10:55.224 UTC [1] LOG: database system is ready to accept connections nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh nginx | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf nginx | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh nginx | /docker-entrypoint.sh: Configuration complete; ready for start up nginx | 2023/05/09 16:10:59 [notice] 1#1: using the "epoll" event method nginx | 2023/05/09 16:10:59 [notice] 1#1: nginx/1.23.4 nginx | 2023/05/09 16:10:59 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) nginx | 2023/05/09 16:10:59 [notice] 1#1: OS: Linux 5.10.16.3-microsoft-standard-WSL2 nginx | 2023/05/09 16:10:59 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576 nginx | 2023/05/09 16:10:59 [notice] 1#1: start worker processes nginx | 2023/05/09 16:10:59 [notice] 1#1: start worker process 29 nginx | 2023/05/09 16:10:59 [notice] 1#1: start worker process 30 nginx | 2023/05/09 16:10:59 [notice] 1#1: start worker process 31 nginx | 2023/05/09 16:10:59 [notice] 1#1: start worker process 32 java | java | . ____ _ __ _ _ java | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ java | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ java | \\/ ___)| |_)| | | | | || (_| | ) ) ) ) java | ' |____| .__|_| |_|_| |_\__, | / / / / java | =========|_|==============|___/=/_/_/_/ java | :: Spring Boot :: (v3.0.0) java | java | 2023-05-09T16:10:59.849Z INFO 1 --- [ main] c.example.stamp_app.BackendApplication : Starting BackendApplication using Java 17.0.7 with PID 1 (/usr/src/server.jar started by root in /usr/src) java | 2023-05-09T16:10:59.854Z INFO 1 --- [ main] c.example.stamp_app.BackendApplication : The following 1 profile is active: "prod" java | 2023-05-09T16:11:01.077Z INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode java | 2023-05-09T16:11:01.080Z INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. java | 2023-05-09T16:11:01.325Z INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 234 ms. Found 6 JPA repository interfaces. java | 2023-05-09T16:11:01.352Z INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode java | 2023-05-09T16:11:01.354Z INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. java | 2023-05-09T16:11:01.371Z INFO 1 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stamp_app.repository.SensorRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository java | 2023-05-09T16:11:01.372Z INFO 1 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stamp_app.repository.EnvironmentalDataRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository java | 2023-05-09T16:11:01.372Z INFO 1 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stamp_app.repository.Sdi12DataRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository java | 2023-05-09T16:11:01.372Z INFO 1 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stamp_app.repository.MeasuredDataMasterRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository java | 2023-05-09T16:11:01.372Z INFO 1 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stamp_app.repository.AccountRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository java | 2023-05-09T16:11:01.373Z INFO 1 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.stamp_app.repository.MicroControllerRepository; If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository java | 2023-05-09T16:11:01.373Z INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 8 ms. Found 0 Redis repository interfaces. java | 2023-05-09T16:11:02.095Z INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http) java | 2023-05-09T16:11:02.109Z INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] java | 2023-05-09T16:11:02.110Z INFO 1 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.1] java | 2023-05-09T16:11:02.209Z INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext java | 2023-05-09T16:11:02.212Z INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2269 ms java | 2023-05-09T16:11:02.383Z INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] java | 2023-05-09T16:11:02.430Z INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.5.Final java | 2023-05-09T16:11:02.620Z WARN 1 --- [ main] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead java | 2023-05-09T16:11:02.742Z INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... java | 2023-05-09T16:11:02.944Z INFO 1 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@60afd40d java | 2023-05-09T16:11:02.947Z INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. java | 2023-05-09T16:11:02.977Z INFO 1 --- [ main] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect java | 2023-05-09T16:11:04.124Z INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] java | 2023-05-09T16:11:04.131Z INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' java | 2023-05-09T16:11:04.923Z WARN 1 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : 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 java | 2023-05-09T16:11:05.278Z INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path '' java | 2023-05-09T16:11:05.287Z INFO 1 --- [ main] c.example.stamp_app.BackendApplication : Started BackendApplication in 6.393 seconds (process running for 8.16) java | 2023-05-09T16:11:19.964Z INFO 1 --- [nio-8082-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' java | 2023-05-09T16:11:19.968Z INFO 1 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' java | 2023-05-09T16:11:19.977Z INFO 1 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 5 ms java | >> Account Controller(login:POST) java | RequestBody:LoginPostParam(email=aaa@example.com) java | Successfully logged in. java | 2023-05-09T16:11:21.547Z ERROR 1 --- [nio-8082-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis] with root cause java | java | java.net.ConnectException: Connection refused java | at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na] java | at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[na:na] java | at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946) ~[na:na] java | at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337) ~[netty-transport-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[netty-transport-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776) ~[netty-transport-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.85.Final.jar!/:4.1.85.Final] java | at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.85.Final.jar!/:4.1.85.Final] java | at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na] java | nginx | 172.27.0.1 - - [09/May/2023:16:11:21 +0000] "POST /api/ems/account/login HTTP/1.1" 500 129 "http://localhost:8080/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36" ```
mktkhr commented 1 year ago

ローカル環境のspringをコンテナ内に入れて調査