优化集群创建脚本

This commit is contained in:
flswld
2023-05-28 19:54:03 +08:00
parent 3100e8b147
commit 98976d7a7d
13 changed files with 1081 additions and 69 deletions

View File

@@ -10,12 +10,14 @@
body { body {
margin: 0; margin: 0;
} }
.title { .title {
margin: 15px; margin: 15px;
font-size: 18px; font-size: 18px;
line-height: 18px; line-height: 18px;
height: 18px; height: 18px;
} }
#log { #log {
margin: 10px; margin: 10px;
display: none; display: none;
@@ -28,6 +30,7 @@
#log p { #log p {
} }
#loading { #loading {
position: fixed; position: fixed;
top: 50%; top: 50%;
@@ -41,9 +44,14 @@
<div id="captcha"></div> <div id="captcha"></div>
<div id="log"></div> <div id="log"></div>
<div id="loading"> <div id="loading">
<svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve"> <svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg"
<path fill="#c7c5c5" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z" transform="rotate(340 25 25)"> x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;"
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform> xml:space="preserve">
<path fill="#c7c5c5"
d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z"
transform="rotate(340 25 25)">
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25"
dur="0.6s" repeatCount="indefinite"></animateTransform>
</path> </path>
</svg> </svg>
</div> </div>
@@ -135,12 +143,12 @@
log('Error Ocurred.'); log('Error Ocurred.');
try { try {
if (typeof JSInterface !== 'undefined') { if (typeof JSInterface !== 'undefined') {
if (typeof JSInterface.gtError === 'function') { if (typeof JSInterface.gtError === 'function') {
JSInterface.gtError(); JSInterface.gtError();
} }
if (typeof JSInterface.gt3Error === 'function') { if (typeof JSInterface.gt3Error === 'function') {
JSInterface.gt3Error(JSON.stringify(err)) JSInterface.gt3Error(JSON.stringify(err))
} }
} }
loadingEle.style.display = 'none' loadingEle.style.display = 'none'
} catch (e) { } catch (e) {
@@ -149,14 +157,14 @@
try { try {
if (window.webkit if (window.webkit
&& window.webkit.messageHandlers) { && window.webkit.messageHandlers) {
err = err || {}; err = err || {};
err.error = '1'; err.error = '1';
var message = JSON.stringify(err); var message = JSON.stringify(err);
if (window.webkit.messageHandlers.gtError) { if (window.webkit.messageHandlers.gtError) {
window.webkit.messageHandlers.gtError.postMessage(message); window.webkit.messageHandlers.gtError.postMessage(message);
} }
if (window.webkit.messageHandlers.gt3Error) { if (window.webkit.messageHandlers.gt3Error) {
window.webkit.messageHandlers.gt3Error.postMessage(message); window.webkit.messageHandlers.gt3Error.postMessage(message);
} }
} }
} catch (e) { } catch (e) {
@@ -261,9 +269,9 @@
} }
}); });
captchaObj.onError(errorHandler); captchaObj.onError(errorHandler);
if(typeof captchaObj.onChangeCaptcha === 'function'){ if (typeof captchaObj.onChangeCaptcha === 'function') {
captchaObj.onChangeCaptcha(function (type) { captchaObj.onChangeCaptcha(function (type) {
var notification = { aspect_radio: args[('aspect_radio_'+type)] } var notification = {aspect_radio: args[('aspect_radio_' + type)]}
try { try {
if (typeof JSInterface !== 'undefined') { if (typeof JSInterface !== 'undefined') {
JSInterface.gtNotify(JSON.stringify(notification)); JSInterface.gtNotify(JSON.stringify(notification));
@@ -309,8 +317,8 @@
s.onload = s.onreadystatechange = function () { s.onload = s.onreadystatechange = function () {
if (!loaded && if (!loaded &&
(!s.readyState (!s.readyState
|| s.readyState === "loaded" || s.readyState === "loaded"
|| s.readyState === 'complete')) { || s.readyState === 'complete')) {
if (test()) { if (test()) {
loaded = true; loaded = true;
callback(null); callback(null);
@@ -328,7 +336,7 @@
head.appendChild(s); head.appendChild(s);
}; };
function init(js){ function init(js) {
loadJS(static_servers, js, function () { loadJS(static_servers, js, function () {
return window.Geetest; return window.Geetest;
}, function (err) { }, function (err) {
@@ -340,6 +348,7 @@
handler(config); handler(config);
}); });
} }
init(js); init(js);
</script> </script>
</body> </body>

View File

@@ -1 +1,3 @@
{"version":16} {
"version": 16
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1,3 @@
{"version":69} {
"version": 69
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1,3 @@
{"version":66} {
"version": 66
}

File diff suppressed because one or more lines are too long

View File

@@ -18,7 +18,7 @@ services:
resources: resources:
limits: limits:
cpus: '1.00' cpus: '1.00'
memory: 128M memory: 512M
dispatch_services: dispatch_services:
restart: always restart: always
image: flswld/dispatch:1.0.0 image: flswld/dispatch:1.0.0
@@ -42,11 +42,11 @@ services:
resources: resources:
limits: limits:
cpus: '1.00' cpus: '1.00'
memory: 128M memory: 512M
gate_services: gate_320_services:
restart: always restart: always
image: flswld/gate:1.0.0 image: flswld/gate:1.0.0
container_name: gate container_name: gate_320
ports: ports:
- "22222:22222/udp" - "22222:22222/udp"
- "33333:33333/tcp" - "33333:33333/tcp"
@@ -65,8 +65,8 @@ services:
deploy: deploy:
resources: resources:
limits: limits:
cpus: '4.00' cpus: '8.00'
memory: 1024M memory: 8192M
anticheat_services: anticheat_services:
restart: always restart: always
image: flswld/anticheat:1.0.0 image: flswld/anticheat:1.0.0
@@ -83,12 +83,12 @@ services:
- ./anticheat/bin/application.toml:/anticheat/application.toml - ./anticheat/bin/application.toml:/anticheat/application.toml
- ../gdconf/game_data_config:/anticheat/game_data_config - ../gdconf/game_data_config:/anticheat/game_data_config
depends_on: depends_on:
- gate_services - gate_320_services
deploy: deploy:
resources: resources:
limits: limits:
cpus: '1.00' cpus: '1.00'
memory: 128M memory: 512M
pathfinding_services: pathfinding_services:
restart: always restart: always
image: flswld/pathfinding:1.0.0 image: flswld/pathfinding:1.0.0
@@ -108,12 +108,12 @@ services:
deploy: deploy:
resources: resources:
limits: limits:
cpus: '4.00' cpus: '1.00'
memory: 1024M memory: 512M
gs_services: gs_1_services:
restart: always restart: always
image: flswld/gs:1.0.0 image: flswld/gs:1.0.0
container_name: gs container_name: gs_1
ports: ports:
- "4567:4567/tcp" - "4567:4567/tcp"
environment: environment:
@@ -130,8 +130,52 @@ services:
deploy: deploy:
resources: resources:
limits: limits:
cpus: '4.00' cpus: '8.00'
memory: 4096M memory: 8192M
gs_2_services:
restart: always
image: flswld/gs:1.0.0
container_name: gs_2
ports:
- "4568:4567/tcp"
environment:
TZ: Asia/Shanghai
GOLANG_PROTOBUF_REGISTRATION_CONFLICT: ignore
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /usr/share/zoneinfo:/usr/share/zoneinfo
- ./gs/bin/application.toml:/gs/application.toml
- ../gdconf/game_data_config:/gs/game_data_config
depends_on:
- gs_1_services
deploy:
resources:
limits:
cpus: '8.00'
memory: 8192M
gs_3_services:
restart: always
image: flswld/gs:1.0.0
container_name: gs_3
ports:
- "4569:4567/tcp"
environment:
TZ: Asia/Shanghai
GOLANG_PROTOBUF_REGISTRATION_CONFLICT: ignore
volumes:
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /usr/share/zoneinfo:/usr/share/zoneinfo
- ./gs/bin/application.toml:/gs/application.toml
- ../gdconf/game_data_config:/gs/game_data_config
depends_on:
- gs_2_services
deploy:
resources:
limits:
cpus: '8.00'
memory: 8192M
gm_services: gm_services:
restart: always restart: always
image: flswld/gm:1.0.0 image: flswld/gm:1.0.0
@@ -148,9 +192,9 @@ services:
- /usr/share/zoneinfo:/usr/share/zoneinfo - /usr/share/zoneinfo:/usr/share/zoneinfo
- ./gm/bin/application.toml:/gm/application.toml - ./gm/bin/application.toml:/gm/application.toml
depends_on: depends_on:
- gs_services - gs_3_services
deploy: deploy:
resources: resources:
limits: limits:
cpus: '1.00' cpus: '1.00'
memory: 128M memory: 512M

View File

@@ -1,37 +1,40 @@
#!/bin/sh #!/bin/sh
IP=$1
echo "create mongo cluster, host ip: ${IP}"
echo "init mongo cluster shard"
# shard1 # shard1
mongo --host 192.168.199.233 --port 27118 <<EOF mongo --host "${IP}" --port 27118 <<EOF
rs.initiate({_id: "shard1", members: [{_id: 0, host: "mongo_shard1:27018"}]}) rs.initiate({_id: "shard1", members: [{_id: 0, host: "mongo_shard1:27018"}]})
EOF EOF
# shard2 # shard2
mongo --host 192.168.199.233 --port 27218 <<EOF mongo --host "${IP}" --port 27218 <<EOF
rs.initiate({_id: "shard2", members: [{_id: 0, host: "mongo_shard2:27018"}]}) rs.initiate({_id: "shard2", members: [{_id: 0, host: "mongo_shard2:27018"}]})
EOF EOF
# shard3 # shard3
mongo --host 192.168.199.233 --port 27318 <<EOF mongo --host "${IP}" --port 27318 <<EOF
rs.initiate({_id: "shard3", members: [{_id: 0, host: "mongo_shard3:27018"}]}) rs.initiate({_id: "shard3", members: [{_id: 0, host: "mongo_shard3:27018"}]})
EOF EOF
echo "init mongo cluster config"
# config1 # config1
mongo --host 192.168.199.233 --port 27119 <<EOF mongo --host "${IP}" --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"}]}) 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 EOF
sleep 30 sleep 30
echo "init mongo cluster mongos"
# mongos1 # mongos1
mongo --host 192.168.199.233 --port 27117 <<EOF mongo --host "${IP}" --port 27117 <<EOF
sh.addShard("shard1/mongo_shard1:27018") sh.addShard("shard1/mongo_shard1:27018")
sh.addShard("shard2/mongo_shard2:27018") sh.addShard("shard2/mongo_shard2:27018")
sh.addShard("shard3/mongo_shard3:27018") sh.addShard("shard3/mongo_shard3:27018")
EOF EOF
sleep 5 sleep 5
mongo --host 192.168.199.233 --port 27117 <<EOF echo "init hk4e database table"
mongo --host "${IP}" --port 27117 <<EOF
sh.enableSharding("dispatch_hk4e") sh.enableSharding("dispatch_hk4e")
sh.shardCollection("dispatch_hk4e.account", {"AccountID": "hashed"}) sh.shardCollection("dispatch_hk4e.account", {"AccountID": "hashed"})
sh.enableBalancing("dispatch_hk4e.account") sh.enableBalancing("dispatch_hk4e.account")

View File

@@ -18,7 +18,7 @@ services:
resources: resources:
limits: limits:
cpus: '4.00' cpus: '4.00'
memory: 512M memory: 2048M
mongo_shard2: mongo_shard2:
restart: always restart: always
@@ -38,7 +38,7 @@ services:
resources: resources:
limits: limits:
cpus: '4.00' cpus: '4.00'
memory: 512M memory: 2048M
mongo_shard3: mongo_shard3:
restart: always restart: always
@@ -58,7 +58,7 @@ services:
resources: resources:
limits: limits:
cpus: '4.00' cpus: '4.00'
memory: 512M memory: 2048M
mongo_config1: mongo_config1:
restart: always restart: always
@@ -81,7 +81,7 @@ services:
resources: resources:
limits: limits:
cpus: '1.00' cpus: '1.00'
memory: 256M memory: 512M
mongo_config2: mongo_config2:
restart: always restart: always
@@ -104,7 +104,7 @@ services:
resources: resources:
limits: limits:
cpus: '1.00' cpus: '1.00'
memory: 256M memory: 512M
mongo_config3: mongo_config3:
restart: always restart: always
@@ -127,7 +127,7 @@ services:
resources: resources:
limits: limits:
cpus: '1.00' cpus: '1.00'
memory: 256M memory: 512M
mongo_mongos1: mongo_mongos1:
restart: always restart: always
@@ -149,7 +149,7 @@ services:
resources: resources:
limits: limits:
cpus: '2.00' cpus: '2.00'
memory: 128M memory: 1024M
mongo_mongos2: mongo_mongos2:
restart: always restart: always
@@ -171,7 +171,7 @@ services:
resources: resources:
limits: limits:
cpus: '2.00' cpus: '2.00'
memory: 128M memory: 1024M
mongo_mongos3: mongo_mongos3:
restart: always restart: always
@@ -193,4 +193,4 @@ services:
resources: resources:
limits: limits:
cpus: '2.00' cpus: '2.00'
memory: 128M memory: 1024M

View File

@@ -15,5 +15,5 @@ services:
deploy: deploy:
resources: resources:
limits: limits:
cpus: '4.00' cpus: '1.00'
memory: 512M memory: 512M

View File

@@ -0,0 +1,11 @@
#!/bin/sh
IP=$1
echo "update redis config, host ip: ${IP}"
sed -i s/192.168.199.233/"${IP}"/ ./redis1/redis.conf
sed -i s/192.168.199.233/"${IP}"/ ./redis2/redis.conf
sed -i s/192.168.199.233/"${IP}"/ ./redis3/redis.conf
sed -i s/192.168.199.233/"${IP}"/ ./redis4/redis.conf
sed -i s/192.168.199.233/"${IP}"/ ./redis5/redis.conf
sed -i s/192.168.199.233/"${IP}"/ ./redis6/redis.conf

View File

@@ -1,10 +1,13 @@
#!/bin/sh #!/bin/sh
IP=$1
echo "create redis cluster, host ip: ${IP}"
redis-cli -a 123456 --cluster create \ redis-cli -a 123456 --cluster create \
192.168.199.233:6371 \ "${IP}":6371 \
192.168.199.233:6372 \ "${IP}":6372 \
192.168.199.233:6373 \ "${IP}":6373 \
192.168.199.233:6374 \ "${IP}":6374 \
192.168.199.233:6375 \ "${IP}":6375 \
192.168.199.233:6376 \ "${IP}":6376 \
--cluster-replicas 1 --cluster-replicas 1