如果網域或節點代理程式意外停止 (例如,您需要重新啟動機器),您可以將系統配置為自動重新啟動網域或節點代理程式。
本附錄包含下列主題:
若要在 UNIX 平台上重新啟動網域,請在 /etc/inittab 檔案中增加一行文字。
例如,若要重新啟動安裝在 opt/SUNWappserver 目錄中的 Application Server 之 domain1,請使用名為 password.txt 的密碼檔案:
das:3:respawn:/opt/SUNWappserver/bin/asadmin start-domain --user admin --passwordfile /opt/SUNWappserver/password.txt domain1 |
將這些文字放在一行上。前三個字母是程序的唯一指示符,可以進行更改。
重新啟動節點代理程式的語法與此相似。例如,若要重新啟動安裝在 opt/SUNWappserver 目錄中的 Application Server 之 agent1,請使用名為 password.txt 的密碼檔案:
das:3:respawn:/opt/SUNWappserver/bin/asadmin start-node-agent --user admin --passwordfile /opt/SUNWappserver/password.txt agent1 |
若要在 Microsoft Windows 上自動重新啟動,請建立一個 Windows 服務。將 Sun Java System Application Server 隨附的 appservService.exe 和 appserverAgentService.exe 可執行檔與 Microsoft 提供的服務控制指令 (sc.exe) 配合使用。
Windows XP 隨附了 sc.exe 指令,該指令位於 C:\windows\system32 目錄或 C:\winnt\system32 目錄。編寫本文件時,已可以從 http:// ftp://ftp.microsoft.com/reskit/win2000/sc.zip 下載 Windows 2000 sc.exe。如需有關使用 sc.exe 的更多資訊,請參閱 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndllpro/html/msdn_scmslite.asp。
使用 appservService.exe 和 appservAgentService.exe,如下所示:
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"
例如,若要建立可以啟動和停止網域 domain1 的名為 SunJavaSystemAppServer DOMAIN1 的服務,請使用密碼檔案 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"
若要建立可以啟動和停止節點代理程式 agent1 的服務,請使用:
C:\windows\system32\sc.exe create agent1 binPath= "C:\Sun\AppServer\lib\appservAgentService.exe \"C:\Sun\AppServer\bin\asadmin.bat start-node-agent --user admin --passwordfile C:\Sun\AppServer\password.txt agent1\" \"C:\Sun\AppServer\bin\asadmin.bat stop-node-agent agent1\"" start= auto DisplayName= "SJESAS_SE8.1 AGENT1"
做為 binPath= 參數的一部分而輸入的啟動和停止指令必須具有正確的語法。請在指令提示符號下執行這些指令以進行測試。如果指令無法正確啟動或停止網域或節點代理程式,則說明該服務無法正常工作。
請勿將服務與 asadmin start 和 stop 指令混合使用來進行啟動和停止。否則,將導致伺服器狀態不同步。例如,即使元件沒有執行,該服務可能也會顯示已啟動元件。為避免發生這種情況,請在使用服務時始終使用 sc.exe 指令啟動和停止元件。
當按以下方式之一啟動時,需要輸入所需的密碼和主密碼:
在 Microsoft Windows 上,將服務配置為要求使用者輸入密碼。
在 [服務] 控制台中,按兩下您所建立的服務。
在 [特性] 視窗中,按一下 [登入] 標籤。
核取 [允許服務與桌面互動],以在啟動元件時提示輸入所需的密碼。
必須登入才能看到提示,鍵入的項目不會在螢幕上顯示出來。如果選擇使用服務,這種方法最為安全,但需要進行使用者互動才能啟動服務。
如果未設定 [與桌面互動] 選項,服務將保持「啟動擱置」狀態,並且將顯示為掛機。中止該服務程序即可從此狀態中恢復。
在 Windows 或 UNIX 上,使用 --savemasterpassword=true 選項建立網域,並建立儲存管理員密碼的密碼檔案。啟動元件時,使用 --passwordfile 選項指向包含密碼的檔案。
例如︰
建立具有已儲存主密碼的網域。在下面的語法中,系統將提示您輸入管理員密碼和主密碼:
asadmin create-domain --adminport 4848 --adminuser admin --savemasterpassword=true --instanceport 8080 domain1 |
在 Windows 上,建立使用密碼檔案的服務,以填入管理員密碼:
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"
密碼檔案 password.txt 的路徑為 C:\Sun\AppServer\password.txt。該檔案包含以下格式的密碼
AS_ADMIN_password=password
例如,對於密碼 adminadmin:
AS_ADMIN_password=adminadmin
在 UNIX 上,請使用為 inittab 檔案增加的行中的 --passwordfile 選項:
das:3:respawn:/opt/SUNWappserver/bin/asadmin start-domain --user admin --passwordfile /opt/SUNWappserver/password.txt domain1 |
密碼檔案 password.txt 的路徑為 /opt/SUNWappserver/password.txt。該檔案包含以下格式的密碼
AS_ADMIN_password=password
例如,對於密碼 adminadmin:
AS_ADMIN_password=adminadmin