Redis

Redis 集群 Docker docker-compose.yml services: redis: image: redis:7.4.0 container_name: redis volumes: - /etc/localtime:/etc/localtime:ro - /opt/redis/conf:/usr/local/etc/redis - /opt/redis/data:/data environment: - TZ=Asia/Shanghai command: - redis-server - /usr/local/etc/redis/redis.conf network_mode: host restart: always redis.conf bind 0.0.0.0 port 6379 appendonly yes loglevel notice cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 cluster-announce-ip x.x.x.x 启动 docker compose -f docker-compose.yml up -d 添加节点 redis-cli --cluster create 192.168.26.11:6379 192.168.26.12:6379 192.168.26.13:6379 192.168.26.14:6379 192.168.26.15:6379 192.168.26.16:6379 192.168.26.17:6379 192.168.26.18:6379 --cluster-replicas 1 docker exec -it redis redis-cli CLUSTER MEET x....

August 8, 2024 · Kevin

Postgres

Postgres 主从模式 HOSTNAME IP master 192.168.2.11 replica 192.168.2.12 Docker master 创建目录赋权 mkdir -p /mnt/da/postgres/data chown 1000:1000 /mnt/da/postgres/data docker-compose.yml services: postgres: image: timescale/timescaledb-ha:pg16.3-ts2.15.1-all container_name: postgres volumes: - /etc/localtime:/etc/localtime:ro - /mnt/da/postgres/data:/var/lib/postgresql/data environment: - TZ=Asia/Shanghai - PGDATA=/var/lib/postgresql/data/pgdata - POSTGRES_PASSWORD=postgres network_mode: host restart: always 启动 docker compose -f docker-compose.yml up -d 修改 postgresql.conf listen_addresses = '*' max_connections = 1024 password_encryption = scram-sha-256 shared_buffers = 32GB work_mem = 8192kB maintenance_work_mem = 32GB effective_io_concurrency = 512 max_worker_processes = 256 max_parallel_workers_per_gather = 128 max_parallel_workers = 64 wal_level = replica synchronous_commit = off checkpoint_completion_target = 0....

July 25, 2024 · Kevin

PXC

PXC 主从模式 HOSTNAME IP node1 192.168.2.11 node2 192.168.2.12 SWARM 集群 创建 SWARM 主节点 (–advertise-addr 用来指定使用哪个网卡的 IP) docker swarm init --advertise-addr 192.168.2.11 复制初始化输出的加入命令,在需要加入的机器执行 docker swarm join --token xxx 创建 PXC 专用的 overlay 网络 pxc docker network create --driver overlay --attachable --subnet 10.10.0.0/16 pxc_net 删除没用网络 docker network prune 删除指定网络 docker network rm pxc_net 离开集群 docker swarm leave -f Docker node1 创建目录,赋权 mkdir -p /opt/pxc-node1/conf /opt/pxc-node1/data /opt/pxc-node1/logs chmod 777 /opt/pxc-node1/conf /opt/pxc-node1/data /opt/pxc-node1/logs mysqld 配置...

April 17, 2024 · Kevin