[关闭]
@ju1900 2017-06-29T17:47:50.000000Z 字数 6081 阅读 631

CONF_LTE_PC

日志


1.切换到root账号:

  1. lte@ltepc11:~$ sudo -s
  2. [sudo] password for lte: \\密码在安装试设置为casa
  3. root@ltepc11:~#

2.更新

  1. root@ltepc11:~# apt-get update

3.安装ssh 和 vim

  1. root@ltepc11:~# apt-get install ssh
  2. root@ltepc11:~# apt-get install vim

4.添加root用户登录密码

4.1修改root密码

  1. root@ltepc11:/# passwd root
  2. Enter new UNIX password: \\密码为casa
  3. Retype new UNIX password:
  4. passwd: password updated successfully

4.2 修改ssh配置文件

  1. root@ltepc6:~# vi /etc/ssh/sshd_config
  2. # Authentication:
  3. LoginGraceTime 120
  4. #PermitRootLogin without-password \\注释掉第28行
  5. PermitRootLogin yes \\添加这一行
  6. StrictModes yes

4.3重启ssh 服务

  1. root@ltepc6:~# service ssh restart

5.安装nfs

  1. root@ltepc11:~# root@ltepc6vm3:~# apt-get install -y nfs-common nfs-kernel-server rpcbind
FQDN
一种包含主机名和域名(包括顶级域)的 URL。例如,www.symantec.com 是完全限定域名。其中 www 是主机,symantec 是二级域,.com 是顶级域。FQDN 总是以主机名开始且以顶级域名结束,因此 www.sesa.symantec.com 也是一个 FQDN
  1. 错误: qmail qmail-run E: Sub-process /usr/bin/dpkg returned an error code (1)
  2. 解决方式:
  3. 1. sudo rm /var/lib/dpkg/info/qmail*
  4. 2. 重新执行安装命令

6.安装wireshark

  1. root@ltepc11:~# apt-get install wireshark

7.安装samba

  1. root@ltepc11:~# apt-get install samba

7.1 修改配置文件

  1. root@ltepc11:~# vi /etc/samba/smb.conf
  2. security = user # ??
  3. # 在最后添加下面几行:
  4. [public]
  5. path = /public
  6. public = yes # ??
  7. writeable = yes
  8. browseable = yes
  9. guest ok = yes

7.2 进入主目录

  1. root@ltepc11:/# cd /

7.3创建/public

  1. root@ltepc11:/# mkdir public/

7.4修改新建文件夹的权限

  1. root@ltepc11:/# chmod 777 public

7.5 重启smbd

  1. root@ltepc11:/# /etc/init.d/smbd restart
  2. root@ltepc11:/# service smbd restart

7.6 查看PC的ip

  1. root@ltepc11:/# ifconfig

7.7 进入Linux

  1. # 用自己的电脑通过ip进入linux电脑刚刚创建的共享文件夹(public)
  2. 1. win + R
  3. 2. \\192.158.58.20 (192.158.58.20linux PCip

7.8 拷贝文件

image_1bjm3nbgl1g3f5cqshs1shf10gb9.png-18.8kB

将ubuntu-14.04.3-desktop-amd64 和安装KVM虚拟机的文件拷贝到public文件夹中

7.9 配置网卡设备文件信息

  1. vi /etc/udev/rules.d/70-persistent-net.rules
  2. 例如:ATTR{address}是主机自带网卡的为eth0,这里98:90:96:d6:cd:b5 eth0ATTR{address}是额外加的网卡按顺序从小到大为依次为eth1 eth2 eth3...
  3. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="a0:36:9f:80:05:f4", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
  4. # PCI device 0x8086:/sys/devices/pci0000:00/0000:00:19.0 (e1000e)
  5. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="98:90:96:d6:cd:b5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
  6. # PCI device 0x8086:/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.1 (igb)
  7. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="a0:36:9f:80:05:f5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

8.安装kvm虚拟机

8.1. Install KVM

  1. root@ltepc11:/# apt-get install kvm qemu-kvm libvirt-bin virtinst bridge-utils virt-viewer
  2. 警告:
  3. dpkg: warning: files list file for package 'qmail-run' missing; assuming package has no files currently installed
  4. dpkg: warning: files list file for package 'qmail' missing; assuming package has no files currently installed
  5. dpkg: warning: files list file for package 'qmail-uids-gids' missing; assuming package has no files currently installed

8.2 添加root到libvirtd

  1. # 添加用户到libvirtd用户组, 之后重新登录
  2. root@ltepc42:/# adduser root libvirtd
  3. # libvirtd 用户组?? 什么作用??
  1. 验证:
  2. root@ltepc42:/etc# id lte
  3. uid=1000(lte) gid=1000(lte) groups=1000(lte),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),126(libvirtd)

8.3 查看正在运行vm列表

  1. root@ltepc42:/etc# virsh -c qemu:///system list
  2. # virsh list --all
  3. Id Name State
  4. ----------------------------------------------------
  5. 6 ltepc42vm5 running
  6. 8 ltepc42vm4 running
  7. 9 ltepc42vm3 running
  8. 10 ltepc42vm1 running

8.4 创建bridges(??)

具体每个网卡是做什么的??
Edit /etc/network/interfaces to create bridges (copy over the same file from ltepc10, then edit)
根据PC规划表(因为这里配置的网段是实验室的ip网段,重启之后,PC将不能上网,等搬到实验室才能上网)

  1. root@ltepc11:/# vi /etc/network/interfaces
  2. # This file describes the network interfaces available on your system
  3. # and how to activate them. For more information, see interfaces(5).
  4. # The loopback network interface
  5. auto lo
  6. iface lo inet loopback
  7. # The primary network interface
  8. auto eth0
  9. iface eth0 inet manual
  10. auto eth1
  11. iface eth1 inet manual
  12. auto eth2
  13. iface eth2 inet manual
  14. auto eth3
  15. iface eth3 inet manual
  16. auto eth4
  17. iface eth4 inet manual
  18. # bridge interfaces
  19. auto br0
  20. iface br0 inet static
  21. address 172.0.5.170
  22. netmask 255.255.255.0
  23. gateway 172.0.5.1
  24. # dns-* options are implemented by the resolvconf package, if installed
  25. dns-nameservers 8.8.8.8
  26. bridge_ports eth0
  27. bridge_stp off
  28. bridge_fd 0
  29. bridge_maxwait 0
  30. auto br1
  31. iface br1 inet static
  32. address 172.1.1.170
  33. netmask 255.255.255.0
  34. bridge_ports eth1
  35. bridge_stp off
  36. bridge_fd 0
  37. bridge_maxwait 0
  38. auto br2
  39. iface br2 inet static
  40. address 172.2.1.170
  41. netmask 255.255.255.0
  42. bridge_ports eth2
  43. bridge_stp off
  44. bridge_fd 0
  45. bridge_maxwait 0
  46. auto br3
  47. iface br3 inet static
  48. address 172.3.1.170
  49. netmask 255.255.255.0
  50. bridge_ports eth3
  51. bridge_stp off
  52. bridge_fd 0
  53. bridge_maxwait 0
  54. auto br4
  55. iface br4 inet static
  56. address 172.4.1.170
  57. netmask 255.255.255.0
  58. bridge_ports eth4
  59. bridge_stp off
  60. bridge_fd 0
  61. bridge_maxwait 0

8.5 reboot the PC

  1. root@ltepc11:/# reboot

8.6 enter root user

  1. lte@ltepc11:~$ sudo -s

8.7 Create the VM:

  1. root@ltepc11:/# virt-install --name ltepc11vm1 -r 2048 --disk path=/var/lib/libvirt/images/ltepc11vm1_img,size=40 --vcpu=2 --os-type linux -w bridge=br0 -w bridge=br1, -w bridge=br2, -w bridge=br3, -w bridge=br4 --virt-type kvm --cdrom=/public/ubuntu-14.04.3-desktop-amd64.iso

8.8 重复 1~6 操作

8.9 Set auto start:

  1. root@ltepc11:/# virsh autostart ltepc15vm1

8.10 shutdown

  1. root@ltepc11:/#virsh shutdown ltepc15vm1

8.11 Clone VM

直接复制虚拟机减少重复操作

  1. root@ltepc11:/#virt-clone --connect=qemu:///system -o ltepc11vm1 -n ltepc11vm2 -f /var/lib/libvirt/images/ltepc11vm2_img
  2. root@ltepc11:/#virt-clone --connect=qemu:///system -o ltepc11vm1 -n ltepc11vm3 -f /var/lib/libvirt/images/ltepc11vm3_img

9.虚拟机操作

9.1登录到虚拟机

  1. root@ltepc11:/# virt-viewer ltepc11vm2

9.2 切换到root用户

  1. lte@ltepc11vm2:~$ sudo -s
  2. [sudo] password for lte:

9.3修改hostname:

  1. root@ltepc11vm2:~# vi /etc/hosts
  2. 第二行修改如下:
  3. 127.0.1.1 ltepc11vm2
  4. root@ltepc11vm2:~# vi /etc/hostname
  5. 第一行修改如下:
  6. ltepc11vm2

9.4 重启虚拟机

  1. root@ltepc11vm2:~# reboot

9.5 修改虚拟机内部IP

在虚拟机 VM1(VM2/VM3/VM4) 修改ip,根据PC规划表

  1. root@ltepc11vm2:~# vi /etc/network/interfaces
  2. # interfaces(5) file used by ifup(8) and ifdown(8)
  3. auto lo
  4. iface lo inet loopback
  5. auto eth0
  6. iface eth0 inet static
  7. address 172.0.10.41
  8. netmask 255.255.255.0
  9. gateway 172.0.5.1
  10. dns-nameservers 8.8.8.8
  11. auto eth1
  12. iface eth1 inet static
  13. address 172.1.10.41
  14. netmask 255.255.255.0
  15. auto eth2
  16. iface eth2 inet static
  17. address 172.2.10.41
  18. netmask 255.255.255.0

9.6 重启虚拟机:

  1. root@ltepc11vm2:~# reboot

10.设置虚拟机开机自动重启

  1. root@ltepc11:/# virsh autostart ltepc11vm1
  2. root@ltepc11:/# virsh autostart ltepc11vm3
  3. root@ltepc11:/# virsh autostart ltepc11vm4
  4. root@ltepc11:/# virsh autostart ltepc11vm5
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注