一、虛擬機的搭建:
- 關(guān)閉防火墻,CentOS 6 和CentOS 7 的關(guān)閉方式略有不同。
- 在CentOS 6 中操作防火墻的基本命令
service iptable status -- 查看防火墻的狀態(tài)
service iptables stop -- 關(guān)閉防火墻
service iptables start -- 啟動防火墻
service iptables restart -- 重啟防火墻
chkconfig iptables off -- 永久關(guān)閉防火墻
chkconfig iptables on -- 永久關(guān)閉防火墻后重新啟動防火墻 - 在CentOS 7 中操作防火墻的基本命令,在CentOS 7默認使用的是firewall作為防火墻
firewall-cmd --state -- 查看防火墻的狀態(tài)
systemctl stop firewalld.service -- 停止firewall
systemctl start firewalld.service -- 開啟firewall
systemctl disable firewalld.service -- 禁止開機啟動firewall
- 創(chuàng)建一個一般用戶
useradd Synhard
passwd Synhard
19991013 - 在/opt目錄下創(chuàng)建software 和 module文件夾
mkdir /opt/software /opt/module
chown Synhard:19991013 /opt/software /opt/module (將這兩個文件夾的權(quán)限賦值給新創(chuàng)建的用戶) - 將新創(chuàng)建的用戶加入sudoers
vim /etc/sudoers
Synhard ALL=(ALL) NOPASSWD:ALL
Esc + :wq! (強制保存) - 更改Host文件
創(chuàng)建腳本,使用腳本向/etc/hosts文件中寫入對應(yīng)的IP地址和Host主機名
vim test.sh 創(chuàng)建test腳本
在test腳本中編寫如下代碼:
#! /bin/bash
for ((i=100;i<104;i++))
do
echo "192.168.40.$i hadoop `expr $i-100`
done
Esc 退出 :wq 保存
運行test.sh文件
bash test.sh - 更改靜態(tài)IP
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.40.100
PREFIX=24
GATEWAY=192.168.40.2
DNS1=192.168.40.2
NAME=eth0
如果是克隆的虛擬機需要還需要更改MAC地址
更改完保存退出后執(zhí)行命令
service network restart 重啟網(wǎng)絡(luò)服務(wù)
7.更改主機名
vim /etc/hostname