GatewayWorker分布式部署
配置三臺服務(wù)器start_gateway.php start_businessworker.php中的registerAddress為['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236']。
設(shè)備A 連接接了192.168.1.1 會隨機分配 businessworker 1,2,3臺來處理信息進行bindUid 綁定
而192.168.1.1 在發(fā)送信息 isUidOnline,sendToUid 都是失敗了
//第一臺192.168.1.1
//start_gateway.php
$gateway_package = new Gateway("tcp://0.0.0.0:8090");
$gateway_package->name = 'GatewayPackage1';
$gateway_package->count = 4;
$gateway_package->lanIp = '192.168.1.1';
$gateway_package->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
$gateway_package->startPort = 9566;
$gateway_package->pingInterval = 30;
$gateway_package->pingNotResponseLimit = 2;
// bussinessWorker 進程
$worker = new BusinessWorker();
// worker名稱
$worker->name = 'YourAppBusinessWorker1';
// bussinessWorker進程數(shù)量
$worker->count = 4;
$worker->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
//第二臺192.168.1.2
//start_gateway.php
$gateway_package = new Gateway("tcp://0.0.0.0:8090");
$gateway_package->name = 'GatewayPackage2';
$gateway_package->count = 4;
$gateway_package->lanIp = '192.168.1.2';
$gateway_package->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
$gateway_package->startPort = 9566;
$gateway_package->pingInterval = 30;
$gateway_package->pingNotResponseLimit = 2;
// bussinessWorker 進程
$worker = new BusinessWorker();
// worker名稱
$worker->name = 'YourAppBusinessWorker2';
// bussinessWorker進程數(shù)量
$worker->count = 4;
$worker->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
//第三臺192.168.1.3
//start_gateway.php
$gateway_package = new Gateway("tcp://0.0.0.0:8090");
$gateway_package->name = 'GatewayPackage3';
$gateway_package->count = 4;
$gateway_package->lanIp = '192.168.1.3';
$gateway_package->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
$gateway_package->startPort = 9566;
$gateway_package->pingInterval = 30;
$gateway_package->pingNotResponseLimit = 2;
// bussinessWorker 進程
$worker = new BusinessWorker();
// worker名稱
$worker->name = 'YourAppBusinessWorker3';
// bussinessWorker進程數(shù)量
$worker->count = 4;
$worker->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
tcp連接192.168.1.1:8090 bussinessWorker 是隨機分配 1,2,3 臺服務(wù)器來進行綁定 bindUid 綁定uid
可是這樣綁定不上 是我的配置有問題還是bindUid 不能互通 ABC 臺服務(wù)器 可以是B上線 A在根據(jù)綁定信息發(fā)送指令就不行了
1、注意多機部署時以下端口不要被服務(wù)器安全組阻擋:
①、Register服務(wù)監(jiān)聽的端口要可以被其它內(nèi)網(wǎng)服務(wù)器訪問(為了安全,register要監(jiān)聽內(nèi)網(wǎng)ip不能讓其被外網(wǎng)訪問);
②、start_gateway.php中如果$gateway->startPort=2300; $gateway->count=4;,則2300 2301 2302 2303四個端口需要被設(shè)置成能被其它服務(wù)器訪問,也就是起始端口$gateway->startPort到$gateway->startPort + $gateway->count - 1這 $gateway->count個端口要設(shè)置成能被其它內(nèi)網(wǎng)服務(wù)器訪問。