From 3674ef72faf22699e055dd6e518bd221d42536e5 Mon Sep 17 00:00:00 2001 From: colaftc Date: Wed, 24 Dec 2025 23:12:56 +0800 Subject: [PATCH] giveup2 --- celerybeat-schedule-shm | Bin 32768 -> 32768 bytes celerybeat-schedule-wal | Bin 2966432 -> 2982912 bytes docker-compose.dev.yml | 18 +++--------------- docker-compose.prod.yml | 18 +++--------------- docker-compose.yml | 19 ++++--------------- pgbouncer/pgbouncer.ini | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 45 deletions(-) create mode 100644 pgbouncer/pgbouncer.ini diff --git a/celerybeat-schedule-shm b/celerybeat-schedule-shm index 36dd64a9180d1d342ae672e34a5762ac046b5f4c..c6cce59d6b6a7a73857bef31549367b1b86c5a93 100644 GIT binary patch delta 175 zcmZo@U}|V!s+V}A%K!pdj0_AwByfd^fq@yw_p&o|Vcd1TYx2=(Ep@S%&hM3%9X7ZW ztVODNu;D-gWbS_?02SX@@5w!JfxzYy+$vU^|F~XYV!6n4nQ8JxZmrF~Jb=7QOjnpT JU*tA20RTF)ItBm$ delta 166 zcmZo@U}|V!s+V}A%K!oyj0_AwByfR=fq@ywKV^36py~QL@5x7_wbaF4I)CMCuRpi6 zMuk-MV8ej~$lU)(04lz*-jjRt4Q>^y$sf1{Hve(Gz%=fi*}377TpET zlM5aSa7;N+v~d2iOPjV=>`=YV!)UjCf-?UVMoDo7ATXGcA=Wk}Xo~MP<_u|#9u_Tq zLxbrDjhNi0i|pqL6#%JWYJ;h>_H(!x+Ie-I-^B>AMaW)&S&1n= QzAUw@b keFH-yV-r&|vAKn%m9>qn#LnKq(aG7x)lKRy`#g&0A8#liZvX%Q diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index b6f5c83..a844733 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -17,29 +17,17 @@ services: pgbouncer: image: pgbouncer/pgbouncer:latest container_name: pgbouncer + # 配置文件已包含所有配置,环境变量仅作为备用 environment: - POSTGRES_HOST: postgres - POSTGRES_PORT: "5432" - POSTGRES_DB: flower - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres DATABASES_HOST: postgres DATABASES_PORT: "5432" DATABASES_USER: postgres DATABASES_PASSWORD: postgres DATABASES_DBNAME: flower - PGBOUNCER_POOL_MODE: transaction - PGBOUNCER_MAX_CLIENT_CONN: "100" - PGBOUNCER_DEFAULT_POOL_SIZE: "25" - PGBOUNCER_MIN_POOL_SIZE: "5" - PGBOUNCER_RESERVE_POOL_SIZE: "5" - PGBOUNCER_RESERVE_POOL_TIMEOUT: "3" - PGBOUNCER_SERVER_IDLE_TIMEOUT: "600" - PGBOUNCER_LOG_CONNECTIONS: "1" - PGBOUNCER_LOG_DISCONNECTIONS: "1" - PGBOUNCER_LOG_POOLER_ERRORS: "1" ports: - "6432:6432" + volumes: + - ./pgbouncer/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini depends_on: - postgres restart: unless-stopped diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 0085309..637d680 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -18,29 +18,17 @@ services: pgbouncer: image: pgbouncer/pgbouncer:latest container_name: pgbouncer + # 配置文件已包含所有配置,环境变量仅作为备用 environment: - POSTGRES_HOST: postgres - POSTGRES_PORT: "${POSTGRES_PORT:-5432}" - POSTGRES_DB: ${POSTGRES_DB:-flower} - POSTGRES_USER: ${POSTGRES_USER:-postgres} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} DATABASES_HOST: postgres DATABASES_PORT: "${POSTGRES_PORT:-5432}" DATABASES_USER: ${POSTGRES_USER:-postgres} DATABASES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} DATABASES_DBNAME: ${POSTGRES_DB:-flower} - PGBOUNCER_POOL_MODE: transaction - PGBOUNCER_MAX_CLIENT_CONN: "100" - PGBOUNCER_DEFAULT_POOL_SIZE: "25" - PGBOUNCER_MIN_POOL_SIZE: "5" - PGBOUNCER_RESERVE_POOL_SIZE: "5" - PGBOUNCER_RESERVE_POOL_TIMEOUT: "3" - PGBOUNCER_SERVER_IDLE_TIMEOUT: "600" - PGBOUNCER_LOG_CONNECTIONS: "1" - PGBOUNCER_LOG_DISCONNECTIONS: "1" - PGBOUNCER_LOG_POOLER_ERRORS: "1" ports: - "${PGBOUNCER_PORT:-6432}:6432" + volumes: + - ./pgbouncer/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini depends_on: - postgres restart: unless-stopped diff --git a/docker-compose.yml b/docker-compose.yml index f4ad351..9c6b86e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,29 +17,18 @@ services: pgbouncer: image: pgbouncer/pgbouncer:latest container_name: pgbouncer + # 配置文件已包含所有配置,环境变量仅作为备用 environment: - POSTGRES_HOST: postgres - POSTGRES_PORT: "5432" - POSTGRES_DB: flower - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres + # 如果镜像支持环境变量配置,这些可以作为备用 DATABASES_HOST: postgres DATABASES_PORT: "5432" DATABASES_USER: postgres DATABASES_PASSWORD: postgres DATABASES_DBNAME: flower - PGBOUNCER_POOL_MODE: transaction - PGBOUNCER_MAX_CLIENT_CONN: "100" - PGBOUNCER_DEFAULT_POOL_SIZE: "25" - PGBOUNCER_MIN_POOL_SIZE: "5" - PGBOUNCER_RESERVE_POOL_SIZE: "5" - PGBOUNCER_RESERVE_POOL_TIMEOUT: "3" - PGBOUNCER_SERVER_IDLE_TIMEOUT: "600" - PGBOUNCER_LOG_CONNECTIONS: "1" - PGBOUNCER_LOG_DISCONNECTIONS: "1" - PGBOUNCER_LOG_POOLER_ERRORS: "1" ports: - "6432:6432" + volumes: + - ./pgbouncer/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini depends_on: - postgres restart: unless-stopped diff --git a/pgbouncer/pgbouncer.ini b/pgbouncer/pgbouncer.ini new file mode 100644 index 0000000..f61df01 --- /dev/null +++ b/pgbouncer/pgbouncer.ini @@ -0,0 +1,38 @@ +[databases] +flower = host=postgres port=5432 dbname=flower user=postgres password=postgres + +[pgbouncer] +; 监听地址和端口 +listen_addr = 0.0.0.0 +listen_port = 6432 + +; 认证方式:trust 表示信任所有连接(适用于容器内部网络) +; 这样客户端连接时不需要密码,但 PgBouncer 到 PostgreSQL 的连接仍需要密码 +auth_type = trust + +; 连接池配置 +; pool_mode: session, transaction, statement +; transaction 模式最适合 Django,每个事务结束后释放连接 +pool_mode = transaction +max_client_conn = 100 +default_pool_size = 25 +min_pool_size = 5 +reserve_pool_size = 5 +reserve_pool_timeout = 3 + +; 连接超时设置 +server_connect_timeout = 15 +server_idle_timeout = 600 +query_timeout = 0 +query_wait_timeout = 120 + +; 日志配置 +log_connections = 1 +log_disconnections = 1 +log_pooler_errors = 1 + +; 其他设置 +; 忽略 PostgreSQL 16 的额外启动参数 +ignore_startup_parameters = extra_float_digits +application_name_add_host = 1 +