1. 设置hostname
方法1:
centos7 里面修改hostname的方式有所改变,修改/etc/hosts和/etc/sysconfig/network两个文件已经不能生效。使用的新命令是:
[root@hadoop1 mort]# hostnamectl set-hostname hadoop101.com [root@hadoop1 mort]# hostname -f hadoop101.com
方法2:
修改配置文件/etc/hostname来实现主机名的修改。把该文件内容hostname name中的name替换成自己想要的主机名重启即可。
[root@hadoop1 mort]# vim /etc/hostname hadoop101.com
centos7之前的版本请用此方法:
[root@hadoop1 mort]# vi /etc/sysconfig/network #Created by anaconda NETWORKING=yes GATEWAY=192.168.1.2 HOSTNAME=hadoop101.com
2. 设置/etc/hosts
[root@hadoop1 mort]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.100 hadoop100.com hadoop100 192.168.1.101 hadoop101.com hadoop101 192.168.1.102 hadoop102.com hadoop102 192.168.1.103 hadoop103.com hadoop103 192.168.1.104 hadoop104.com hadoop104 192.168.1.105 hadoop105.com hadoop105 192.168.1.106 hadoop106.com hadoop106
3. 重启后生效