快速记录下自己在虚拟机安装Redhat Linux 6 的过程,仅供参考。
1. 系统安装
存储空间规划 200M for “/boot”, 2G for swap, rest for “/”
2. 网络管理
Network Management TUI: nmtui
3. SELinux
检查SELinux状态
/usr/sbin/sestatus -v
或者
getenforce
临时禁用SELinux
setenforce 0
永久禁用SELinux
grep SELINUX /etc/selinux/config
SELINUX=disabled
之后需要重启
3. IPtables
临时禁用 IPtables
service iptables status
永久禁用 IPtables
chkconfig iptables off
[RHEL7: systemctl stop firewalld]
[RHEL7: systemctl disable firewalld]
4. 重启/关机选项
重启方法
a. shutdown -r +10 ‘system will reboot in ten minutes’
b. Init 6
c. Reboot
关机方法
a. Shutdown -h +10 ‘system will shut down in ten minutes’
b. Init 0
c. Halt
6. 修改Hostname
临时修改
hostname [new hostname]
永久修改
vim /etc/sysconfig/network
7. 网络配置
Service network restart
常见虚拟机与主机网络设置模式
"Device eth0 does not seem to present." after VM clone.
a. Ifconfig -a, record Mac addr of eth1;
b. Vi /etc/sysconfig/network-scripts/ifcfg-eth0 , with eth1’s MAC addr;
c.rm -rf /etc/udev/rules.d/70-persistent-net.rules
d. Reboot -h now
8. 配置root用户的ssh无密码登录
在每个节点执行,生成公钥和私钥
ssh-keygen -t rsa (with all default)
在某一个节点例如login1上生成一个授权文件
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
除login1外其他节点执行,公钥会自动追加写入login1的授权文件
ssh-copy-id -i login1
chmod 600 authorized_keys
从login1分发整合后的公钥文件到每个节点
scp authorized_keys n01:/root/.ssh/
9. 配置本地Yum
$releasever定义:https://blog.csdn.net/taiyang1987912/article/details/46890997
mkdir /mnt/iso
mount -o loop /dev/cdrom /mnt/iso/ #write into /etc/rc.local
cp /etc/yum.repos.d/rhel-source.repo /etc/yum.repos.d/rhel-source.repo.backup
vi /etc/yum.repos.d/rhel-source.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0
gpgkey=file:///mnt/iso/RPM-GPG-KEY-redhat-beta
[rhel-source-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Sourcebaseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/SRPMS/
enabled=0
gpgcheck=1
gpgkey=file:///mnt/iso/RPM-GPG-KEY-redhat-release
最后通过 ‘yum install vim*’ 验证。
10. 如果要改为CentOS Yum
- 重装Yum:https://blog.csdn.net/CTLLIN/article/details/79089123
- 配置Proxy:https://www.centos.org/docs/5/html/yum/sn-yum-proxy-server.html
11. 配置FTP
yum install vsftpd
验证FTP安装和服务
which vsftpd
service vsftpd status
service vsftpd start
验证FTP服务已启动
netstat -an | grep 21
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
修改root用户权限
vi /etc/vsftpd/ftpusers #注释root
vi /etc/vsftpd/user_list #注释root
service vsftpd restart
设置开机自启动
chkconfig vsftpd on
12. 配置NFS
[CentOS7: https://qizhanming.com/blog/2018/08/08/how-to-install-nfs-on-centos-7]
NFS服务器
mkdir /home/share
vi /etc/exports #添加 /home/share 192.168.1.0/24(rw,sync,no_root_squash)
service nfs start
chkconfig nfs on #开机自启动nfs service
NFS客户端
showmount -e 192.168.1.1
mkdir /home/share
mount -t nfs 192.168.1.1:/home/share /home/share #可以再添加到rc.local开机自启动
12. 配置NTP
NTP服务器
[root@localhost ~]# cat /etc/ntp.conf |awk '{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}'
restrict default ignore //默认不允许修改或者查询ntp,并且不接收特殊封包
restrict 127.0.0.1 //给于本机所有权限
restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify //给于局域网机的机器有同步时间的权限
server time.nist.gov prefer //设置时间服务器,加prefer表示优先
si-time1.bosch.com
si-time3.bosch.com
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
[root@localhost ~]# /etc/init.d/ntpd start
[root@localhost ~]# Chkconfig ntpd on
NTP客户端
yum install ntp
vi /etc/ntp.conf #add NTP server
/etc/init.d/ntpd start
ntpdate $NTPServer #optional
FAQ - "the NTP socket is in use, exiting"
When “Ntpdate test-login1”, output err above.
lsof -i:123 # find the ntpd PID
Kill -9 $ntpdPID
Ntpdate $NTPServer #try again
13. 安装Linux桌面
yum -y groupinstall Desktop
yum -y groupinstall "X Window System"