文档

在使用了本地盘的弹性裸金属服务器实例上安装监控插件

更新时间:

本文介绍了安装监控插件xdragon_hardware_detect_plugin的方式,适用于使用了本地盘的弹性裸金属服务器实例。

前提条件

待安装监控插件的弹性裸金属服务器实例必须满足以下条件:

  • 所在地域为中国北京、中国上海、中国杭州、中国深圳或者中国张家口地域。

  • 操作系统为Linux系统。

  • 仅使用OOS批量安装监控插件:如果您根据标签匹配弹性裸金属服务器实例目标,目标实例必须已经绑定了标签。详细步骤请参见创建或绑定标签

  • 已安装云助手客户端。具体操作,请参见安装云助手Agent

    说明

    2017年12月01日之后使用公共镜像创建的ECS实例,默认预装云助手Agent。

背景信息

如果您使用的是搭载了本地盘的弹性裸金属服务器实例规格,需要您自行监控和诊断本地盘健康状态。

插件xdragon_hardware_detect_plugin可以定期检测弹性裸金属服务器实例上的本地盘设备的健康状态,如果发生本地盘异常事件,插件会自动将异常事件反馈成本地盘系统事件。对应的系统事件代码为SystemMaintenance.ReInitErrorDisk。详情请参见本地盘实例运维场景和系统事件

使用OOS批量安装监控插件

运维编排服务OOS能通过公共模板自动安装监控插件xdragon_hardware_detect_plugin。

  1. 登录OOS管理控制台

  2. 在页面左侧顶部,选择目标资源所在的资源组和地域。地域

  3. 在左侧导航栏,选择自动化任务 > 公共任务模板,输入ACS-ECS-InstallXDragonAndCloudMonitor搜索批量安装神龙监控插件的模板,单击创建执行

    批量安装神龙监控插件-创建执行

  4. 创建执行的对话框中,完成以下配置:

    1. 基本信息步骤中,执行模式选择自动执行,其他配置保持系统默认。完成后单击下一步:设置参数

    2. 设置参数步骤中,完成以下配置,其他配置保持系统默认,完成后单击下一步:确定

      • 操作类型:选择install,即安装插件。

        说明

        该运维模板同时支持安装、更新和卸载监控插件,您可以根据自身需要选择运维任务类型。

      • 目标实例:选择一台或多台需要轮询并安装监控插件的弹性裸金属服务器实例。

      • 任务执行的并发比率:选择并发控制并发速率选择百分制,并设置为100 %。

      批量安装神龙监控插件-创建执行

    3. 确认模板配置信息后,单击创建

    创建了运维任务后,您可以在执行管理页面查看运维任务的结果。

    • 执行状态显示成功,表示运维任务已完成。

    • 执行状态显示失败,您可以单击操作列下的详情查看执行日志,并根据日志信息分析和调整执行内容。

手动安装监控插件

云助手客户端提供的aliyun_installer工具可以下载并安装监控插件xdragon_hardware_detect_plugin。

  1. 以root权限远程连接弹性裸金属服务器实例。

  2. (可选)运行aliyun_installer -h查看工具帮助信息。

  3. 使用aliyun_installer命令安装监控插件xdragon_hardware_detect_plugin。

    aliyun_installer -i xdragon_hardware_detect_plugin -e 1.0.0
  4. 保存并运行安装特殊版本云监控插件的Shell脚本。Shell脚本请参见下文脚本示例

    bash <nameOfTheScript>.sh
    说明

    安装监控插件xdragon_hardware_detect_plugin的步骤必须先于云监控插件,若您先安装了云监控插件,请执行/usr/local/cloudmonitor/CmsGoAgent.linux-amd64 restart重启云监控插件。

  5. 执行smartctl -V检测实例是否已安装本地盘监控和分析工具smartctl。

    如果返回信息中显示工具版本号,表示实例已安装smartctl工具。

  6. (可选)如果实例未安装smartctl工具,按以下方式安装:

    • CentOS系统:

      yum install smartmontools
    • Ubuntu系统:

      apt update &&  apt install smartmontools
    • 其他Linux发行版安装方式,请参见smartmontools相关文档

手动安装特殊版本云监控插件的Shell脚本如下所示:

#!/bin/bash
echo "installing cms agent"

if [ -z "${CMS_HOME}" ]; then
  CMS_HOME="/usr/local/cloudmonitor"
  [[ ! -z "`egrep -i coreos /etc/os-release`" ]] && CMS_HOME="/opt/cloudmonitor"
fi

if [ `uname -m` = "x86_64" ]; then
    ARCH="amd64"
else
    ARCH="386"
fi

VERSION="2.1.57"
ELF_NAME=CmsGoAgent.linux-${ARCH}
DOWNLOAD_PATH="cms-go-agent/${VERSION}/${ELF_NAME}"
DEST_UPDATE_FILE="$CMS_HOME/${ELF_NAME}"

current_cms_version="0"
# xdragon always x86 arch, judge version
if [ -f /usr/local/cloudmonitor/CmsGoAgent.linux-amd64 ]; then
    current_cms_version="$($DEST_UPDATE_FILE version)"
fi

if [ $current_cms_version = "2.1.57" ]; then
    echo "CmsGoAgent already installed"
    echo "Installation success."
    exit 0
fi

if [ -z "${REGION_ID}" ]; then
  REGION_ID="$(wget -q --timeout=1 -t 1 -O - 'http://100.100.100.200/latest/meta-data/region-id')"
fi


if [ -d $CMS_HOME ] ; then
  if [ -f $CMS_HOME/wrapper/bin/cloudmonitor.sh ] ; then
    $CMS_HOME/wrapper/bin/cloudmonitor.sh remove;
    rm -rf $CMS_HOME;
  elif [ -f $DEST_UPDATE_FILE ]; then
    $DEST_UPDATE_FILE stop
    #$DEST_UPDATE_FILE uninstall
    ps aux | grep -v grep | grep $ELF_NAME
  fi
fi

download()
{
  if [ -z "${REGION_ID}" ]; then
    echo "networkType is classic"
    OSS_URL="http://cms-agent-cn-hangzhou.oss-cn-hangzhou-internal.aliyuncs.com/$DOWNLOAD_PATH"
  else
    echo "networkType is vpc, REGION_ID: $REGION_ID"
    if [[ "$REGION_ID" = "cn-shenzhen-finance-1" ]]; then
      OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"
      CMS_PROXY="szcmsproxy.aliyun.com:3128"
    elif [[ "$REGION_ID" = "cn-shanghai-finance-1" ]]; then
      OSS_URL="http://cms-agent-$REGION_ID.oss-$REGION_ID-pub-internal.aliyuncs.com/$DOWNLOAD_PATH"
    elif [[ "$REGION_ID" = "ap-south-1" ]]; then
      OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"
      CMS_PROXY="cmsproxy-ap-south-1.aliyuncs.com:8080"
    elif [ "$REGION_ID" = "ap-southeast-3" -o "$REGION_ID" = "me-east-1" -o "$REGION_ID" = "cn-chengdu" ]; then
      OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"
    else
      OSS_URL="http://cms-agent-$REGION_ID.oss-$REGION_ID-internal.aliyuncs.com/$DOWNLOAD_PATH"
    fi
  fi
  echo download from "$OSS_URL"
  wget -q -e "http_proxy=$CMS_PROXY" "$OSS_URL" -O "$DEST_UPDATE_FILE" -t 3 --connect-timeout=2
  if [ $? != 0 ]; then
    echo "download fail, retry..."
    CMS_PROXY="vpc-opencmsproxy.aliyun.com:8080";
    OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"
    wget -q -e "http_proxy=$CMS_PROXY" "$OSS_URL" -O "$DEST_UPDATE_FILE" -t 3 --connect-timeout=2
  fi
  if [ $? != 0 ]; then
    echo "download fail, retry..."
    CMS_PROXY="opencmsproxy.aliyun.com:8080";
    OSS_URL="http://cms-download.aliyun.com/$DOWNLOAD_PATH"
    wget -q -e "http_proxy=$CMS_PROXY" "$OSS_URL" -O "$DEST_UPDATE_FILE" -t 3 --connect-timeout=2
  fi
}

mkdir -p $CMS_HOME && \
chown -R root:root $CMS_HOME && \
download && \
chmod a+x $DEST_UPDATE_FILE
$DEST_UPDATE_FILE check
RC=$?
if [ ${RC} -ne 0 ]; then
    echo CmsGoAgent install failed, your platform is not supported
    exit ${RC}
fi

$DEST_UPDATE_FILE install >/dev/null 2>&1 || true
$DEST_UPDATE_FILE start
ps aux | grep -v grep | grep $ELF_NAME

ACT_VERSION=`$DEST_UPDATE_FILE version`
if [ -n "$ACT_VERSION" ]; then
    echo CmsGoAgent v$ACT_VERSION installed
else
    echo CmsGoAgent install failed
    exit 1
fi

执行结果

安装后,监控插件xdragon_hardware_detect_plugin所在目录为/usr/local/xdragon_hwqc。更新插件可执行aliyun_installer -d xdragon_hardware_detect_plugin,卸载插件可执行aliyun_installer -u xdragon_hardware_detect_plugin

后续步骤

您可以调用ECS API隔离损坏的本地盘,隔离后,弹性裸金属服务器实例不会变更所宿物理机。详情请参见本地盘实例系统事件

  • 本页导读 (1)
文档反馈