@ju1900
2017-06-29T09:47:50.000000Z
字数 6081
阅读 795
日志
lte@ltepc11:~$ sudo -s[sudo] password for lte: \\密码在安装试设置为casaroot@ltepc11:~#
root@ltepc11:~# apt-get update
root@ltepc11:~# apt-get install sshroot@ltepc11:~# apt-get install vim
root@ltepc11:/# passwd rootEnter new UNIX password: \\密码为casaRetype new UNIX password:passwd: password updated successfully
root@ltepc6:~# vi /etc/ssh/sshd_config# Authentication:LoginGraceTime 120#PermitRootLogin without-password \\注释掉第28行PermitRootLogin yes \\添加这一行StrictModes yes
root@ltepc6:~# service ssh restart
root@ltepc11:~# root@ltepc6vm3:~# apt-get install -y nfs-common nfs-kernel-server rpcbind
错误: qmail qmail-run E: Sub-process /usr/bin/dpkg returned an error code (1)解决方式:1. sudo rm /var/lib/dpkg/info/qmail*2. 重新执行安装命令
root@ltepc11:~# apt-get install wireshark
root@ltepc11:~# apt-get install samba
root@ltepc11:~# vi /etc/samba/smb.confsecurity = user # ??# 在最后添加下面几行:[public]path = /publicpublic = yes # ??writeable = yesbrowseable = yesguest ok = yes
root@ltepc11:/# cd /
root@ltepc11:/# mkdir public/
root@ltepc11:/# chmod 777 public
root@ltepc11:/# /etc/init.d/smbd restartroot@ltepc11:/# service smbd restart
root@ltepc11:/# ifconfig
# 用自己的电脑通过ip进入linux电脑刚刚创建的共享文件夹(public)1. win + R2. \\192.158.58.20 (192.158.58.20是linux PC的ip)

将ubuntu-14.04.3-desktop-amd64 和安装KVM虚拟机的文件拷贝到public文件夹中
/etc/udev/rules.d这个目录存储的是以.rules结束的文件。下面可能有好几个udev规则文件,每一个文件处理一系列规则来帮助udev**分配名字**给设备文件以保证能被内核识别。
vi /etc/udev/rules.d/70-persistent-net.rules例如:ATTR{address}是主机自带网卡的为eth0,这里98:90:96:d6:cd:b5 为eth0,ATTR{address}是额外加的网卡按顺序从小到大为依次为eth1 eth2 eth3...SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="a0:36:9f:80:05:f4", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:19.0 (e1000e)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="98:90:96:d6:cd:b5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.1 (igb)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="a0:36:9f:80:05:f5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
root@ltepc11:/# apt-get install kvm qemu-kvm libvirt-bin virtinst bridge-utils virt-viewer警告:dpkg: warning: files list file for package 'qmail-run' missing; assuming package has no files currently installeddpkg: warning: files list file for package 'qmail' missing; assuming package has no files currently installeddpkg: warning: files list file for package 'qmail-uids-gids' missing; assuming package has no files currently installed
# 添加用户到libvirtd用户组, 之后重新登录root@ltepc42:/# adduser root libvirtd# libvirtd 用户组?? 什么作用??
验证:root@ltepc42:/etc# id lteuid=1000(lte) gid=1000(lte) groups=1000(lte),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),126(libvirtd)
root@ltepc42:/etc# virsh -c qemu:///system list# virsh list --allId Name State----------------------------------------------------6 ltepc42vm5 running8 ltepc42vm4 running9 ltepc42vm3 running10 ltepc42vm1 running
具体每个网卡是做什么的??
Edit /etc/network/interfaces to create bridges (copy over the same file from ltepc10, then edit)
根据PC规划表(因为这里配置的网段是实验室的ip网段,重启之后,PC将不能上网,等搬到实验室才能上网)
root@ltepc11:/# vi /etc/network/interfaces# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet manualauto eth1iface eth1 inet manualauto eth2iface eth2 inet manualauto eth3iface eth3 inet manualauto eth4iface eth4 inet manual# bridge interfacesauto br0iface br0 inet staticaddress 172.0.5.170netmask 255.255.255.0gateway 172.0.5.1# dns-* options are implemented by the resolvconf package, if installeddns-nameservers 8.8.8.8bridge_ports eth0bridge_stp offbridge_fd 0bridge_maxwait 0auto br1iface br1 inet staticaddress 172.1.1.170netmask 255.255.255.0bridge_ports eth1bridge_stp offbridge_fd 0bridge_maxwait 0auto br2iface br2 inet staticaddress 172.2.1.170netmask 255.255.255.0bridge_ports eth2bridge_stp offbridge_fd 0bridge_maxwait 0auto br3iface br3 inet staticaddress 172.3.1.170netmask 255.255.255.0bridge_ports eth3bridge_stp offbridge_fd 0bridge_maxwait 0auto br4iface br4 inet staticaddress 172.4.1.170netmask 255.255.255.0bridge_ports eth4bridge_stp offbridge_fd 0bridge_maxwait 0
root@ltepc11:/# reboot
lte@ltepc11:~$ sudo -s
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
root@ltepc11:/# virsh autostart ltepc15vm1
root@ltepc11:/#virsh shutdown ltepc15vm1
直接复制虚拟机减少重复操作
root@ltepc11:/#virt-clone --connect=qemu:///system -o ltepc11vm1 -n ltepc11vm2 -f /var/lib/libvirt/images/ltepc11vm2_imgroot@ltepc11:/#virt-clone --connect=qemu:///system -o ltepc11vm1 -n ltepc11vm3 -f /var/lib/libvirt/images/ltepc11vm3_img
root@ltepc11:/# virt-viewer ltepc11vm2
lte@ltepc11vm2:~$ sudo -s[sudo] password for lte:
root@ltepc11vm2:~# vi /etc/hosts第二行修改如下:127.0.1.1 ltepc11vm2root@ltepc11vm2:~# vi /etc/hostname第一行修改如下:ltepc11vm2
root@ltepc11vm2:~# reboot
在虚拟机 VM1(VM2/VM3/VM4) 修改ip,根据PC规划表
root@ltepc11vm2:~# vi /etc/network/interfaces# interfaces(5) file used by ifup(8) and ifdown(8)auto loiface lo inet loopbackauto eth0iface eth0 inet staticaddress 172.0.10.41netmask 255.255.255.0gateway 172.0.5.1dns-nameservers 8.8.8.8auto eth1iface eth1 inet staticaddress 172.1.10.41netmask 255.255.255.0auto eth2iface eth2 inet staticaddress 172.2.10.41netmask 255.255.255.0
root@ltepc11vm2:~# reboot
root@ltepc11:/# virsh autostart ltepc11vm1root@ltepc11:/# virsh autostart ltepc11vm3root@ltepc11:/# virsh autostart ltepc11vm4root@ltepc11:/# virsh autostart ltepc11vm5