您可以使用“安装前执行脚本”功能来配置CCE集群节点(弹性云服务器ECS),配置方法请参见创建集群-高级配置。
在使用“安装前执行脚本”功能前,请预先编写一个可以格式化数据盘的脚本(该脚本需以root用户执行)。
输入参数:
在“安装前执行脚本”中执行以下命令来实现格式化能力:
cd /tmp;curl -k -X GET OBS的地址/formatdisk.sh -1 -O;fdisk -l;sleep 30;bash -x formatdisk.sh 100 /data/code;fdisk -l
formatdisk.sh脚本示例如下:
dockerdisksize=$1 mountdir=$2 systemdisksize=40 i=0 while [ 20 -gt $i ]; do echo $i; if [ $(lsblk -o KNAME,TYPE | grep disk | grep -v nvme | awk '{print $1}' | awk '{ print "/dev/"$1}' |wc -l) -ge 3 ]; then break else sleep 5 fi; i=$[i+1] done all_devices=$(lsblk -o KNAME,TYPE | grep disk | grep -v nvme | awk '{print $1}' | awk '{ print "/dev/"$1}') for device in ${all_devices[@]}; do isRawDisk=$(lsblk -n $device 2>/dev/null | grep disk | wc -l) if [[ ${isRawDisk} > 0 ]]; then # is it partitioned ? match=$(lsblk -n $device 2>/dev/null | grep -v disk | wc -l) if [[ ${match} > 0 ]]; then # already partited [[ -n "${DOCKER_BLOCK_DEVICES}" ]] && echo "Raw disk ${device} has been partition, will skip this device" continue fi else isPart=$(lsblk -n $device 2>/dev/null | grep part | wc -l) if [[ ${isPart} -ne 1 ]]; then # not parted [[ -n "${DOCKER_BLOCK_DEVICES}" ]] && echo "Disk ${device} has not been partition, will skip this device" continue fi # is used ? match=$(lsblk -n $device 2>/dev/null | grep -v part | wc -l) if [[ ${match} > 0 ]]; then # already used [[ -n "${DOCKER_BLOCK_DEVICES}" ]] && echo "Disk ${device} has been used, will skip this device" continue fi isMount=$(lsblk -n -o MOUNTPOINT $device 2>/dev/null) if [[ -n ${isMount} ]]; then # already used [[ -n "${DOCKER_BLOCK_DEVICES}" ]] && echo "Disk ${device} has been used, will skip this device" continue fi isLvm=$(sfdisk -lqL 2>>/dev/null | grep $device | grep "8e.*Linux LVM") if [[ ! -n ${isLvm} ]]; then # part system type is not Linux LVM [[ -n "${DOCKER_BLOCK_DEVICES}" ]] && echo "Disk ${device} system type is not Linux LVM, will skip this device" continue fi fi block_devices_size=$(lsblk -n -o SIZE $device 2>/dev/null | awk '{ print $1}') if [[ ${block_devices_size}"x" != "${dockerdisksize}Gx" ]] && [[ ${block_devices_size}"x" != "${systemdisksize}Gx" ]]; then echo "n p 1 w " | fdisk $device mkfs -t ext4 ${device}1 mkdir -p $mountdir uuid=$(blkid ${device}1 |awk '{print $2}') echo "${uuid} $mountdir ext4 noatime 0 0" | tee -a /etc/fstab >/dev/null mount $mountdir fi done
如果直接拷贝上方示例不能正常执行,请使用dos2unix工具进行格式转换。
本文介绍共享型实例规格族的特点,并列出了具体的实例规格。 共享标准型实例规格...
大家好,我是冰河~~ 今天,我们一起来讲讲线程的执行顺序,可能与你想象的不一样...
调用StopGWSInstance停止一个可视化实例。 调试 您可以在OpenAPI Explorer中直接...
TOP云 (west.cn)3月9日消息,最近新顶级 域名 fly.info在国内外曝光率颇高,不...
操作场景 本文以 云服务器 的操作系统为“CentOS 7.4 64位”为例,采用初始化数...
文章来源 雷锋网 作者 杨丽 原标题 《独家解读 阿里云原生应用的布局与策略》 原...
服务器租用 是指用户只需根据自己业务的需要,提出对硬件配置的要求,主机服务器...
数据分析,包括大数据分析,在企业的业务中,特别是在传统的商务行业,已有多年...
1. 接口描述 接口请求域名: cvm.tencentcloudapi.com 。 本接口(DeleteImages...
功能介绍 接口名称 RestartCloudPhone 功能描述 批量重启云手机,也可用于开启云...