虛擬機安裝CentOS7最小版本及配置
背景原因:因考慮到CentOS7安裝包占用過大,這里我根據個人需要采用CentOS最小安裝,后續的一些配置會陸續添加其中
虛擬機安裝CentOS最小版本(CentOS-7-x86_64-Minimal-1810.iso)的過程我在這里就不進行闡述,可以參考 :https://blog.csdn.net/hellboy0621/article/details/80392273
1.VMware最小化安裝centos7安裝共享文件夾實現虛擬機與Windows共享一個文件夾
1.點擊虛擬選項卡下的安裝VMware Tools
2.以root用戶進入虛擬機並創建目錄
[root@localhost ~]# mkdir -p /mnt/cdrom
3.裝載CD-ROM
[root@localhost mnt]# mount -t auto /dev/cdrom /mnt/cdrom
4.將VMware-Tools安裝包拷貝到/tmp下
[root@localhost mnt]# cd /tmp/
[root@localhost tmp]# cp /mnt/cdrom/VMwareTools-9.6.2-1688356.tar.gz ./
5.解壓文件得到vmware-tools-distrib
tar -xzvf VMwareTools-9.6.2-1688356.tar.gz
6.進入vmware-tools-distrib 運行vmware-install.pl 命令:./vmware-install.pl
----------------安裝VMwere Tools------------------------
遇到問題1:bash: ./vmware-install.pl: /usr/bin/perl: bad interpreter: 沒有那個文件或目錄
解決方法
yum install perl gcc kernel-devel
yum upgrade kernel kernel-devel
遇到問題2:centos 7 The path "" is not a valid path to the 3.10.0-957.5.1.el7.x86_64 kernel headers. Would you like to change it?
解決方法:Would you like to change it? no 再一路enter
遇到問題3:安裝VMWare tools后/mnt中有hgfs但沒共享文件
前提:在虛擬機軟件中設置了共享目錄
此時在linux中進入 /mnt/hgfs 文件夾,但發現共享的文件沒有顯示
使用以下辦法解決(root權限):
1. vmware-hgfsclient 命令查看當前有哪些共享的目錄,這里我只使用了share文件夾
[root@centos7 share]# vmware-hgfsclient
share
2.掛在共享文件目錄
[root@centos7 hgfs]# mount -t vmhgfs .host:/share /mnt/hgfs
Error: cannot mount filesystem: No such device
補充:
如果顯示
Error: cannot mount filesystem: No such device
centos7則先執行 yum install open-vm-tools
然后再執行vmhgfs-fuse .host:/share /mnt/hgfs
3.永久掛載 ---開機自動掛載
vi /etc/fstab
在最末行添加命令 .host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0
此處一定注意字節對齊,不然開不了機
2.安裝工具集命令
[root@localhost vmware-tools-distrib]# yum -y install net-tools vim-enhanced wget
3.關閉CentOS7自帶的防火牆 firewall 啟用 IPtable
停止 Firewall
systemctl stop firewalld
systemctl mask firewalld
關閉firewall自動啟動
systemctl disable firewalld.service
安裝IPtables防火牆
yum install -y iptables-services
開放端口
vi /etc/sysconfig/iptables
#添加下面三句話到默認的22端口這條規則的下面
#開放443端口(HTTPS)
#開啟服務
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 4433 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
重啟iptables
systemctl restart iptables.service
添加iptables開機自啟項
systemctl enable iptables.service
查看防火牆狀態
service iptables status
4.替換centos7自帶的yum源
#先進入源的目錄
cd /etc/yum.repo.d
#備份一下官方源
mv CentOS-Base.repo CentOS-Base.repo.bak
#將阿里源文件下載下來
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#重建源數據緩存
yum makecache
ok,換源完成