Rocks changing the computer point name

Source: Internet
Author: User

1. View the current compute node naming method as follows

[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. To change the compute-0-* to node* now, proceed as follows

Under any path, create a script named Rename.sh, which reads as follows

[email protected] addhost]# cat rename.sh

#!/bin/bashorder=0sum=2                                        //total number of nodes 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  configrocks sync config# #SUM =2new=1## #Set  for hosts  filefor i in  ' seq  $NEW   $SUM ';d o 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 ';d o ssh node$i hostname node$i.local;done# for i in  ' seq  $NEW &nbsp, $SUM ';d o ssh node$i sed -i  "/hostname/c\hostname=node$i.local"  /etc/ Sysconfig/network;done

Note: The script content changes according to the actual situation

For example: Now there are 10 nodes, now you need to compute-0-0 to compute-0-9, rename Node1 to Node10, the steps are as follows

1. There are two places in the script that need to be changed, please see the note for specific location

[email protected] addhost]# cat rename.sh

#!/bin/bashorder=0sum=10                                            //change the number of nodes here                         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  Configrocks sync  config# #SUM =10                                         //This place also needs to change new=1## #Set  For hosts filefor i in  ' seq  $NEW   $SUM ';d o  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 ';d o ssh  node$i hostname node$i.local;done#for i in  ' seq  $NEW   $SUM ';d o  ssh node$i sed -i  "/hostname/c\hostname=node$i.local"  /etc/sysconfig/network;done

2. Execute the script to

[Email protected] addhost]# sh rename.sh


This article is from the "Never Stop" blog, please be sure to keep this source http://wjcaiyf.blog.51cto.com/7105309/1690846

Rocks changing the computer point name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.