Sun Cluster 数据服务开发者指南(适用于 Solaris OS)

启动服务

xfnts_start 方法将调用 xfnts.c 中定义的 svc_start() 方法来启动 xfs 守护程序。 本节将介绍 svc_start ()

用来启动 xfs 守护程序的命令如下所示。


xfs -config config_directory/fontserver.cfg -port port_number

Confdir_list 扩展特性用来标识 config_directoryPort_list 系统特性用来标识 port_number。 群集管理员配置数据服务时,需要提供这些特性的具体值。

xfnts_start 方法将使用 scds_get_ext_confdir_list()scds_get_port_list() 函数将这些特性声明为字符串数组并获取管理员设置的值(在 scds_property_functions(3HA) 中进行介绍),如下所示。


scha_str_array_t *confdirs;
scds_port_list_t    *portlist;
scha_err_t   err;

   /* get the configuration directory from the confdir_list property */
   confdirs = scds_get_ext_confdir_list(scds_handle);

   (void) sprintf(xfnts_conf, "%s/fontserver.cfg", confdirs->str_array[0]);

   /* obtain the port to be used by XFS from the Port_list property */
   err = scds_get_port_list(scds_handle, &portlist);
   if (err != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Could not access property Port_list.");
      return (1);
   }

请注意,confdirs 变量指向该数组的第一个元素 (0)。

xfnts_start 方法使用 sprintf 组成 xfs 命令行,如下所示。


/* Construct the command to start the xfs daemon. */
   (void) sprintf(cmd,
       "/usr/openwin/bin/xfs -config %s -port %d 2>/dev/null",
       xfnts_conf, portlist->ports[0].port);

请注意,输出将重定向到 dev/null,以抑制该守护程序生成的消息。

xfnts_start 方法将把 xfs 命令行传送到 scds_pmf_start(),以在 PMF 控制下启动该数据服务,如下所示。


scds_syslog(LOG_INFO, "Issuing a start request.");
   err = scds_pmf_start(scds_handle, SCDS_PMF_TYPE_SVC,
      SCDS_PMF_SINGLE_INSTANCE, cmd, -1);

   if (err == SCHA_ERR_NOERR) {
      scds_syslog(LOG_INFO,
          "Start command completed successfully.");
   } else {
      scds_syslog(LOG_ERR,
          "Failed to start HA-XFS ");
   }

请注意以下几点关于对 scds_pmf_start() 进行调用的内容。

在返回之前,svc_pmf_start() 将释放为 portlist 结构分配的内存,如下所示。


scds_free_port_list(portlist);
return (err);