connect(username,password,url) edit() startEdit() #创建群集 theCluster = cmo.createCluster( 'mycluster' ) theCluster.setClusterMessagingMode( 'unicast' ) theCluster.setClusterBroadcastChannel( 'myclusterChannel' ) #创建被管理服务器 ms = cmo.createServer( 'ms1' ) ms.setListenAddress( 'localhost' ) ms.setListenPort( 8001 ) ms.setCluster( theCluster ) #创建Unicast使用的通道 channel = ms.createNetworkAccessPoint( 'myclusterChannel' ) channel.setListenPort( 5001 ) #-1指通道监听端口与服务器实例监听端口相同 channel.setPublicPort( -1 ) #-1指通道外部监听端口与通道监听端口相同 channel.setProtocol( 'cluster-broadcast' ) #想更安全使用 cluster-broadcast-secure #通道其它选项 #channel.setAddress( null ) #null 指通道监听地址与服务器实例监听地址相同 #channel.setPublicAddress( null ) #null指通道外部监听地址与通道监听地址相同 #下面三个必须Enabled channel.setOutboundEnabled( true ) #默认是false channel.setHttpEnabledForThisProtocol(true) channel.setEnabled( true ) #其它选项 #channel.setTunnelingEnabled( false ) #channel.setTwoWaySSLEnabled( false ) #channel.setClientCertificateEnforced( false ) ms = cmo.createServer( 'ms2' ) ms.setListenAddress( 'localhost' ) ms.setListenPort( 9001 ) ms.setCluster( theCluster ) channel = ms.createNetworkAccessPoint( 'myclusterChannel' ) channel.setListenPort( 6001 ) channel.setPublicPort( -1 ) channel.setProtocol( 'cluster-broadcast' ) channel.setOutboundEnabled( true ) channel.setHttpEnabledForThisProtocol(true) channel.setEnabled( true ) save() activate() disconnect()
原文件下载:unicast_cluster.zip