Introduction to watchdog of resin and implementation of resin Load Balancing

Source: Internet
Author: User

To ensure stability and security, resin uses an independent watchdog process to start and monitor the Resin server. Watchdog continuously detects the status of the Resin server. If it is unresponsive or slow, the Resin server process will be restarted. In most cases, watchdog reads configuration information from resin. xml without additional configuration. Some ISP service providers may use special configurations. To ensure security, they will configure watchdog to isolate JVM (Java virtual host ).

Overview
Because watchdog runs as a service, you do not need to pay attention to it in most cases. Under the standard configuration, watchdog on a machine can monitor all the JVMs on this machine. Therefore, you do not need to modify the watchdog configuration in most cases. The task for managing watchdog is to stop watchdog and check the restart event of the Resin server in the watchdog log if a problem occurs on the machine.

Watchdog automatically restarts the crashed and exited resin services. So if you want to stop resin, you need to tell watchdog to stop the resin instance, or stop the watchdog completely. Use the main program in resin. ar to control watchdog. It can be used to start, stop, and restart the resin instance, as well as to report the watchdog status.

Most users do not need to configure watchdog, but ISP and big site may create special watchdog. XML (including the <watchdog-Manager> tag) to control watchdog. <Watchdog-Manager> allows the ISP to control watchdog and specify additional command line parameters for their users' resin instances, including the ability to create a secure chroot environment for their users. Typically, watchdog runs with the root account, but user instances use their respective user IDs.

Command Line
The command line of the main class resinboot in resin. jar is used to control watchdog. Main Operations include start, stop, restart, shutdown, and status.

Start
The "start" command uses the given server ID to start a new resin instance. Resinboot first tries watchdog on the current machine and starts a new watchdog as needed. The server ID defined in resin. xml must be unique.
Example: watchdog startup

Resin-3.2.x> JAVA-jar lib/resin. jar-conf CONF/test. conf-server a start
Resin/3.2.x started-server 'A' for watchdog at 127.0.0.1: 6700

Stop
The "stop" command uses the specified server ID to stop the resin instance. If the stopped instance is the last resin instance managed by watchdog, watchdog automatically exits. If the-server parameter is not specified, watchdog uses the default-server "".

Example: watchdog stops

Resin-3.2.x> JAVA-jar lib/resin. Jar stop
Resin/3.2.x started-server ''for watchdog at 127.0.0.1: 6600

Status
The "status" command counts the status of the resin instance managed by the watchdog service.
Example: watchdog status

Resin-3.2.x> JAVA-jar lib/resin. Jar status
Resin/3.2.x status for watchdog at Fig: 6600

Server '': Active
Password: Missing
User: Ferg
Root:/home/test/resin/
Conf:/etc/resin. xml

Single resin instance
This example shows a single server site that listens to the standard http port 80 and runs as the resin user. In this example, watchdog runs as a root user, so it can be bound to a special port 80, but the resin instance runs as a resin.

Because the default configuration is used, watchdog listens on port 6600 to obtain the command.
Example:/etc/resin. xml

<Resin xmlns = "http://caucho.com/ns/resin">
<Cluster id = "">

<Server id = "app-a" address = "127.0.0.1">
<User-Name> resin </user-Name>
<Group-Name> resin </group-Name>

<Http port = "80"/>
</Server>

<Resin: Import Path = "$ {resin. Home}/CONF/app-default.xml"/>

<Host ID = "">
<Web-app id = "" Path = "/var/www/htdocs"/>
</Host>

</Cluster>
</Resin>

Load Balancing using a shared watchdog on a machine
When multiple resin instances are run on one machine, one watchdog-manager can manage all the resin instances. Specify the server ID to determine whether the resin instance is start or stop.
In this example, there is a Web-tier server as a Load balancer. Two app-tier servers process Background Data on one machine. To facilitate maintenance and upgrade, multiple app-rier servers may be required for one site. When a server is down, the second server can continue to serve.
In this example, the default watchdog configuration is used to read the standard resin. xml file. Both the watchdog process and resinboot read the resin. xml configuration file, so no special watchdog configuration is required. Watchdog can automatically discover and manage multiple resin instances running on this machine.

Example:/etc/resin. xml

<Resin xmlns = "http://caucho.com/ns/resin">

<Cluster id = "app-tier">

<Server-default>
<User-Name> resin </user-Name>
<Group-Name> resin </group-Name>
</Server-default>

<Server id = "app-a" address = "192.168.1.10" Port = "6810"/>
<Server id = "app-B" address = "192.168.1.10" Port = "6811"/>

<Host ID = "">
<Web-app id = "" Path = "/var/www/htdocs"/>
</Host>

</Cluster>

<Cluster id = "Web-tier">

<Server-default>
<User-Name> resin </user-Name>
<Group-Name> resin </group-Name>
</Server-default>

<Server id = "Web-a" address = "192.168.1.10" Port = "6800">
<Http port = "80"/>
</Server>

<Host ID = "">
<Web-app id = "">
<Rewrite-redirect>
<Load-balance Regexp = "" cluster = "app-tier"/>
</Rewrite-redirect>
</Web-app>
</Host>

</Cluster>

</Resin>

The same machine uses different watchdog to achieve Load Balancing
In some cases, it is recommended that each resin instance have its own watchdog, for example, when multiple users are using the same machine. Each <Server> block is configured with a <watchdog-port>. Because watchdog will read resin. xml and use the <Server> block to match the-server ID in the command line parameters, Each watchdog will start its own port during the startup period.

Example:/etc/resin. xml

<Resin xmlns = "http://caucho.com/ns/resin">

<Cluster id = "app-tier">

<Server-default>
<User-Name> resin </user-Name>
<Group-Name> resin </group-Name>
</Server-default>

<Server id = "app-a" address = "192.168.1.10" Port = "6810">
& Lt; watchdog-Port & gt; 6700 & lt;/watchdog-Port & gt;

<Http port = "8080" type = "codeph" text = "codeph"/>
</Server>

<Server id = "app-B" address = "192.168.1.10" Port = "6811">
& Lt; watchdog-Port & gt; 6701 & lt;/watchdog-Port & gt;

<Http port = "8081" type = "codeph" text = "codeph"/>
</Server>

<Host ID = "">
<Web-app id = "" Path = "/var/www/htdocs"/>
</Host>

</Cluster>

</Resin>

In the preceding example, start resin and use the-server app-a parameter to start a watchdog on port 6700, use the-server app-B parameter to start a watchdog at Port 6701.

Example: Starting app-B with watchdog-Port = 6701

Resin-3.2.x> JAVA-jar lib/resin. jar-server app-B Start

ISP watchdog Management
In the ISP environment, you may need to use an isolated configuration file for watchdog, which starts resin instances for different users. In this case, make sure that watchdog. xml cannot be read by these common users. Create a management user to read the file.

● Start and restart your resin JVM
● Set JVM parameters and Java Enforceability
● Set the root-directory of the resin instance
● Setuid user-Name and group-name
● Set resin. xml configuration
● Open a protected port, such as 80
● Optional chroot settings

Watchdog uses the given account as the setuid to start the resin instance. It can also open any required protection port, such as 80.
Example:/etc/resin/watchdog. xml

<Resin xmlns = "http://caucho.com/ns/resin">

<Management>
<User name = "Harry" Password = "md5hash ="/>
</Management>

<Watchdog-Manager>

<Watchdog-default>
<JVM-Arg>-xmx256m </JVM-Arg>
</Watchdog-default>

<Watchdog id = "user_1">
<User-Name> user_1 </user-Name>
<Group-Name> group_1 </group-Name>

<Resin-XML>/home/user_1/CONF/resin. xml </resin-conf>
<Resin-root>/home/user_1/WWW </resin-root>

<Open-port address = "192.168.1.10" Port = "80"/>
</Watchdog>

...

<Watchdog id = "user_n">
<User-Name> user_n </user-Name>
<Group-Name> group_n </group-Name>

<Resin-conf>/home/user_n/CONF/resin. xml </resin-conf>
<Resin-root>/home/user_n/WWW </resin-root>

<Open-port address = "192.168.1.240" Port = "80"/>
</Watchdog>

</Watchdog-Manager>

</Resin>

 

Article from: http://www.163jsp.com/main/helpcontent.jsp? Id = f9b4523e1eb63bd9011eca0aadb90a08

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.