您的位置:首页 > 理论基础 > 计算机网络

使用 AIX TCP/IP 过滤功能设置防火墙

2013-02-22 13:37 639 查看
经过几天的奋斗终于小有突破了。

制作Eucalyptus镜像的方法主要有两种,一种是在已有虚拟机上制作,另一种是以ISO的形势来制作。一下主要来自Eucalyptus Community官方文档的翻译和国内论坛的整理。

第一种在VM上制作镜像

该方法是在已经部署了Eucalyptus环境并且装有CentOS的VM上创建镜像步骤:
1、 运行一个实例。
2、 确保实例上有足够的空间创建新镜像。
3、 使用KVM创建一个文件系统,并且将它挂载:
~$mkfs –t ext3 /dev/vdb
~$mount /dev/vdb /mnt
4、 SCP 你的eucalyptus 绑定证书到实例的/mnt下:
~$scp –I yourkey.private euca2-xxxxxxx-x509.zip root@xxx.xxx.xxx.xxx:/mnt
5、 SSH到实例:
~$ssh –I yourkey.private root@xxx.xxx.xxx.xxx
6、 安装必备的工具:
~$yum install rsync unzip
7、 进入到/mnt(确保它有足够的空间来创建image):
~$cd /mnt
8、 解压eucalyptus证书到 /mnt/euca:
~$unzip euca2-admin-x509.zip -d euca/
9、 按照指导安装Euca2ools on CentOS 5。
10、安装软件到你要制作的image。
11、Source your Eucalyptus script:
/mnt/euca/eucarc
12、绑定image:
euca-bundle-vol -c ${EC2_CERT} -k ${EC2_PRIVATE_KEY} -u ${EC2_USER_ID} --ec2cert ${EUCALYPTUS_CERT} --no-inherit --kernel eki-47C7126D --ramdisk eri-80991354 -d /mnt -r x86_64 -p new.centos.5-3.x86-64.2GB.img -s 2048 -e /mnt,/root/.ssh

13、上传bundle:
euca-upload-bundle -b BUCKET_NAME -m /mnt/NEW_IMAGE_NAME.manifest.xml

如有"You do not have permission to access bucket: BUCKET_NAME" error。执行一下命令:
yum install -y ntp
ntpdate pool.ntp.org

14、注册bundle:
euca-register BUCKET_NAME/NEW_IMAGE_NAME.manifest.xml

另一个例子(原理基本相同,只是实现手段不同)

1. Run an instance of the image.
2. SCP your Eucalyptus credential bundle (i.e., euca2-xxxxx-x509.zip) to the instance.
3. SSH into the instance.
4. Change to the super user: sudo su
5. apt-get update && apt-get -y install python-dev libssl-dev swig help2man unzip rsync make wget curl
6. Change to the /mnt device (it should have enough space to create new image bundle - I use 5GB for mine).
7. Unzip your Eucalyptus credentials zip file under /mnt, and delete the zip file from the login directory (so it doesn't get bundled in the new image).
8. Download Euca2ools 1.2 source code and dependencies source code from Eucalyptus' download page.
9. Follow the instructions to build Euc2ools. Make sure to uninstall the old Euca2ools before building the new one, if it is installed on the instance (i.e., apt-get remove euca2ools).
10. Install any other software you want on the instance.
11. Remove the udev rules: rm /etc/udev/rules.d/70*
12. Change to the /mnt directory and source your Eucalyptus script:
cd /mnt

. eucarc
13. Bundle the image:

euca-bundle-image -c ${EC2_CERT} -k ${EC2_PRIVATE_KEY} -u ${EC2_USER_ID} --ec2cert ${EUCALYPTUS_CERT} --no-inherit --kernel eki-KKKKKKKK --ramdisk eri-RRRRRRRR -d /mnt -r ARCH -p NEW_IMAGE_NAME -s SIZE_IN_MBs
eki-KKKKKKKK -> same as with running instance

eri-RRRRRRRR -> same as with running instance
Example:
euca-bundle-image -c ${EC2_CERT} -k ${EC2_PRIVATE_KEY} -u ${EC2_USER_ID} --ec2cert ${EUCALYPTUS_CERT} --no-inherit --kernel eki-0A104321 --ramdisk eri-1B031216 -d /mnt -r x86_64 -p myimage -s 5120

14. Upload bundle:
euca-upload-bundle -b BUCKET_NAME -m /mnt/NEW_IMAGE_NAME.manifest.xml
Example:
euca-upload-bundle -b test1 -m /mnt/myimage.manifest.xml

15. Register bundle:
euca-register BUCKET_NAME/NEW_IMAGE_NAME.manifest.xml
Example:
euca-register test1/myimage.manifest.xml

第二种使用ISO在KVM中创建windows镜像

下面分三步制作EMI(eucalyptus machine image),EKI(eucalyptus kernel image),ERI(eucalyputs ramdisk image)。

第一步要制作EMI:

1、在~下创建virtualxp目录用来存放镜像文件:
~$mkdir virtualxp

2、创建一个用于执行windows安装的硬盘镜像,并可以设置该镜像的大小。例如,如下命令就创建了一个10GB的硬盘镜像win.img:
~$dd if=/dev/zero of=~/virtualxp/win.img bs=1M count=10000

3、放入winxp安装盘并执行以下命令(必须是安装盘,我没有测试ghost,论坛上说ghost
陈功):
~$kvm –m 1024 –boot d –cdrom /dev/cdrom –drive file=~/virtualxp/win.img,
If=scsi,boot=on

执行上述命令,将会在窗口虚拟环境qume下进入我们熟悉的windows xp安装,因为xp安装在一个“未被格式化的硬盘”的镜像(win.img)上,首先会要求分区,并且至少分成两个区,分区完了就直接安装,安装完成可能会假死,可以试着关闭窗口,通过如下命令进入我们刚装好的xp系统:
~$kvm -m 1024 -boot c -drive file=~/virtualxp/win.img,if=scsi,boot=on
-net nic,model=e1000

这两条命令可能会报错,基本不会影响安装,另外安装时间是超长,我前后用了2小时左右。

第二步制作EKI

在 /usr/lib/syslinux 下找到 memdisk,复制到 ~/virtualxp 下。(如果没有syslinux,可以下载安装:apt-get install syslinux)

第三步制作ERI

1、创建软盘镜像 win-boot.img:
~$dd if=/dev/zero of=~/virtualxp/win-boot.img bs=512 count=2880

2、以加载软盘的方式进入windows镜像
~$kvm -m 1024 -boot c -drive file=~/virtualxp/win.img,if=scsi,boot=on,index=1 -fda ~/virtualxp/win-boot.img

3、在进入镜像的xp系统后,找到 ntldr、ntdetect.com、sym_hi.sys boot.ini这四个隐藏文件,其中将 sym_hi.sys 改名为 Ntbootdd.sys,如果没有boot.ini创建一个 boot.ini 文件,内容如下:
[boot loader]
timeout=30
Default= multi(0)disk(0)rdisk(0)partition(1)\Windows
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP"

将上述的四个文件拷贝到软盘当中(先格式化),注意,这里说的软盘是指在KVM虚拟机中的xp系统所“看到”的软盘。

至此,windows xp的eucalyptus镜像基本制作完毕!

第四步是分别bundle 镜像到eucalyptus上:

这些操作跟绑定其他OS镜像基本上一致:
1、进入到 ~/virtualxp

2、绑定EKI
euca-bundle-image -i memdisk -d ./kernel --kernel true
euca-upload-bundle -b winxp-bucket -m ./kernel/memdisk.manifest.xml
euca-register winxp-bucket/memdisk.manifest.xml

3、绑定ERI
euca-bundle-image -i win-boot.img -d ./ramdisk --ramdisk true
euca-upload-bundle -b winxp-bucket -m ./ramdisk/win-boot.img.manifest.xml
euca-register winxp-bucket/win-boot.img.manifest.xml

4、绑定EMI
euca-bundle-image -i win.img -d ./image
euca-upload-bundle -b winxp-bucket -m ./image/win.img.manifest.xml
euca-register winxp-bucket/win.img.manifest.xml

这样windowsXP就可以在eucalyptus上使用。

第三种使用ISO在KVM中创建linux镜像

下面是步骤
1、创建虚拟硬盘用来安装系统,如下创建一个大小为4G的虚拟硬盘new.img:
~$dd if=/dev/zero of=new.img bs=1M count=4096

2、以CDROM模式启动KVM,new.img做为启动硬盘:
~$kvm -cdrom iso_image -drive if=scsi,file=new.img,boot=off

3、在虚拟窗口中选择一个分区正常安装系统。

NOTE: most distributions will remember the network interfaces by the MAC address so that interfaces will always be the same (that is eth0 and eth1 will no t be inverted accidentally). In Eucalyptus you have to get the distribution to forget the NIC, so that every instance will see the interface as the first interface. To do so you may want to see to the specific disrtibution: for example debian/ubuntu uses udev so check /etc/udev/rules.d/*net* while centos may have something in /etc/network-scripts/ifcfg-eth0. Failure to do so may leave your instance without network;

4、找到开始块和跟文件系统的大小,提取文件:
~$dd if=new.img of=rootfs.img bs=512 skip=63 count=2000

Rootfs.img 就是包含跟文件的系统,确保 kernel/initrd和img的兼容性。

总结

以上几种方法,从实现原理上都有一定的相似之处,即制作EMI,EKI,ERI,三部分。我制作了第二种windows镜像,经测试,可以运行在Eucalyptus环境下,但存在BUG,不能再次登录,初步分析是引导文件处许修改,正想办法解决。本文出自 “outlier” 博客,请务必保留此出处http://2823908.blog.51cto.com/2813908/796039
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: