设置静态IP、主机名

1. /etc/sysconfig/network

  [root@hadoop ~]# vi /etc/sysconfig/network

  NETWORKING=yes
  HOSTNAME=hadoop  #主机名
  GATEWAY=192.168.80.1  #网关

2. /etc/sysconfig/network-scripts/ifcfg-eth0

  [root@hadoop ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

  DEVICE="eth0"
  NETMASK="255.255.255.0"  #子网掩码
  IPADDR="192.168.80.100"  #ip地址
  BOOTPROTO="static"  #取值:none  | static | bootp | dhcp(默认值)

          #引导使用的协议:无协议 | 静态 | bootp | dhcp

  HWADDR="00:0C:29:6F:B6:BE"   #MAC地址
  NM_CONTROLLED="yes"
  ONBOOT="yes"  #取值:yes | no

      #引导是否激活设备: 是 | 否
  TYPE="Ethernet"
  UUID="27a2ebe6-e3de-4a99-92ec-bf67336928bf"
  PEERDNS="yes"

  DNS1="8.8.8.8"  #域名解析服务器(没配)

3. /etc/hosts

  [root@hadoop ~]# vi /etc/hosts

  127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


  192.168.80.100 hadoop 绑定主机名和ip

--------- 可略过 -------

    /etc/resolv.conf

  [root@hadoop ~]# vi /etc/resolv.conf

  search hadoop

  nameserver 8.8.8.8  #DNS域名解析服务器

------------------------

4. 应用变更

  [root@hadoop ~]# ifdown eht0

  [root@hadoop ~]# ifup eht0  #这两个操作只能在本机进行,远程操作无反应

  [root@hadoop ~]# service network restart  #重启网络服务

5. 重启

  [root@hadoop ~]# reboot -h 0 或 shutdown -r 0

关闭防火墙:

  [root@hadoop ~]# service iptables status  #查看防火墙状态

  [root@hadoop ~]# service iptables stop  #关闭防火墙

  [root@hadoop ~]# chkconfig iptables off  #关闭防火墙自启动

  [root@hadoop ~]# chkconfig --list|grep iptables #查看防火墙状态 全off,即操作成功