1. 查看主機名,三個命令都可以
# hostname
# uname -n
# cat /proc/sys/kernel/hostname
2. 使用 vi /etc/hostname 文件

修改為Hadoop100
3. 設置主機名及IP映射
vi 編輯器打開vi /etc/hosts 文件
在文件尾部添加內容,格式:IP地址 主機名(中間用空格分隔),保存退出
192.168.1.100 hadoop
4. 重啟網略
systemctl restart network
5. 檢查主機名是否可用
[root@localhost ~]# ping hadoop100
PINGhadoop100 (192.168.1.100) 56(84) bytes of data.
64 bytesfrom hadoop100 (192.168.1.100): icmp_seq=1 ttl=64 time=0.038 ms
64 bytesfrom hadoop100 (192.168.1.100): icmp_seq=2 ttl=64 time=0.037 ms
64 bytesfrom hadoop100 (192.168.1.100): icmp_seq=3 ttl=64 time=0.038 ms
64 bytesfrom hadoop100 (192.168.1.100): icmp_seq=4 ttl=64 time=0.038 ms
如果想在我們的Windows是上用別名訪問需要在C:\Windows\System32\drivers\etc\hosts后追加
192.168.1.100 hadoop100
6. 添加/刪除用戶
[root@hadoop100 ~]# useradd shaozhiqi //添加用戶
useradd: user 'shaozhiqi' already exists
[root@hadoop100 ~]# userdel shaozhiqi
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists
[root@hadoop100 ~]# userdel -r shaozhiqi //刪除用戶及目錄
[root@hadoop100 ~]# passwd shaozhiqi
Changing password for user shaozhiqi.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.
[root@hadoop100 ~]# id shaozhiqi //查看用戶創建成功
uid=1000(shaozhiqi) gid=1000(shaozhiqi) groups=1000(shaozhiqi)
[root@hadoop100 ~]#
7. 為用戶設置root權限
[root@hadoop100 ~]# vim /etc/sudoers
set nu 可以設置行號


:wq! 強制退出
8. 創建目錄
[root@hadoop100~]# cd /opt
[root@hadoop100opt]# ll
total 0
drwxr-xr-x.2 root root 6 Mar 26 2015 rh
[root@hadoop100opt]# mkdir software module
[root@hadoop100opt]# ll
total 0
drwxr-xr-x.2 root root 6 Jun 18 05:58 module
drwxr-xr-x.2 root root 6 Mar 26 2015 rh
drwxr-xr-x.2 root root 6 Jun 18 05:58 software
[root@hadoop100opt]# rm -rf rh
[root@hadoop100opt]# ll
total 0
drwxr-xr-x.2 root root 6 Jun 18 05:58 module
drwxr-xr-x.2 root root 6 Jun 18 05:58 software
[root@hadoop100opt]# chown shaozhiqi:shaozhiqi module/ software/ //修改文件所有者
[root@hadoop100opt]# ll
total 0
drwxr-xr-x.2 shaozhiqi shaozhiqi 6 Jun 18 05:58 module
drwxr-xr-x.2 shaozhiqi shaozhiqi 6 Jun 18 05:58 software
9. Clone虛擬機以及設置ip/用戶

在虛擬機關閉的情況下進行克隆

創建完整克隆不要快捷方式


10. 修改克隆好的機器的ip為101、機器名hadoop101 ,以及ip映射,驗證是否可用等

11. 修改101的物理地址(由於是克隆的100的,當修改了物理地址后就不能激活網卡了)

52:54:00:0a:b6:9e
cd /etc/udev/rules.d
vi 70-persistent-ipoib.rules
運行命令:grub2-mkconfig -o /boot/grub2/grub.cfg #重新生成grub配置並更新內核參數
vi /etc/sysconfig/network-scripts/ifcfg-eth0
MACADDR=52:54:00:0a:b6:9e
service network restart 重啟網卡
還是異常,於是修改

重啟解決
總結下克隆后要修改的點:
1.修改mac為生成的mac
cd /etc/udev/rules.d
vi 70-persistent-ipoib.rules
2.修改vi
/etc/sysconfig/network-scripts/ifcfg-eth0里的HWADDR與其一致
3.修改ip
4.修改映射關系
vi /etc/hosts
5.修改機器名
vi /etc/hostname
6.重啟網卡
service network restart
7.ping 機器名驗證
8.重啟機器可以看到機器名已變更
12. 在前面配置完centOs Nat 后就可以用外部工具鏈接我們的虛擬機了
