createDnodeStorage.sh 2.1 KB
Newer Older
P
plum-lihui 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
#!/bin/bash
#
# setup test environment

set -e
#set -x

# set parameters by default value
dataRootDir="/data/dockerbuilder/storage"
dnodeNumber=1
firstEp="node1:6030"

while getopts "hn:r:f:" arg
do
  case $arg in
    n)
      dnodeNumber=$(echo $OPTARG)
      ;;
    f)
      firstEp=$(echo $OPTARG)
      ;;
    r)
      dataRootDir=$(echo $OPTARG)
      ;;
    h)
      echo "Usage: `basename $0` -n [ dnode number] "
      echo "                  -n [ dnode number] "
      echo "                  -f [ first ep] "
      echo "                  -r [ data root dir] "
      exit 0
      ;;
    ?) #unknow option
      echo "unkonw argument"
      exit 1
      ;;
  esac
done

echo "dnodeNumber=${dnodeNumber} dataRootDir=${dataRootDir} firstEp=${firstEp}"

createTaosCfg() {
    cfgFile=$1/cfg/taos.cfg
    #dataDir=$1/data
    #logDir=$1/log
    firstEp=$2    
    fqdn=$3
    
    echo "debugFlag     131"             > ${cfgFile}
    echo "firstEp       ${firstEp}"     >> ${cfgFile}
    #echo "dataDir       ${dataDir}"     >> ${cfgFile}
    #echo "logDir        ${logDir}"      >> ${cfgFile}
    echo "fqdn          ${fqdn}"        >> ${cfgFile}     
    
    echo "supportVnodes        1024"   >> ${cfgFile} 
    echo "asyncLog             0"     >> ${cfgFile}
    echo "telemetryReporting   0"      >> ${cfgFile}  
}

createDnodesDataDir() {
    if [ -d ${dataRootDir} ]; then
        rm -rf ${dataRootDir}/*
    else
        echo "${dataRootDir} not exist"
        exit 1
    fi
    
    dnodeNumber=$1
    firstEp=$2
    
    serverPort=${startPort}
    for ((i=1; i<=${dnodeNumber}; i++)); do
        mkdir -p ${dataRootDir}/dnode${i}/cfg
        mkdir -p ${dataRootDir}/dnode${i}/log
        mkdir -p ${dataRootDir}/dnode${i}/data
        mkdir -p ${dataRootDir}/dnode${i}/core  
        
        createTaosCfg ${dataRootDir}/dnode${i} ${firstEp} node${i}
    done
}

########################################################################################
###############################  main process ##########################################

## create director and taos.cfg for all dnode
createDnodesDataDir ${dnodeNumber} ${firstEp}

echo "====create end===="
echo " "