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:WindowsSystem32driversetchosts后追加
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.重启机器可以看到机器名已变更