@ju1900
2017-06-29T17:47:50.000000Z
字数 6081
阅读 631
日志
lte@ltepc11:~$ sudo -s
[sudo] password for lte: \\密码在安装试设置为casa
root@ltepc11:~#
root@ltepc11:~# apt-get update
root@ltepc11:~# apt-get install ssh
root@ltepc11:~# apt-get install vim
root@ltepc11:/# passwd root
Enter new UNIX password: \\密码为casa
Retype 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.conf
security = user # ??
# 在最后添加下面几行:
[public]
path = /public
public = yes # ??
writeable = yes
browseable = yes
guest ok = yes
root@ltepc11:/# cd /
root@ltepc11:/# mkdir public/
root@ltepc11:/# chmod 777 public
root@ltepc11:/# /etc/init.d/smbd restart
root@ltepc11:/# service smbd restart
root@ltepc11:/# ifconfig
# 用自己的电脑通过ip进入linux电脑刚刚创建的共享文件夹(public)
1. win + R
2. \\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 installed
dpkg: warning: files list file for package 'qmail' missing; assuming package has no files currently installed
dpkg: 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 lte
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)
root@ltepc42:/etc# virsh -c qemu:///system list
# virsh list --all
Id Name State
----------------------------------------------------
6 ltepc42vm5 running
8 ltepc42vm4 running
9 ltepc42vm3 running
10 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 interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet manual
auto eth1
iface eth1 inet manual
auto eth2
iface eth2 inet manual
auto eth3
iface eth3 inet manual
auto eth4
iface eth4 inet manual
# bridge interfaces
auto br0
iface br0 inet static
address 172.0.5.170
netmask 255.255.255.0
gateway 172.0.5.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
auto br1
iface br1 inet static
address 172.1.1.170
netmask 255.255.255.0
bridge_ports eth1
bridge_stp off
bridge_fd 0
bridge_maxwait 0
auto br2
iface br2 inet static
address 172.2.1.170
netmask 255.255.255.0
bridge_ports eth2
bridge_stp off
bridge_fd 0
bridge_maxwait 0
auto br3
iface br3 inet static
address 172.3.1.170
netmask 255.255.255.0
bridge_ports eth3
bridge_stp off
bridge_fd 0
bridge_maxwait 0
auto br4
iface br4 inet static
address 172.4.1.170
netmask 255.255.255.0
bridge_ports eth4
bridge_stp off
bridge_fd 0
bridge_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_img
root@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 ltepc11vm2
root@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 lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 172.0.10.41
netmask 255.255.255.0
gateway 172.0.5.1
dns-nameservers 8.8.8.8
auto eth1
iface eth1 inet static
address 172.1.10.41
netmask 255.255.255.0
auto eth2
iface eth2 inet static
address 172.2.10.41
netmask 255.255.255.0
root@ltepc11vm2:~# reboot
root@ltepc11:/# virsh autostart ltepc11vm1
root@ltepc11:/# virsh autostart ltepc11vm3
root@ltepc11:/# virsh autostart ltepc11vm4
root@ltepc11:/# virsh autostart ltepc11vm5