[关闭]
@yangwenbo 2023-04-26T16:06:48.000000Z 字数 4799 阅读 225

虚拟机小笔记

创建新虚拟机小笔记

1、创建虚拟机模板服务器

1.点击左上角文件-->>新建虚拟机

image.png-142.7kB

2.选择经典,点击下一步

image.png-171.3kB

3.选择稍后安装操作系统,点击下一步

image.png-102kB

4.系统选择Linux,版本选择CentOS 7 64位,点击下一步

image.png-83.7kB

5.创建虚拟机名称,选择虚拟机文件储存位置,点击下一步

image.png-80.7kB

6.选择磁盘大小,建议20G左右;选择将虚拟磁盘拆分成多个文件,点击下一步

image.png-121.8kB

7.选择自定义硬件

image.png-94kB

8.依次修改配置信息

image.png-181.7kB

image.png-193kB

image.png-146kB

image.png-185.7kB

9.最后点击完成即可

image.png-92kB

2、配置虚拟网络编辑器(net8模式)

1.子网掩码

图片.png-176kB

2.IP范围(DHCP)

图片.png-56.6kB

3.网关地址

图片.png-104.3kB

3、配置虚拟机

1.点击开启此虚拟机

image.png-229.8kB

2.点击enter

image.png-21.7kB

3.等待。。。

image.png-49.2kB

4.选择语言包,可以根据个人喜好来选择中文英文

image.png-146.2kB

5.进入操作界面

image.png-147.9kB

6.选择时区,建议选择shanghai

image.png-146.2kB

image.png-198.2kB

7.选择安装模式,一般选择最小化安装

image.png-145.3kB

image.png-160.5kB

8.根据自己的需求选择分区

image.png-150.1kB

9.设置网络主机名

image.png-150.7kB

image.png-91.6kB

10.开始安装

image.png-155.5kB

11.等待安装,设置密码

image.png-236kB

12.安装完毕,重启虚拟机

image.png-122.9kB

image.png-124.3kB

image.png-10.4kB

4、修改虚拟机软件配置(centos6)

  1. #修改IP
  2. [root@ywb ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
  3. DEVICE=eth0
  4. TYPE=Ethernet
  5. ONBOOT=yes
  6. NM_CONTROLLED=yes
  7. BOOTPROTO=static
  8. IPADDR=192.168.200.200
  9. NETMASK=255.255.255.0
  10. GATEWAY=192.168.200.2
  11. #修改网卡
  12. [root@ywb ~]# cat /etc/resolv.conf
  13. ; generated by /sbin/dhclient-script
  14. search localdomain
  15. nameserver 192.168.200.2
  16. #重启网络
  17. [root@ywb ~]# service network restart
  1. #关闭防火墙,并关闭开机启动
  2. [root@ywb ~]# service iptables stop
  3. [root@ywb ~]# chkconfig iptables off
  4. #关闭selinux开机自启动
  5. [root@ywb ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
  1. #配置yum源
  2. [root@ywb ~]# mkdir -p /media/cdrom
  3. [root@ywb ~]# mount /dev/sr0 /media/cdrom/
  4. [root@ywb ~]# tail -6 /etc/yum.repos.d/CentOS-Media.repo
  5. [c6-media]
  6. name=CentOS-$releasever - Media
  7. baseurl=file:///media/cdrom/
  8. gpgcheck=1
  9. enabled=1
  10. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  11. [root@ywb ~]# yum -y clean all
  12. [root@ywb ~]# yum makecache
  13. #设置开机自挂载
  14. [root@ywb ~]# echo "mount /dev/sr0 /media/cdrom/" >> /etc/rc.local
  1. #安装一些常用命令
  2. [root@ywb ~]# yum -y install tree curl telnet make cmake gcc gcc-c++ vim wget lrzsz lsof sysstat tcpdump openssh-clients nc htop
  3. #把系统中的命令版本全部更新为最新
  4. [root@ywb ~]# yum -y update
  1. #清空70-persistent-net.rules文件,避免模板依赖
  2. [root@ywb ~]# >/etc/udev/rules.d/70-persistent-net.rules

5、修改虚拟机软件配置(centos7)

  1. #修改IP
  2. [root@ywb ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32
  3. TYPE="Ethernet"
  4. BOOTPROTO="static"
  5. NAME="ens32"
  6. DEVICE="ens32"
  7. ONBOOT="yes"
  8. IPADDR=192.168.200.200
  9. NETMASK=255.255.255.0
  10. GATEWAY=192.168.200.2
  11. #修改网卡
  12. [root@ywb ~]# cat /etc/resolv.conf
  13. ; generated by /usr/sbin/dhclient-script
  14. search localdomain
  15. nameserver 192.168.200.2
  16. #重启网络
  17. [root@ywb ~]# systemctl restart network
  1. #关闭NetworkManager服务,并关闭开机启动
  2. [root@ywb ~]# systemctl stop NetworkManager
  3. [root@ywb ~]# systemctl disable NetworkManager
  4. #关闭防火墙,并关闭开机启动
  5. [root@ywb ~]# systemctl stop firewalld
  6. [root@ywb ~]# systemctl disable firewalld
  7. #关闭selinux开机自启动
  8. [root@ywb ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
  1. #安装一些常用命令
  2. [root@ywb ~]# yum -y install net-tools tree curl telnet make cmake gcc gcc-c++ vim wget lrzsz lsof sysstat tcpdump nc
  3. #把系统中的命令版本全部更新为最新
  4. [root@ywb ~]# yum -y update

6、修改虚拟机软件配置(ubuntu16.04)

  1. #配置静态IP
  2. root@ubuntu-virtual-machine:~# cat /etc/network/interfaces
  3. # interfaces(5) file used by ifup(8) and ifdown(8)
  4. auto lo
  5. iface lo inet loopback
  6. auto ens32
  7. iface ens32 inet static
  8. address 192.168.200.200
  9. netmask 255.255.255.0
  10. gateway 192.168.200.2
  11. dns-nameserver 192.168.200.2
  12. #重启网络
  13. root@ubuntu-virtual-machine:~# systemctl restart NetworkManager.service
  1. root@ubuntu-virtual-machine:~# apt-get update
  2. #安装ssh
  3. root@ubuntu-virtual-machine:~# apt-get -y install openssh-server
  4. #修改sshd配置,使用户可以远程登录
  5. root@ubuntu-virtual-machine:~# vim /etc/ssh/sshd_config
  6. root@ubuntu-virtual-machine:~# sed -n "28p;52p" /etc/ssh/sshd_config
  7. PermitRootLogin yes
  8. PasswordAuthentication yes
  9. #重启sshd
  10. root@ubuntu-virtual-machine:~# systemctl restart sshd
  1. #安装一些常用命令
  2. root@ubuntu-virtual-machine:~# apt-get -y install net-tools tree curl telnet make cmake gcc g++ vim wget lrzsz lsof tcpdump nano inetutils-ping usbutils pciutils resolvconf open-vm-tools open-vm-tools-desktop tmux htop ethtool
  3. #把系统中的命令版本全部更新为最新
  4. root@ubuntu-virtual-machine:~# apt-get -y upgrade
  5. ubuntu镜像源:https://www.zybuluo.com/yangwenbo/note/2271749

7、修改虚拟机软件配置(ubuntu18.04/20.04/22.04)

  1. #配置静态IP
  2. root@ywb-virtual-machine:~# cat /etc/netplan/01-network-manager-all.yaml
  3. # Let NetworkManager manage all devices on this system
  4. network:
  5. version: 2
  6. ethernets:
  7. ens32:
  8. addresses: [192.168.200.200/24]
  9. dhcp4: no
  10. dhcp6: no
  11. gateway4: 192.168.200.2
  12. nameservers:
  13. addresses: [255.255.255.0]
  14. #设置网关
  15. root@ywb-virtual-machine:~# cat /etc/resolv.conf
  16. nameserver 192.168.200.2
  17. #重启网络
  18. root@ywb-virtual-machine:~# systemctl restart NetworkManager.service
  1. root@ywb-virtual-machine:~# apt-get update
  2. #安装ssh
  3. root@ywb-virtual-machine:~# apt-get -y install openssh-server
  4. #修改sshd配置,使用户可以远程登录
  5. root@ywb-virtual-machine:~# vim /etc/ssh/sshd_config
  6. root@ywb-virtual-machine:~# sed -n "32p;56p" /etc/ssh/sshd_config
  7. PermitRootLogin yes
  8. PasswordAuthentication yes
  9. #重启sshd
  10. root@ywb-virtual-machine:~# systemctl restart sshd
  1. #安装一些常用命令
  2. root@ywb-virtual-machine:~# apt-get -y install net-tools tree curl telnet make cmake gcc g++ vim wget lrzsz lsof tcpdump nano inetutils-ping usbutils pciutils resolvconf open-vm-tools open-vm-tools-desktop tmux htop ethtool
  3. #把系统中的命令版本全部更新为最新
  4. root@ywb-virtual-machine:~# apt-get -y upgrade
  5. ubuntu镜像源:https://www.zybuluo.com/yangwenbo/note/2271749
  1. #配置网关(解决resolv.conf配置在机器在重启时被重置问题)
  2. root@ywb-virtual-machine:~# cat /etc/resolvconf/resolv.conf.d/tail
  3. nameserver 192.168.200.2
  4. #重启resolvconf
  5. root@ywb-virtual-machine:~# systemctl restart resolvconf
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注