Skip to content

Instantly share code, notes, and snippets.

@jaohaohsuan
Last active December 13, 2016 06:13
Show Gist options
  • Select an option

  • Save jaohaohsuan/8d0189fe281c8da9fc0fa73325674729 to your computer and use it in GitHub Desktop.

Select an option

Save jaohaohsuan/8d0189fe281c8da9fc0fa73325674729 to your computer and use it in GitHub Desktop.

#改/etc/hosts

可精确改到原有hostname原来是指向127.0.0.1(lookback)的问题, 在建立ceph的osd node一定得改

原始/etc/hosts

127.0.0.1    node1 node1

变成

192.168.60.102    node1 node1

sed指令

sudo sed -i 's/^127\.0\.0\.1\(.*node1$\\)/192.168.60.102 \1/' /etc/hosts

剖析

  • -i直接替/etc/hosts文件
  • s/取代
  • ^127\.0\.0\.1\开头127.0.0.1
  • 注意\(里面匹配到的内容\)会对应到取代位置那边的\1
  • \escaping char

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment