修改机器名
- 说明:
[hadoop@localhost Desktop]
@之前的hadoop为用户名
@之后的localhost为机器名,也可以理解为IP映射地址 - 进入到【/etc】下的hosts文件,修改IP与主机名的映射关系【注意:要在root用户下修改】
追加:192.168.253.20 spark
- 修改【/etc/sysconfig/network】文件 【注意:机器名不能含有“_”下划线】
修改HOSTNAME属性为:spark
HOSTNME=spark
- 重启系统,即可!
$>reboot
- 修改【C:\Windows\System32\drivers\etc】下的hosts文件
如果无hosts文件,则需手动创建hosts文件【如果遇到权限问题,最简便的方式是用Notepad++打开进行修改】
添加:192.168.253.20 spark
在主机直接ping虚拟机的机器名来通信:cmd>ping spark
防火墙设置
- 查看防火墙状态
[root@spark Desktop]# service iptables status
- 临时关闭防火墙【要在root用户下】
[root@spark Desktop]# service iptables stop
[root@spark Desktop]# service iptables status
iptables: Firewall is not running. - 查看防火墙开机启动状态
[root@spark Desktop]# chkconfig iptables --list
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off - 设置开机启动防火墙为关闭状态【root权限】
[root@spark Desktop]# chkconfig iptables off
[root@spark Desktop]# chkconfig iptables --list
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off - 设置开机启动防火墙为开启状态【root权限】
[root@spark Desktop]# chkconfig iptables on
[root@spark Desktop]#chkconfig iptables --list
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Linux的开关机
- 基本语法
(1)sync (功能描述:将数据由内存同步到硬盘中)
(2)shutdown [选项] 时间
选项:
-h:关机
-r:重启
注意:shutdown命令要在root用户下使用】
(3)halt (功能描述:关闭系统,等同于shutdown -h now 和 poweroff)
(4)reboot (功能描述:就是重启,等同于 shutdown -r now) - 【案例】
(1)将数据由内存同步到硬盘中
[root@spark Desktop]# sync
(2)计算机将在10分钟后关机,并且会显示在登录用户的当前屏幕中
[root@spark Desktop]# shutdown -h 10 'shutdown after 10 mins张三'
(3)立马关机
[root@spark Desktop]# shutdown -h now
(4)系统立马重启
[root@spark Desktop]# shutdown -r now
(5)重启(等同于:shutdown -r now)
[root@spark Desktop]# reboot
(6)关机(等同于:shutdown -h now 和 poweroff)
[root@spark Desktop]# halt
- 【注意】:不管是重启系统还是关闭系统,首先要运行sync命令,把内存中的数据写到磁盘中。