Sun Java System Application Server Platform Edition 9 Administration Guide
この本のみを検索
PDF 文書ファイルをダウンロードする (1637 KB)

Chapter 20 Automatically Restarting a Domain

If your domain is stopped unexpectedly (for example, if you need to restart your machine), you can configure your system to automatically restart the domain.

This Appendix contains the following topics:

Restarting Automatically on UNIX Platforms

To restart your domain on a UNIX platform, add a line of text to the /etc/inittab file.

If you use /etc/rc.local, or your system’s equivalent, place a line in /etc/rc.local that calls the desired asadmin command.

For example, to restart domain1 for an Application Server installed in the opt/SUNWappserver directory, using a password file called password.txt:


das:3:respawn:/opt/SUNWappserver/bin/asadmin start-domain --user admin 
--passwordfile /opt/SUNWappserver/password.txt domain1

Put the text on one line. The first three letters are a unique designator for the process and can be altered.

Restarting Automatically on the Microsoft Windows Platform

To restart automatically on Microsoft Windows, create a Windows Service. Use the appservService.exe and appserverAgentService.exe executable files shipped with the Sun Java System Application Server in conjunction with the Service Control command (sc.exe) provided by Microsoft.

The sc.exe command comes with Windows XP and is either located in the C:\windows\system32 directory or C:\winnt\system32 directory.

For more information on using sc.exe, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndllpro/html/msdn_scmslite.asp.

Use appservService.exe and appservAgentService.exe as follows:

C:\winnt\system32\sc.exe create service-name binPath= \"fully-qualified-path-to-appservService.exe 
\"fully-qualified-path-to-asadmin.bat start-command\" 
\"fully-qualified-path-to-asadmin.bat stop-command\"" 
start= auto DisplayName= "display-name"

For example, to create a service called SunJavaSystemAppServer DOMAIN1 that starts and stops the domain domain1, using a password file C:\Sun\AppServer\password.txt:

C:\windows\system32\sc.exe create domain1 binPath= 
"C:\Sun\AppServer\lib\appservService.exe \"C:\Sun\AppServer\bin\asadmin.bat 
start-domain --user admin --passwordfile C:\Sun\AppServer\password.txt domain1\" 
\"C:\Sun\AppServer\bin\asadmin.bat stop-domain domain1\"" start= auto 
DisplayName= "SunJavaSystemAppServer DOMAIN1"

Note –

The start and stop commands entered as part of the binPath= parameter must have the correct syntax. To test, run the commands from the command prompt. If the commands do not properly start or stop the domain, the service does not work correctly.



Note –

Don’t use a mixture of asadmin start and stop commands and service start and stops. Mixing the two can cause the server status to be out of sync. For example, the service might not show that the component has started even though the component is not running. To avoid this situation, always use the sc.exe command to start and stop the component when using services.


Security for Automatic Restarts

Handle the password and master password required when starting in one of the following ways:

  • On Microsoft Windows, configure the service to ask the user for the password.

    1. In the Services Control Panel, double-click the service you created.

    2. In the Properties window, click the Log On tab.

    3. Check “Allow service to interact with desktop” to prompt for the required passwords when starting the component.

      You have to log in to see the prompts, and entries are not echoed back as you type them. This method is the most secure way to use the services option, but user interaction is required before the service becomes available.

      If the “interact with desktop” option is not set, the service stays in a “start-pending” state and appears to hang. Kill the service process to recover from this state.

  • On Windows or UNIX, create a domain using the --savemasterpassword=true option and create a password file to store the admin password. When starting the component, use the --passwordfile option to point to the file that contains the password. The admin password can also be added by using the --password option of the asadmin start command. Be aware that this method is less secure because the admin password is stored in clear text.

    For example:

    1. Create domain with a saved master password. In this syntax, you are prompted for the admin password and master password:


      asadmin create-domain --adminport 4848 --adminuser admin 
      --savemasterpassword=true --instanceport 8080 domain1
    2. On Windows, create a service using a password file to populate the admin password:

      C:\windows\system32\sc.exe create domain1 binPath= 
      "C:\Sun\AppServer\lib\appservService.exe \"C:\Sun\AppServer\bin\asadmin.bat 
      start-domain --user admin --passwordfile C:\Sun\AppServer\password.txt domain1\" 
      \"C:\Sun\AppServer\bin\asadmin.bat stop-domain domain1\"" start= auto 
      DisplayName= "SJESAS_PE8.1 DOMAIN1"

      The path to the password file password.txt is C:\Sun\AppServer\password.txt. It contains the password in the following format

      AS_ADMIN_password=password

      For example, for a password adminadmin:

      AS_ADMIN_password=adminadmin

    3. On UNIX, use the --passwordfile option in the line you add to the inittab file:


      das:3:respawn:/opt/SUNWappserver/bin/asadmin start-domain --user admin 
      --passwordfile /opt/SUNWappserver/password.txt domain1

      The path to the password file password.txt is /opt/SUNWappserver/password.txt. It contains the password in the following format

      AS_ADMIN_password=password

      For example, for a password adminadmin:

      AS_ADMIN_password=adminadmin

  • Creating a service using a password that is populated from a command line option:

    C:\windows\system32\sc.exe create domain1 binPath= 
    "C:\Sun\AppServer\lib\appservService.exe \"C:\Sun\AppServer\bin\asadmin.bat 
    start-domain --user admin --password adminadmin domain1\" 
    \"C:\Sun\AppServer\bin\asadmin.bat stop-domain domain1\"" start= auto 
    DisplayName= "SJESAS_PE8.1 DOMAIN1"

Executing Local Admin CLI Commands without Admin Password

Sun Java System Application Server supports three local commands for which the administrator password need not be specified in clear text anymore. Instead the admin password can be defined as an alias in the passwordfile. The asadmin command invokes this passwordfile through "--passwordfile" option. This feature is also useful when a domain or a server has to be automatically restarted. The commands currently supported by this feature are start-domain, start-appserv, and start-node-agent.

手順To create the password alias

  1. Ensure that the domain is running.

  2. Create the alias for the admin user. To do this, from the directory where the domain.xml file resides (install_dir/domains/domain_dir/config by default), run the following asadmin command:

    create-password-alias --port 4848 --user admin --password adminadmin --aliaspassword adminadmin adminalias

  3. Insert the alias in a passwordfile

    $cat passwordfile

    AS_ADMIN_PASSWORD=${ALIAS=adminalias}


Example 20–1 for start-domain

Here's an example of the start-domain command used with the password alias.

asadmin start-domain --user admin --passwordfile passwordfile domain1