Dubbo releases web service instances and dubboweb instances

Source: Internet
Author: User

Dubbo releases web service instances and dubboweb instances

Dubbo role and call Execution Process

Dubbo node role description:
Provider: exposes the service provider.
Consumer: the consumer who calls the remote service
Registry: the service is registered in the discovery registry.
Monitor: Monitoring Center that counts the number of service calls and call time
Container: Service running container

Dubbo call relationship description:
1. The service container is responsible for starting, loading, and running the service provider.
2. When the service provider starts, it registers its own services with the Registration Center.
3. service consumers subscribe to the Registration Center to subscribe to the services they need at startup.
4. The Registration Center returns the service provider address list to the consumer. If there is any change, the Registration Center pushes the change data to the Consumer based on the persistent connection.
5. The service consumer selects one provider for calling Based on the soft load balancing algorithm from the provider address list. If the call fails, select another
6. service consumers and providers, accumulate calls and call times in the memory, and regularly send statistical data to the monitoring center once per minute

Registration Center:
Zookeeper (version 2.3.3 or later is recommended)
Dubbo does not make any intrusion changes to the zookeeper server. You only need to install the native zookeeper server. All logical adaptation of the Registry is completed when the zookeeper client is called.

Zookeeper Registration Center Installation

Author's Environment:
A) centos
IP Address: [192.168.1.107]

B) zookeeper
Zk version: [zookeeper-3.4.6]
1. Modify the/etc/hosts file and add host "192.168.1.107 zk-provider" as follows
[root@localhost local]# vim /etc/hosts[root@localhost local]# cat /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.1.107 zk-provider
2. Unzip the zookeeper-3.4.6 to/usr/local/
[root@localhost zookeeper-3.4.6]# pwd/usr/local/zookeeper-3.4.6
3. Create a directory under the/usr/local/zookeeper-3.4.6 directory:
[root@localhost zookeeper-3.4.6]# mkdir logs[root@localhost zookeeper-3.4.6]# mkdir data
4. Copy zoo_sample.cfg under the/usr/local/zookeeper-3.4.6/conf directory and name it zoo. cfg.
[root@localhost conf]# pwd/usr/local/zookeeper-3.4.6/conf[root@localhost conf]# cp zoo_sample.cfg zoo.cfg
5. Modify the zoo. cfg file as follows:
[Root @ localhost conf] # cat zoo. cfgtickTime = 2000 # initLimit this configuration item is used to configure zookeeper interface client initLimit = 10 syncLimit = 5 dataDir =/usr/local/zookeeper-3.4.6/datadtaLogDir =/usr/local/zookeeper-3.4.6/logsclientPort = 2181. 1 = zk-providers: 2888: 3888
Note: server.1 = zk-provider: 2888: 3888 is equivalent to server.1 = 192.168.1.107: 2888: 3888
6. Create the myid file under/usr/local/zookeeper-3.4.6/data and enter the number corresponding to the current service machine
[root@localhost data]# pwd/usr/local/zookeeper-3.4.6/data[root@localhost data]# lsmyid[root@localhost data]# cat myid1[root@localhost data]#
7. Configure zookeeper to Environment Variables
[root@localhost data]# vim /etc/profile

Add at the end of the file

# zookeeper envexport ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6export PATH=$ZOOKEEPER_HOME/bin:$PATH

 

Save and exit to make the configuration take effect

[root@localhost data]# source /etc/profile
8. Use ports 2181, 2888, and 3888 to open the firewall.
[root@localhost data]# vim /etc/sysconfig/iptables
Add the following before COMMIT:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 2888 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 3888 -j ACCEPT
Restart Firewall
[root@localhost data]# service iptables restart[root@localhost data]# service iptables status
9. Start zookeeper
[Root @ localhost zookeeper-3.4.6] #/usr/local/zookeeper-3.4.6/bin/zkServer. sh startJMX enabled by defaultUsing config:/usr/local/zookeeper-3.4.6/bin /.. /conf/zoo. cfstarting zookeeper... STARTED # view the status [root @ localhost zookeeper-3.4.6] # zkServer. sh statusJMX enabled by defaultUsing config:/usr/local/zookeeper-3.4.6/bin /.. /conf/zoo. export mode: standalone # view output service information [root @ localhost zookeeper-3.4.6] # tail-500f/usr/local/zookeeper-3.4.6/bin/zookeeper. out
10. Configure zookeeper to start at random
[Root @ localhost zookeeper-3.4.6] # vim/etc/rc. local # Add the following command/usr/local/zookeeper-3.4.6/bin/zkServer. sh start
 
Dubbo Service Release and call
1. Service Release
<? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: dubbo = "http://code.alibabatech.com/schema/dubbo" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <! -- Provider application information for dependency calculation --> <dubbo: application name = "ws-server-user"/> <! -- Use the zookeeper registration center to expose the service address --> <dubbo: registry protocol = "zookeeper" address = "192.168.1.107: 2181"/> <! -- Expose services on port 20880 using dubbo protocol --> <dubbo: protocol name = "dubbo" port = "20880"/> <bean id = "userFacade" class = "com. ws. server. userFacadeImpl "/> <! -- User service interface --> <dubbo: service interface = "com. ws. facade. UserFacade" ref = "userFacade"/> </beans>
 
2. service call
<? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns: dubbo = "http://code.alibabatech.com/schema/dubbo" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <! -- Consumer application name, used to calculate dependencies. It is not a matching condition and must not be the same as the provider --> <dubbo: application name = "ws-client-invoke-user"/> <! -- Use the zookeeper registration center to expose the service address --> <! -- Registry address --> <dubbo: registry protocol = "zookeeper" address = "192.168.1.107: 2181"/> <! -- User service interface --> <dubbo: reference interface = "com. ws. facade. UserFacade" id = "userFacadeClient" check = "false"/> </beans>
 
Instance demo: http://files.cnblogs.com/files/dennisit/dubbo-ws.zip

For more information, see [http://www.cnblogs.com/dennisit/p/4542901.html].

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.