mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-13 09:02:26 +08:00
1.MongoDB、Redis兼容集群模式
2.离线数据接口化访问
This commit is contained in:
47
docker/3rd/mongo/mongo_cluster/create_cluster.sh
Executable file
47
docker/3rd/mongo/mongo_cluster/create_cluster.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
|
||||
# shard1
|
||||
mongo --host 192.168.199.233 --port 27118 <<EOF
|
||||
rs.initiate({_id: "shard1", members: [{_id: 0, host: "mongo_shard1:27018"}]})
|
||||
EOF
|
||||
|
||||
# shard2
|
||||
mongo --host 192.168.199.233 --port 27218 <<EOF
|
||||
rs.initiate({_id: "shard2", members: [{_id: 0, host: "mongo_shard2:27018"}]})
|
||||
EOF
|
||||
|
||||
# shard3
|
||||
mongo --host 192.168.199.233 --port 27318 <<EOF
|
||||
rs.initiate({_id: "shard3", members: [{_id: 0, host: "mongo_shard3:27018"}]})
|
||||
EOF
|
||||
|
||||
# config1
|
||||
mongo --host 192.168.199.233 --port 27119 <<EOF
|
||||
rs.initiate({_id: "config", configsvr: true, members: [{_id: 0, host: "mongo_config1:27019"}, {_id: 1, host: "mongo_config2:27019"}, {_id: 2, host: "mongo_config3:27019"}]})
|
||||
EOF
|
||||
|
||||
sleep 30
|
||||
|
||||
# mongos1
|
||||
mongo --host 192.168.199.233 --port 27117 <<EOF
|
||||
sh.addShard("shard1/mongo_shard1:27018")
|
||||
sh.addShard("shard2/mongo_shard2:27018")
|
||||
sh.addShard("shard3/mongo_shard3:27018")
|
||||
EOF
|
||||
|
||||
sleep 5
|
||||
|
||||
mongo --host 192.168.199.233 --port 27117 <<EOF
|
||||
sh.enableSharding("dispatch_hk4e")
|
||||
sh.shardCollection("dispatch_hk4e.account", {"AccountID": "hashed"})
|
||||
sh.enableBalancing("dispatch_hk4e.account")
|
||||
sh.shardCollection("dispatch_hk4e.client_log", {"_id": "hashed"})
|
||||
sh.enableBalancing("dispatch_hk4e.client_log")
|
||||
sh.enableSharding("gs_hk4e")
|
||||
sh.shardCollection("gs_hk4e.player", {"PlayerID": "hashed"})
|
||||
sh.enableBalancing("gs_hk4e.player")
|
||||
sh.shardCollection("gs_hk4e.chat_msg", {"Uid": "hashed"})
|
||||
sh.enableBalancing("gs_hk4e.chat_msg")
|
||||
sh.startBalancer()
|
||||
db.adminCommand("flushRouterConfig")
|
||||
EOF
|
||||
196
docker/3rd/mongo/mongo_cluster/docker-compose.yaml
Normal file
196
docker/3rd/mongo/mongo_cluster/docker-compose.yaml
Normal file
@@ -0,0 +1,196 @@
|
||||
version: '3'
|
||||
services:
|
||||
mongo_shard1:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_shard1
|
||||
ports:
|
||||
- "27118:27018/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
- ./data/shard1:/data/db
|
||||
command: mongod --shardsvr --replSet shard1
|
||||
privileged: true
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '4.00'
|
||||
memory: 512M
|
||||
|
||||
mongo_shard2:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_shard2
|
||||
ports:
|
||||
- "27218:27018/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
- ./data/shard2:/data/db
|
||||
command: mongod --shardsvr --replSet shard2
|
||||
privileged: true
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '4.00'
|
||||
memory: 512M
|
||||
|
||||
mongo_shard3:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_shard3
|
||||
ports:
|
||||
- "27318:27018/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
- ./data/shard3:/data/db
|
||||
command: mongod --shardsvr --replSet shard3
|
||||
privileged: true
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '4.00'
|
||||
memory: 512M
|
||||
|
||||
mongo_config1:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_config1
|
||||
ports:
|
||||
- "27119:27019/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
- ./data/config1:/data/configdb
|
||||
command: mongod --configsvr --replSet config
|
||||
depends_on:
|
||||
- mongo_shard1
|
||||
- mongo_shard2
|
||||
- mongo_shard3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.00'
|
||||
memory: 256M
|
||||
|
||||
mongo_config2:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_config2
|
||||
ports:
|
||||
- "27219:27019/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
- ./data/config2:/data/configdb
|
||||
command: mongod --configsvr --replSet config
|
||||
depends_on:
|
||||
- mongo_shard1
|
||||
- mongo_shard2
|
||||
- mongo_shard3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.00'
|
||||
memory: 256M
|
||||
|
||||
mongo_config3:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_config3
|
||||
ports:
|
||||
- "27319:27019/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
- ./data/config3:/data/configdb
|
||||
command: mongod --configsvr --replSet config
|
||||
depends_on:
|
||||
- mongo_shard1
|
||||
- mongo_shard2
|
||||
- mongo_shard3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.00'
|
||||
memory: 256M
|
||||
|
||||
mongo_mongos1:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_mongos1
|
||||
ports:
|
||||
- "27117:27017/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
command: mongos --bind_ip_all --configdb config/mongo_config1:27019,mongo_config2:27019,mongo_config3:27019
|
||||
depends_on:
|
||||
- mongo_config1
|
||||
- mongo_config2
|
||||
- mongo_config3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2.00'
|
||||
memory: 128M
|
||||
|
||||
mongo_mongos2:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_mongos2
|
||||
ports:
|
||||
- "27217:27017/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
command: mongos --bind_ip_all --configdb config/mongo_config1:27019,mongo_config2:27019,mongo_config3:27019
|
||||
depends_on:
|
||||
- mongo_config1
|
||||
- mongo_config2
|
||||
- mongo_config3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2.00'
|
||||
memory: 128M
|
||||
|
||||
mongo_mongos3:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo_mongos3
|
||||
ports:
|
||||
- "27317:27017/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
command: mongos --bind_ip_all --configdb config/mongo_config1:27019,mongo_config2:27019,mongo_config3:27019
|
||||
depends_on:
|
||||
- mongo_config1
|
||||
- mongo_config2
|
||||
- mongo_config3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2.00'
|
||||
memory: 128M
|
||||
19
docker/3rd/mongo/mongo_strndalone/docker-compose.yaml
Normal file
19
docker/3rd/mongo/mongo_strndalone/docker-compose.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
version: '3'
|
||||
services:
|
||||
mongo:
|
||||
restart: always
|
||||
image: mongo:5.0.5
|
||||
container_name: mongo
|
||||
ports:
|
||||
- "27017:27017/tcp"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
- /etc/timezone:/etc/timezone
|
||||
- ./data:/data/db
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '4.00'
|
||||
memory: 512M
|
||||
Reference in New Issue
Block a user