1. 程式人生 > 其它 >第一章:安裝VMware Workstation 並配置第一個虛擬機器

第一章:安裝VMware Workstation 並配置第一個虛擬機器

  1. 進行網路配置
    a 新增網絡卡
    b 配置網絡卡
    vim /etc/sysconfig/network-scripts/ifcfg-eth1
    c 確認網路配置

  2. 系統優化
    2. 模板機優化配置---更改yum源
    更改yum源
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup &&
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    yum install -y wget
    wget -O /etc/yum.repos.d/epel.repo

    http://mirrors.aliyun.com/repo/epel-7.repo
    PS:yum repolist 列出yum源資訊;講解什麼是epel源

    1. 模板機優化配置---關閉selinux
    #關閉selinux
    sed -i.bak 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    grep SELINUX=disabled /etc/selinux/config 
    setenforce 0
    getenforce
    
    1. 模板機優化配置---關閉iptables
    #關閉iptables  centos7       
    systemctl stop firewalld
    systemctl disable firewalld
    
    1. 模板機優化配置---提權test可以sudo (可選配置)
    #提權test可以sudo(可選配置)
    useradd test
    echo 123456|passwd --stdin test
    \cp /etc/sudoers /etc/sudoers.ori
    echo "test  ALL=(ALL) NOPASSWD: ALL " >>/etc/sudoers
    tail -1 /etc/sudoers
    visudo -c #載入/etc/sudoers
    
    1. 模板機優化配置---英文字符集
    #英文字符集
    localectl set-locale LANG="en_US.UTF-8"
    
    1. 模板機優化配置---時間同步
    #時間同步
    yum install -y ntpdate
    echo '#time sync by wish at 2021-08-09' >>/var/spool/cron/root
    echo '*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1' >>/var/spool/cron/root
    crontab -l
    
    
    8. 模板機優化配置---加大檔案描述
    yum install -y lsof
    lsof -i:22
    
    檢視檔案開啟的多少:ulimit -a
    #加大檔案描述
    echo '*               -       nofile          65536' >>/etc/security/limits.conf 
    tail -1 /etc/security/limits.conf
    說明:
    一個服務程式執行起來,會開啟相應的檔案
    crond定時任務服務---systemctl start crond --- 開啟相應檔案
    /var/spool/cron/root  --- 載入開啟配置檔案
    /var/log/cron         --- 載入開啟日誌檔案
    
    
    9. 模板機優化配置---安裝其他小軟體
      #安裝其他小軟體
      yum install lrzsz nmap tree dos2unix nc telnet wget lsof ntpdate bash-completion bash-completion-extras -y
      
    10. 模板機優化配置---ssh連線速度慢優化
      #ssh連線速度慢優化          
      sed -i.bak 's@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g'  /etc/ssh/sshd_config
    systemctl restart sshd	
    
    11.關閉NetworkManager
    systemctl stop NetworkManager
    systemctl disable NetworkManager
    systemctl status NetworkManager
    
  3. 克隆後虛擬主機配置
    a 修改主機名稱
    hostnamectl set-hostname backup
    b 修改主機地址
    sed -i 's#200#41#g' /etc/sysconfig/network-scripts/ifcfg-eth[01]
    grep 41 /etc/sysconfig/network-scripts/ifcfg-eth[01]
    sed -i '/UUID/d' /etc/sysconfig/network-scripts/ifcfg-eth[01]
    grep UUID /etc/sysconfig/network-scripts/ifcfg-eth[01]
    systemctl restart network
    ping -c 6 www.baidu.com