Sun Cluster 資料服務開發者指南 (適用於 Solaris 作業系統)

驗證配置

為了作業,DNS 需要配置目錄內 named.conf 檔案的資訊。因此,在嘗試啟動 DNS 之前,Start 方法將執行某些正常性檢查,以驗證目錄和檔案是否可存取。

Confdir 延伸特性提供配置目錄的路徑。特性本身定義在 RTR 檔案中。但是,當叢集管理員配置資料服務時,會指定其實際位置。

在資料服務範例中,Start 方法透過使用 scha_resource_get() 函數擷取配置目錄的位置。


備註 –

由於 Confdir 是一個延伸特性,因此 scha_resource_get() 將傳回類型與值。awk 指令會擷取此值並將其放入 shell 變數 CONFIG_DIR 中。


# find the value of Confdir set by the cluster administrator at the time of
# adding the resource.
config_info=`scha_resource_get -O Extension -R $RESOURCE_NAME \
-G $RESOURCEGROUP_NAME Confdir`

# scha_resource_get returns the "type" as well as the "value" for the
# extension properties. Get only the value of the extension property 
CONFIG_DIR=`echo $config_info | awk '{print $2}'`

Start 方法使用 CONFIG_DIR 的值來驗證目錄是否可存取。如果不可存取,Start 會記錄錯誤訊息並以錯誤狀態結束。請參閱Start 退出狀態

# Check if $CONFIG_DIR is accessible.
if [ ! -d $CONFIG_DIR ]; then
   logger -p ${SYSLOG_FACILITY}.err \
         -t [$SYSLOG_TAG] \
         "${ARGV0} Directory $CONFIG_DIR is missing or not mounted"
   exit 1
fi

在啟動應用程式常駐程式之前,該方法將執行最後的檢查,以驗證 named.conf 檔案是否存在。如果檔案不存在,Start 會記錄一條錯誤訊息並以錯誤狀態結束。

# Change to the $CONFIG_DIR directory in case there are relative
# pathnames in the data files.
cd $CONFIG_DIR

# Check that the named.conf file is present in the $CONFIG_DIR directory
if [ ! -s named.conf ]; then
   logger -p ${SYSLOG_FACILITY}.err \
         -t [$SYSLOG_TAG] \
         "${ARGV0} File $CONFIG_DIR/named.conf is missing or empty"
   exit 1
fi