Solaris OS용 Sun Cluster 데이터 서비스 개발 안내서

SUNW.xfnts 오류 모니터

RGM은 PROBE 메소드를 직접 호출하지 않고 Monitor_start 메소드를 호출하여 노드에서 자원이 시작된 후 모니터를 시작합니다. xfnts_monitor_start 메소드는 PMF의 제어 하에서 오류 모니터를 시작합니다. xfnts_monitor_stop 메소드는 오류 모니터를 중지합니다.

SUNW.xfnts 오류 모니터는 다음 작업을 수행합니다.

xfonts_probe 주 루프

xfonts_probe 메소드는 루프를 구현합니다. 루프를 구현하기 전에 xfonts_probe는 다음 작업을 수행합니다.

xfnts_probe 메소드는 다음과 같이 루프를 구현합니다.

for (ip = 0; ip < netaddr->num_netaddrs; ip++) {
         /*
          * Grab the hostname and port on which the
          * health has to be monitored.
          */
         hostname = netaddr->netaddrs[ip].hostname;
         port = netaddr->netaddrs[ip].port_proto.port;
         /*
          * HA-XFS supports only one port and
          * hence obtain the port value from the
          * first entry in the array of ports.
          */
         ht1 = gethrtime(); /* Latch probe start time */
         scds_syslog(LOG_INFO, "Probing the service on port: %d.", port);

         probe_result =
         svc_probe(scds_handle, hostname, port, timeout);

         /*
          * Update service probe history,
          * take action if necessary.
          * Latch probe end time.
          */
         ht2 = gethrtime();

         /* Convert to milliseconds */
         dt = (ulong_t)((ht2 - ht1) / 1e6);

         /*
          * Compute failure history and take
          * action if needed
          */
         (void) scds_fm_action(scds_handle,
             probe_result, (long)dt);
      }   /* Each net resource */
   }    /* Keep probing forever */

svc_probe() 함수는 검사 논리를 구현합니다. svc_probe() 반환값이 scds_fm_action()으로 전달되고, 여기서 응용 프로그램을 다시 시작할지, 자원 그룹을 페일오버할지, 아니면 아무 작업도 수행하지 않을지 결정합니다.

svc_probe() 함수

svc_probe() 함수는 scds_fm_tcp_connect()를 호출하여 지정된 포트에 대한 간단한 소켓 연결을 설정합니다. 연결에 실패할 경우 svc_probe()는 완전한 실패를 나타내는 값 100을 반환합니다. 연결에 성공했지만 연결을 끊는 데 실패한 경우 svc_probe()는 부분적 실패를 나타내는 값 50을 반환합니다. 연결과 연결 끊기에 모두 성공한 경우 svc_probe()는 성공을 나타내는 값 0을 반환합니다.

svc_probe()의 코드는 다음과 같습니다.

int svc_probe(scds_handle_t scds_handle,
char *hostname, int port, int timeout)
{
   int  rc;
   hrtime_t   t1, t2;
   int    sock;
   char   testcmd[2048];
   int    time_used, time_remaining;
   time_t      connect_timeout;


   /*
    * probe the data service by doing a socket connection to the port
    * specified in the port_list property to the host that is
    * serving the XFS data service. If the XFS service which is configured
    * to listen on the specified port, replies to the connection, then
    * the probe is successful. Else we will wait for a time period set
    * in probe_timeout property before concluding that the probe failed.
    */

   /*
    * Use the SVC_CONNECT_TIMEOUT_PCT percentage of timeout
    * to connect to the port
    */
   connect_timeout = (SVC_CONNECT_TIMEOUT_PCT * timeout)/100;
   t1 = (hrtime_t)(gethrtime()/1E9);

   /*
    * the probe makes a connection to the specified hostname and port.
    * The connection is timed for 95% of the actual probe_timeout.
    */
   rc = scds_fm_tcp_connect(scds_handle, &sock, hostname, port,
       connect_timeout);
   if (rc) {
      scds_syslog(LOG_ERR,
          "Failed to connect to port <%d> of resource <%s>.",
          port, scds_get_resource_name(scds_handle));
      /* this is a complete failure */
      return (SCDS_PROBE_COMPLETE_FAILURE);
   }

   t2 = (hrtime_t)(gethrtime()/1E9);

   /*
    * Compute the actual time it took to connect. This should be less than
    * or equal to connect_timeout, the time allocated to connect.
    * If the connect uses all the time that is allocated for it,
    * then the remaining value from the probe_timeout that is passed to
    * this function will be used as disconnect timeout. Otherwise, the
    * the remaining time from the connect call will also be added to
    * the disconnect timeout.
    *
    */

   time_used = (int)(t2 - t1);

   /*
    * Use the remaining time(timeout - time_took_to_connect) to disconnect
    */

   time_remaining = timeout - (int)time_used;

   /*
    * If all the time is used up, use a small hardcoded timeout
    * to still try to disconnect. This will avoid the fd leak.
    */
   if (time_remaining <= 0) {
      scds_syslog_debug(DBG_LEVEL_LOW,
          "svc_probe used entire timeout of "
          "%d seconds during connect operation and exceeded the "
          "timeout by %d seconds. Attempting disconnect with timeout"
          " %d ",
          connect_timeout,
          abs(time_used),
          SVC_DISCONNECT_TIMEOUT_SECONDS);

      time_remaining = SVC_DISCONNECT_TIMEOUT_SECONDS;
   }

   /*
    * Return partial failure in case of disconnection failure.
    * Reason: The connect call is successful, which means
    * the application is alive. A disconnection failure
    * could happen due to a hung application or heavy load.
    * If it is the later case, don't declare the application
    * as dead by returning complete failure. Instead, declare
    * it as partial failure. If this situation persists, the
    * disconnect call will fail again and the application will be
    * restarted.
    */
   rc = scds_fm_tcp_disconnect(scds_handle, sock, time_remaining);
   if (rc != SCHA_ERR_NOERR) {
      scds_syslog(LOG_ERR,
          "Failed to disconnect to port %d of resource %s.",
          port, scds_get_resource_name(scds_handle));
      /* this is a partial failure */
      return (SCDS_PROBE_COMPLETE_FAILURE/2);
   }

   t2 = (hrtime_t)(gethrtime()/1E9);
   time_used = (int)(t2 - t1);
   time_remaining = timeout - time_used;

   /*
    * If there is no time left, don't do the full test with
    * fsinfo. Return SCDS_PROBE_COMPLETE_FAILURE/2
    * instead. This will make sure that if this timeout
    * persists, server will be restarted.
    */
   if (time_remaining <= 0) {
      scds_syslog(LOG_ERR, "Probe timed out.");
      return (SCDS_PROBE_COMPLETE_FAILURE/2);
   }

   /*
    * The connection and disconnection to port is successful,
    * Run the fsinfo command to perform a full check of
    * server health.
    * Redirect stdout, otherwise the output from fsinfo
    * ends up on the console.
    */
   (void) sprintf(testcmd,
       "/usr/openwin/bin/fsinfo -server %s:%d > /dev/null",
       hostname, port);
   scds_syslog_debug(DBG_LEVEL_HIGH,
       "Checking the server status with %s.", testcmd);
   if (scds_timerun(scds_handle, testcmd, time_remaining,
      SIGKILL, &rc) != SCHA_ERR_NOERR || rc != 0) {

      scds_syslog(LOG_ERR,
         "Failed to check server status with command <%s>",
         testcmd);
      return (SCDS_PROBE_COMPLETE_FAILURE/2);
   }
   return (0);
}

작업이 완료되면 svc_probe()는 성공(0), 부분적 실패(50) 또는 완전한 실패(100)를 나타내는 값을 반환합니다. xfnts_probe 메소드는 이 값을 scds_fm_action()에 전달합니다.

오류 모니터 작업 결정

xfnts_probe 메소드는 scds_fm_action()을 호출하여 수행할 작업을 결정합니다. scds_fm_action()의 논리는 다음과 같습니다.

예를 들어, 검사가 xfs 서버에 연결을 설정하지만 연결을 끊는 데 실패한다고 가정합니다. 이는 서버가 실행 중이지만 정지되거나 일시적으로 로드 상태가 될 수 있음을 나타냅니다. 연결을 끊는 데 실패하면 scds_fm_action()으로 부분적 실패 값( 50)을 보냅니다. 이 값은 데이터 서비스를 재시작하기 위한 임계값보다 작지만 실패 기록에서 유지 관리됩니다.

다음 검사 중에 서버가 연결 끊기에 다시 실패하면 scds_fm_action()에서 유지 관리하는 실패 기록에 값 50이 추가됩니다. 이제 누적 실패 값이 100이므로 scds_fm_action()이 데이터 서비스를 재시작합니다.