diff --git a/celerybeat-schedule-shm b/celerybeat-schedule-shm index 36dd64a..c6cce59 100644 Binary files a/celerybeat-schedule-shm and b/celerybeat-schedule-shm differ diff --git a/celerybeat-schedule-wal b/celerybeat-schedule-wal index b79331f..27f09f9 100644 Binary files a/celerybeat-schedule-wal and b/celerybeat-schedule-wal differ 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 +