1.查看当前计算节点命名方式如下
[[email protected] ~]# rocks list host
HOST MEMBERSHIP CPUS RACK RANK RUNACTION INSTALLACTION
cluster: Frontend 1 0 0 os install
compute-0-0: Compute 1 0 0 os install
compute-0-1: Compute 1 0 1 os install
2.现在要把compute-0-*更改为node*,步骤如下
◆在任何路径下,创建一个名为ReName.sh的脚本,内容如下
[[email protected] AddHost]# cat ReName.sh
#!/bin/bash ORDER=0 SUM=2 //共有多少个节点 NEW=1 ## while [ $ORDER -lt "$SUM" ]; do rocks set host name compute-0-$ORDER node$NEW; rocks set host interface name node$NEW eth0 node$NEW; let ORDER++; let NEW++; done # # ##Sync Config rocks sync config # # SUM=2 NEW=1 # ##Set For hosts file for i in `seq $NEW $SUM`;do ssh node$i sed -i -e "s/compute-0-.*.local/node$i.local/g" -e "s/compute-0-.*/node$i/g" /etc/hosts;done # for i in `seq $NEW $SUM`;do ssh node$i hostname node$i.local;done # for i in `seq $NEW $SUM`;do ssh node$i sed -i "/HOSTNAME/c\HOSTNAME=node$i.local" /etc/sysconfig/network;done
注:脚本内容根据实际情况更改
例如:现在共有10个节点,现在需要把compute-0-0到compute-0-9,重命名为node1到node10,步骤如下
1.脚本中需要更改的地方共两处,具体位置请看注释
[[email protected] AddHost]# cat ReName.sh
#!/bin/bash ORDER=0 SUM=10 //更改此处节点数 NEW=1 ## while [ $ORDER -lt "$SUM" ]; do rocks set host name compute-0-$ORDER node$NEW; rocks set host interface name node$NEW eth0 node$NEW; let ORDER++; let NEW++; done # # ##Sync Config rocks sync config # # SUM=10 //这个地方也要改 NEW=1 # ##Set For hosts file for i in `seq $NEW $SUM`;do ssh node$i sed -i -e "s/compute-0-.*.local/node$i.local/g" -e "s/compute-0-.*/node$i/g" /etc/hosts;done # for i in `seq $NEW $SUM`;do ssh node$i hostname node$i.local;done # for i in `seq $NEW $SUM`;do ssh node$i sed -i "/HOSTNAME/c\HOSTNAME=node$i.local" /etc/sysconfig/network;done
2.执行该脚本即可
[[email protected] AddHost]# sh ReName.sh
时间: 2024-11-08 21:56:16