Cluster purpose: To achieve high availability, fault-tolerant function, cluster servers do not put in a physical machine, to disperse nodes, in order to achieve high availability, high fault tolerance, a provider hangs, there are other providers to ensure that the system normal, stable operation.
I. Environmental preparedness
EDU-PROVIDER-01 (192.168.1.121)
EDU-PROVIDER-02 (192.168.1.122)
Connecting to 192.168.1.121:22 ...
Connection established.
To an escape to the local shell, press ' ctrl+alt+] '.
Last Login:sat APR 9 04:28:07 2016 from 192.168.1.51
[Root@edu-provider-01 ~]#
Connecting to 192.168.1.122:22 ...
Connection established.
To an escape to the local shell, press ' ctrl+alt+] '.
Last Login:sat APR 9 04:28:07 2016 from 192.168.1.51
[Root@edu-provider-02 ~]#
Second, Dubbo service cluster
User Service: Pay-service-user
Transaction services: Pay-service-trade
I started both services on the 121,122 server
[root@edu-provider-01 user]#./service-user.sh start
= = Start Pay-service-user
[Root@edu-provider-01 user]# CD ...
[Root@edu-provider-01 service]# CD trade/
[root@edu-provider-01 trade]#./service-trade.sh start
= = Start Pay-service-trade
[root@edu-provider-02 user]#./service-user.sh start
= = Start Pay-service-user
[Root@edu-provider-02 user]# CD ...
[Root@edu-provider-02 service]# CD trade/
[root@edu-provider-02 trade]#./service-trade.sh start
= = Start Pay-service-trade
Services that can be viewed on both machines in the Dubboadmin Management console are registered successfully
Here I can check the transaction information
I'll turn off 121 of the trading services first.
[root@edu-provider-01 trade]#./service-trade.sh stop
= = Stop Pay-service-trade
[Root@edu-provider-01 trade]# Ps-ef | grep pay
Root 2803 1 8 06:33 pts/0 00:00:50/usr/jdk/jre/bin/java-xms128m-xmx512m-jar Pay-service-user.jar
Root 2980 2705 0 06:43 pts/0 00:00:00 grep pay
[Root@edu-provider-01 trade]#
Here I can still query the transaction information
I'll turn off 122 of the trading service.
[root@edu-provider-02 trade]#./service-trade.sh stop
= = Stop Pay-service-trade
[Root@edu-provider-02 trade]# Ps-ef | grep pay
Root 2639 1 7 06:34 pts/1 00:00:51/usr/jdk/jre/bin/java-xms128m-xmx512m-jar Pay-service-user.jar
Root 2816 2592 0 06:46 pts/1 00:00:00 grep pay
[Root@edu-provider-02 trade]#
I'm going to get an exception when I check the transaction information.
I open the trading service on the 121 service, and I can check the transaction information.
[root@edu-provider-01 trade]#./service-trade.sh start
= = Start Pay-service-trade
[Root@edu-provider-01 trade]#
Third, Dubbo Service fault-tolerant configuration-cluster fault-tolerant mode
<dubbo:service> supplier configuration label, coarse granularity
Example:<!--when Protocolconfig and serviceconfig a property is not configured, this default value is used-->
<dubbo:provider timeout= "30000" threadpool= "fixed" threads= "accepts=" 1000 "/>"
<DUBBO:SERVICE>: Service Publishing tab, for example, configure fault tolerance on this, granular <!--provide service interface-->
<dubbo:service retries= "0" interface= "edu.pay.facade.trade.service.PaymentFacade" ref= "Paymentfacade"/>
<dubbo:consumer> consumer end tag, apply a single consumer configuration, coarse granularity
Example: <dubbo:consumer timeout= "8000" retries= "0"/>
Configure fault tolerance on this, granular fine <dubbo:reference >
<!--Call Account service-->
<dubbo:reference interface= "Edu.pay.facade.account.service.AccountTransactionFacade" id= " Accounttransactionfacade "check= false"/>
Properties: Cluster Type: string
Required: Optional default value: Failover
Function: Performance tuning cluster mode: Optional: failover/failfast/failsafe/failback/forking
1, Failover Cluster
Failed auto switch, when a failure occurs, retry the other server. (the default) is typically used for read operations, but retries can result in longer delays. You can set the number of retries (excluding the first time) by retries= "2".
<dubbo:service retries= "2"/>
Or:
<dubbo:reference retries= "2"/>
Or:
<dubbo:reference>
<dubbo:method name= "Findfoo" retries= "2"/> </dubbo:reference>
2, FailFast Cluster
Fast failure, only one call is initiated, and the failure immediately complains. Typically used for non-idempotent write operations, such as New records.
<dubbo:service cluster= "FailFast"/>
Or:
<dubbo:reference cluster= "FailFast"/>
3.Failsafe Cluster
Failure security, which is ignored when an exception occurs, and is typically used to write to an audit log, and so on
<dubbo:service cluster= "failsafe"/> or
<dubbo:reference cluster= "Failsafe"/>
4.Failback Cluster
Failed AutoRecover, background record failure request, timed postback, usually used for message notification operations.
<dubbo:service cluster= "failback"/>
Or
<dubbo:reference cluster= "failback"/>
5.Forking Cluster
Calling multiple services in parallel, as long as a success is returned, is often used to require higher read operations in real time, but requires a waste of more server resources. You can set the maximum number of concurrent numbers by forks= "2".
<dubbo:service cluster= "Forking" >
Or
<dubbo:reference cluster= "forking"/>
In the actual project, in the production environment, we can use the failover mode to design the service interface, follow the principle of interface isolation, query service and write operation service isolation,
Query Interface We can configure retries= "2"
in the write operation interface we configure retries= "0", if not set to 0, timeout, will reconnect, will appear repeatedly write the situation, so use failover mode, we have read and write operation interface isolation, and write operation interface Retries=0
Label
label