2012/08/11

it jobs@104

微軟派
.net        4035
dot net        23
c#        1415
asp.net        1310
linq        17
ruby        238

非主流
php        2592
java        2684
delphi        249
perl        390
python        276
c++        8047

資料庫
sql server    767
sql2008        13
sql2005        10
mssql        151
ms sql        1696
oracle        2007
mysql        1185
postgresql    75
postgre        6
dba        135
sql        2703
mcdba        39

官方版
ccna        428
mcsa        28
mcse        265
mcp        112
mcitp        113
lpic        44
scsa        5
rhce        120

其他a
ms ad        60
exchange    348
vmware        247
xen        18
kvm        53
erp        4742
sap        1102
ios        466
android        1580
server        2008
centos        26
ubuntu        25
redhat        51
solaris        159

其他b
data mining            99
pattern mining            3
business intelligence        110
data warehouse            33
olap                26

2012/08/07

ubuntu 12.0.4 desktop & jdk-6u33-linux-i586.bin & eclipse-SDK-4.2-linux-gtk.tar.gz

#ubuntu 12.0.4 desktop
#jdk-6u33-linux-i586.bin
#eclipse-SDK-4.2-linux-gtk.tar.gz

$ sudo apt-get purge openjdk*

$ chmod +x jdk-6u33-linux-i586.bin

$ ./jdk-6u33-linux-i586.bin

$ sudo mv jdk1.6.0_33 /usr/lib/jvm/

$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/bin/java 1

$ java –version
$ sudo update-alternatives --config javac
$ java –version

$ tar -zxvf eclipse-SDK-4.2-linux-gtk.tar.gz

2012/08/03

ubuntu desktop 12.04 LTS + Workstation 8.0.2

#Ubuntu Desktop 12.04 + VMWare Workstation 8.0.2

[1]
download  VMWare Workstation 8.0.2

[2]
it work on the linux kernel 3.2
http://weltall.heliohost.org/wordpress/wp-content/uploads/2012/01/vmware802fixlinux320.tar.gz

tar xzvf file.tar.gz
sudo ./patch-modules_3.2.0.sh

[3]
sudo sh VMware-Workstation-8.0.2-123456.i386.bundle
sudo ./patch-modules_3.2.0.sh
 

2012/07/31

BIOS 嗶聲 2長8短

BIOS 在系統發生錯誤時會發出一些嗶聲 來警告使用者是哪裡出錯,在連螢幕都沒法顯示錯誤的訊息時嗶聲可以幫助
使用者來了解是哪裡出問題。

一、AMI BIOS
嗶聲數     錯誤     說明描述
1     記憶體Refresh有問題     記憶體恢復晶片有瑕疵
2     記憶體同位元檢查錯誤     記憶體的前64K等位檢查後有錯誤
3     前 64K 記憶區段檢測失敗     記憶體的前64K有瑕疵
4     系統計時器無法工作     主機板上的計時器無法工作
5     CPU錯誤     CPU 故障毀損
6     鍵盤控制器8048-A20 位址錯誤     鍵盤控制器(8042)壞了BIOS無法進入"保護模式"
7     CPU發生異常中斷     CPU產生了不正常的中斷
8     顯示卡未裝妥或視訊記憶體存取錯誤     找不到顯示卡或顯示卡計憶區有瑕疵
9     ROM  BIOS 檢查值錯誤     ROM 檢查值錯誤
10     CMOS  shutdown 暫存器讀寫錯誤     CMOS RAM 的關閉暫存器壞了
11     外部快取錯誤     主機板上的快取記憶體有瑕疵
1長3短     記憶體錯誤      
1長8短     顯示測試錯誤      

 二、AWARD BIOS
嗶聲     錯誤&描述
1 短聲     不是錯誤,系統正在開機
1 長聲,2 短聲     顯示卡或螢幕連接有錯誤
2 短聲     CMOS設定錯誤,螢幕顯示"按F 1 繼續"
1 長聲,3 短聲     鍵盤控制器錯誤
1 長聲 1 短聲     DRAM錯誤
1長聲 9 短聲     ROM錯誤
不斷長響     DRAM未插好
不停急響     電源有問題

三、IBM BIOS
嗶聲     錯誤&描述
無     電源供應器或主機板完全損壞
持續     主機板嚴重損壞
短聲     系統自我測試,情況正常
2 短聲     自我測試發現錯誤,錯誤訊息顯示在螢幕上
持續短聲     電源供應器或主機板損壞
1 長聲,1短聲     主機板有錯誤
1 長聲,2短聲     顯示卡(MDA、CGA)
1 長聲,3短聲     顯示卡(EGA)
3 長聲     鍵盤錯誤

四、PHOENIX BIOS
嗶聲     錯誤&描述
1 1 3     CMOS-RAM 的存取
1 1 4     ROM-BIOS 檢查值
1 2 1     可撰寫的計時器晶片 (8253)
1 2 2     直接記憶體存取途徑第 0 號之位址與 / 或計數暫存器
1 2 3     直接記憶體存取"頁暫存器"之讀寫
1 3 1     記憶體恢復
1 3 3     前 64K 記憶體之晶片或資料線
1 3 4     前 64K 記憶體有錯誤:單 / 雙邏輯錯誤
1 4 1     前 64K 記憶體有錯誤:位址匯流排
1 4 2     前 64K 記憶體中發生等位錯誤
1 4 3     安全計時器 (只有在 EISA BIOS 中才有)
1 4 4     非遮蔽中斷 (NMI) 介面的軟體 (只有在 EISA BIOS 中才有)
2 1 1     故障的前 64K 記憶體中之位元 0
2 1 2     故障的前 64K 記憶體中之位元 1
2 1 3     故障的前 64K 記憶體中之位元 2
2-2-3     ROM BIOS 檢查碼錯誤
3-1-1     記憶體充電失敗
3-1-3     鍵盤控制器 8042 錯誤
3-4-1     512K 位址解碼電路錯誤
3-4-3     512K 主記憶體錯誤
2-1-2-3     BIOS 版權遭修改
2-2-3-1     處理器發生異常中斷

Ref>
http://www.sljh.tcc.edu.tw/sl00/How2Use/biosmeg.htm

2012/06/01

如何開啟 Windows 中的自動登入

系統提示本篇文章的內容適用於其他版本的 Windows (不涵蓋您正在使用的版本) 。本篇文章的內容可能不適用您參考。瀏覽 Windows XP 解決方案中心

使用登錄編輯程式啟用自動登入

警告 如果您使用「登錄編輯程式」或其他方法不當地修改登錄,可能會發生嚴重問題。您可能需要重新安裝作業系統,才能解決這些問題。Microsoft 不保證可以解決這些問題。請自行承擔修改登錄的一切風險。
如果要使用「登錄編輯程式」(Regedt32.exe) 啟用自動登入,請依照下列步驟執行:
  1. 按一下 [開始],然後按一下 [執行]
  2. [開啟] 方塊中,輸入 Regedt32.exe,然後按下 ENTER。
  3. 在登錄中找出下列子機碼:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
  4. 按兩下 [DefaultUserName] 項目,輸入您的使用者名稱,然後按一下 [確定]
  5. 按兩下 [DefaultPassword] 項目,輸入您的密碼,然後按一下 [確定]注意:如果 DefaultPassword 值不存在,您必須新增該值。如果要新增這個值,請依照下列步驟執行:

    1. [編輯] 功能表上,按一下 [新增],然後指向 [字串值]
    2. 輸入 DefaultPassword,然後按 ENTER。
    3. 按兩下 [DefaultPassword]
    4. [編輯字串] 對話方塊中,輸入您的密碼,然後按一下 [確定]
    注意:如果沒有指定 DefaultPassword 字串,Windows 就會自動將 AutoAdminLogon 機碼的值從 1 (True) 變更為 0 (False),以停用 AutoAdminLogon 功能。
  6. [編輯] 功能表上,按一下 [新增],然後指向 [字串值]
  7. 輸入 AutoAdminLogon,然後按 ENTER。
  8. 按兩下 [AutoAdminLogon]
  9. [編輯字串] 對話方塊中,輸入 1,然後按一下 [確定]
  10. 結束 [登錄編輯程式]。
  11. 按一下 [開始],按一下 [關機],然後在 [註解] 文字方塊中輸入原因。
  12. 按一下 [確定] 以關閉您的電腦。
  13. 重新啟動您的電腦。現在,您已經可以自動登入。
注意 如果要略過 AutoAdminLogon 程序,並以不同的使用者身分登入,請在登出或 Windows 重新啟動之後,按住 SHIFT 鍵。

如果群組原則物件 (GPO) 或本機原則在伺服器上定義「登入標誌」,登錄變更將不會生效。當原則變更為不會影響伺服器時,這個功能就會如預期般運作。

伺服器上存有不同使用者的互動式主控台在登入時,會將 DefaultUserName 登錄項目變更為最後登入的使用者指標。AutoAdminLogon 會依賴 DefaultUserName 項目來配對使用者和密碼,因此 AutoAdminLogon 可能會失敗。您可以設定關機指令碼,為 AutoAdminLogonAs 設定正確的 DefaultUserName 項目。 如需詳細資訊,請按一下下面的文件編號,檢視「Microsoft 知識庫」中的文件:
119364  AutoAdminLogon Loses DefaultUserName 
Ref>
http://support.microsoft.com/kb/324737/zh-tw


[1]
Windows Server 2003 每次開機都要輸入"Ctrl+Alt+Del",然後再輸入用戶名和密碼才能登錄。
這樣設定總是感覺很麻煩。網路搜尋了許久,終於讓我找到方法啦~~
可以透過以下方法實現自動登錄:
1.點選 開始 > 執行
2.在"執行"視窗中輸入"control userpasswords2"後點選"確定"
3.此時就會開啟"使用者帳戶"視窗
4.將"必須輸入使用者名稱和密碼,才能使用這台電腦"選項取消勾選後點選"確定"
5.系統會跳出"自動登入"視窗,輸入"密碼"及"確認密碼"後點選"確定"
6.這樣就可以囉,重新開機就會自動登入到桌面,若要取消自動登入只要將選項勾選即可

[2]
Windows Server 2003 自動登入
簡單的說就是 Regedit -> Winlogon -> DefaultUserName / DefaultPassword / AutoAdminLogon=1 


1. 按「開始」,然後按「執行」。
2. 在「開啟」 方塊中,輸入 Regedt32.exe,然後按下 ENTER。
3. 在登錄中找出下列子機碼:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
4. 按兩下「DefaultUserName」 項目,輸入您的使用者名稱,然後按「確定」。
5. 按兩下「DefaultPassword」 項目,輸入您的密碼,然後按「確定」。注意:如果 DefaultPassword 值不存在,您必須新增該值。如果要新增這個值,請依照下列步驟執行:

5.1. 在「編輯」 功能表上,按「新增」,然後指向「字串值」。
5.2. 輸入 DefaultPassword,然後按 ENTER。
5.3. 按兩下「DefaultPassword」。
5.4. 在「編輯字串」 對話方塊中,輸入您的密碼,然後按「確定」。
注意:如果沒有指定 DefaultPassword 字串,Windows 就會自動將 AutoAdminLogon 機碼的值從 1 (True) 變更為 0 (False),以停用 AutoAdminLogon 功能。
6. 在「編輯」 功能表上,按「新增」,然後指向「字串值」。
7. 輸入 AutoAdminLogon,然後按 ENTER。
8. 按兩下「AutoAdminLogon」。
9. 在「編輯字串」 對話方塊中,輸入 1,然後按「確定」。
10. 結束「登錄編輯程式」。
11. 按「開始」,按「關機」,然後在「註解」 文字方塊中輸入原因。
12. 按「確定」 以關閉您的電腦。
13. 重新啟動您的電腦。現在,您已經可以自動登入。
注意 如果要略過 AutoAdminLogon 程序,並以不同的使用者身分登入,請在登出或 Windows 重新啟動之後,按住 SHIFT 鍵。
http://support.microsoft.com/kb/324737

2012/04/29

为 OpenStack Nova 制作 Windows 镜像

Ref>

http://www.vpsee.com/2011/06/create-windows-kvm-image-for-openstack-nova/

为 OpenStack Nova 制作 Windows 镜像

2011年06月22日 | 标签: cloud, kvm, nova, openstack, ubuntu, windows | 作者:vpsee

上次 VPSee 给 OpenStack Nova 制作 Ubuntu 镜像的 时候忘了介绍制作 Windows 镜像和在 Nova 上运行 Windows 虚拟机的情况,前几天刚好有人在微薄上问到这个问题。在 Nova 上运行 Windows 的虚拟机其实很容易,和运行 Linux 虚拟机差不多:先制作一个 Windows 虚拟机镜像(模板),然后再以这个镜像为模板来创建 Windows 虚拟机(实例)。

安装 Windows 镜像

创建一个 10GB 大小的 “硬盘”(raw 格式):

$ kvm-img create -f raw windowsxp.img 10G
Formatting 'windowsxp.img', fmt=raw size=10737418240

openstack 启动虚拟机实例的时候使用的是 virtio 接口,但是 windows 默认没有这个接口的驱动,所以需要额外的驱动。然后使用 ISO 文件的 windowsxp.iso 安装盘来安装 Windows:

$ wget http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/
virtio-win-1.1.16.vfd

$ sudo kvm -m 1024 -cdrom windowsxp.iso -drive file=windowsxp.img,if=virtio,boot=on \
-fda virtio-win-1.1.16.vfd -boot d -nographic -vnc :0

在另外一台机器上使用 vnc 客户端就可以看到 windows 安装过程和进行操作:

$ vncview 172.16.39.111:5900

安装完 windows 后可以进行一些必要的定制,比如打开 RDP 访问、设置防火墙不要屏蔽 RDP 等,这时候也可以安装一些必要软件,要注意的是这个是以后的模板,要尽量保持系统原样,最好不要做定制也不要装任何软件,可以留给客户自己做,定制这东西 每个人口味都不同。

发布 Windows 镜像

windows 虚拟机镜像做好以后就可以发布到云里了,注册镜像后会得到一个标志符 ami-00000004,以后就用这个 ami-00000004 来识别云里面的镜像(还记得我们上次做的 ubuntu 镜像的标志符是 ami-00000003 吗?):

$ euca-bundle-image -i windowsxp.img
Checking image
Encrypting image
Splitting image...
Part: windowsxp.img.part.00
Part: windowsxp.img.part.01
...
Part: windowsxp.img.part.65
Generating manifest /tmp/windowsxp.img.manifest.xml

$ euca-upload-bundle -b mybucket -m /tmp/windowsxp.img.manifest.xml
Checking bucket: mybucket
Uploading manifest file
Uploading part: windowsxp.img.part.00
...
Uploading part: windowsxp.img.part.65
Uploaded image as mybucket/windowsxp.img.manifest.xml

$ euca-register mybucket/windowsxp.img.manifest.xml
IMAGE ami-00000004

检验一下 windows 镜像是否上传成功,ami-00000004 就是我们刚做的 windows 镜像:

$ euca-describe-images
IMAGE aki-00000001 mybucket/vmlinuz-2.6.32-28-server.manifest.xml  available public  x86_64 kernel
IMAGE ari-00000002 mybucket/initrd.img-2.6.32-28-server.manifest.xml  available public  x86_64 ramdisk
IMAGE ami-00000003 mybucket/ubuntutemplate.img.manifest.xml  available public  x86_64 machine aki-00000001 ari-00000002
IMAGE ami-00000004 mybucket/windowsxp.img.manifest.xml  untarring public  x86_64 machine

第一个 Windows 虚拟机实例

有了这个 windows 模板(镜像)以后我们就可以以这个 “镜像” 为模板来为云计算用户创建 n 个 windows 虚拟机,运行之前需要 key:

$ euca-describe-keypairs
KEYPAIR mykey 76:7d:93:88:a0:e5:3e:5d:4b:62:cd:85:c5:23:7a:05

$ euca-run-instances -k mykey -t m1.small ami-00000004
RESERVATION r-er0zkjm7 mycloud default
INSTANCE i-00000003 ami-00000004   scheduling mykey (mycloud, None) 0 m1.small 2011-06-20T14:08:45Z unknown zone

然后用 nova-manage 命令检查是否成功运行 windows 虚拟机,状态栏 state 应该是 running 状态:

$ sudo nova-manage vm list
instance   node            type       state      launched            image        kernel       ramdisk       project    user       zone       index
i-00000003 node01           running    2011-06-20 14:12:49 7                                       mycloud    vpsee       None       0

大功告成,用一个 RDP 客户端连接 windows 就可以了(这个 windows 云虚拟机使用的是内部 IP):

# rdesktop 192.168.3.4

为 OpenStack Nova 制作 CentOS 镜像

Ref>

http://www.vpsee.com/2012/02/create-centos-kvm-image-for-openstack-nova/

为 OpenStack Nova 制作 CentOS 镜像

2012年02月2日 | 标签: centos, cloud, kvm, nova, openstack | 作者:vpsee

做 CentOS 镜像的过程和去年写的那篇为 OpenStack Nova 制作 Ubuntu 镜像的 步骤差不多,不过这半年 OpenStack 发展神速,比以前要稳定多了,有些步骤可以省了,而且有些命令工具、参数、功能都有改动,比如以前的 uec-publish-image 改成了现在的 cloud-publish-image,功能也有变化。下面的制作镜像步骤在 Ubuntu 11.10 + OpenStack Diablo Release 上完成。
安装 CentOS 镜像

下载要安装的 CentOS 版本,这里选用最新的 CentOS 6.2:

$ wget http://mirrors.kernel.org/centos/6.2/isos/x86_64/CentOS-6.2-x86_64-minimal.iso

创建一个 10GB 大小的 “硬盘”(raw 格式),最好用一个较小的 “硬盘”,体积太大提交到云里会花很长时间,而且每次运行实例也会花很长时间:

$ kvm-img create -f raw centos.img 10G
Formatting 'centos.img', fmt=raw size=10737418240

使用刚才下载的 CentOS “安装盘” 和刚创建的 “硬盘” 引导启动系统,用 -vnc 参数打开 vnc 访问,这样可以从其他机器登录到这个界面安装系统:

$ sudo kvm -m 512 -cdrom CentOS-6.2-x86_64-minimal.iso \
-drive file=centos.img -boot d -net nic -net tap -nographic -vnc :0

用 vncviewer 登录后按照屏幕提示完成 CentOS 安装。需要注意的是在分区阶段把 10GB 硬盘全部划分成一个 ext4 root 分区,不要创建多个分区也不要创建 swap 区:

$ vncviewer 172.16.39.111:5900

安装完后会自动重启,如果没有重启的话按照下面的命令启动刚刚安装好的虚拟机镜像 centos.img,如果出现 failed to find romfile “pxe-rtf8139.bin” 的错误提示可以通过安装 kvm-pxe 解决:

$ sudo kvm -m 512 -drive file=centos.img -boot c -net nic -net tap \
-nographic -vnc :0
kvm: pci_add_option_rom: failed to find romfile "pxe-rtl8139.bin"

$ sudo apt-get install kvm-pxe

再次用 vnc 登录虚拟机镜像,安装一些必要工具(因为这个镜像将会是模板,所以最好保持最简最小化):

$ vncviewer 172.16.39.111:5900

# yum update
# yum upgrade
# yum install openssh-server
# chkconfig sshd on

修改分区加载表(/etc/fstab),注释或删除以前的,加上 UUID=cec-rootfs 一行:

# vi /etc/fstab
#UUID=47a90bea-2d88-4c82-a335-09c1533b1538 / ext4 defaults 1 1
LABEL=cec-rootfs                           / ext4 defaults 0 0

在网络接口配置里面注释或删除这行 #HWADDR= 一行,启用 DHCP:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
#HWADDR="00:11:22:12:34:56"
#NM_CONTROLLED="yes"
BOOTPROTO=dhcp
ONBOOT="yes"

注射 ssh key 以便外界可以用 ssh -i mykey.priv root@host 的形式无密码登录到虚拟机实例,在 /etc/rc.local 文件中加入下面这些:

# vi /etc/rc.local
...
mkdir -p /root/.ssh
echo >> /root/.ssh/authorized_keys
curl -m 10 -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key
| grep 'ssh-rsa' >> /root/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
echo "AUTHORIZED_KEYS:"
echo "--------------------"
cat /root/.ssh/authorized_keys
echo "--------------------"

别忘了还需要修改 sshd 的配置实现无密码登录:

# vi /etc/ssh/sshd_config
...
RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin without-password
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no

需要关闭 SELINUX,否则即使上面 ssh 设定允许 root 无密码登录也无效:

# vi /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted

70-persistent-net.rules 会自动添加其他的网络接口,需要删除这个文件避免自动添加除了 eth0 以外的接口,关闭虚拟机准备发布镜像:

# rm -rf /etc/udev/rules.d/70-persistent-net.rules

# shutdown -h now

发布 CentOS 镜像

CentOS 镜像已经做好了,现在可以发布到云里了:

$ cloud-publish-image amd64 centos.img mybucket
ami-00000007    mybucket/centos.img.manifest.xml

等待一段时间后出现 ami-00000008 mybucket/centos.img.manifest.xml 表示我们刚制作的 CentOS 镜像已经正式发布到云里,以后就可以以这个镜像为模板来快速生成虚拟机实例(instance)。可以通过 euca-describe-images 来查看:

$ euca-describe-images
IMAGE ami-00000008 images/centos.img.manifest.xml  available private  x86_64 machine     instance-store

第一个 CentOS 虚拟机实例

有了 CentOS 镜像(模板)以后我们就可以以这个 “镜像” 为模板来为云计算用户创建 n 个 CentOS 虚拟机(操作系统)实例,不过在运行实例之前需要 key:

$ euca-add-keypair mykey > mykey.priv
$ chmod 600 mykey.priv

$ euca-describe-keypairs
KEYPAIR mykey 76:7d:93:88:a0:e5:3e:5d:4b:62:cd:85:c5:23:7a:05

$ euca-run-instances -k mykey -t m1.small ami-00000008
RESERVATION r-hzwwif81 vpseecloud default
INSTANCE i-0000002a ami-00000008 pending vpsee (vpseecloud, None) 0  m1.small 2012-02-01T14:26:51Z unknown zone aki-00000001 ami-00000000

上面使用 euca-run-instances 创建一个实例后可以用 nova-manage 命令看到:

$ euca-describe-instances
RESERVATION r-z973l7mm vpseecloud default
INSTANCE i-0000002a ami-00000008 172.16.39.200 172.16.39.200 running vpsee (vpseecloud, cloud00) 0  m1.small 2012-02-01T13:56:02Z nova ami-00000000 ami-00000000

还记得在 Ubuntu 上安装和配置 OpenStack Nova 的创建网络部分吗?看看现在云里面 IP 的分配情况:

$ sudo nova-manage network list
id    IPv4               IPv6            start address   DNS1            DNS2            VlanID          project         uuid
1     172.16.38.0/23     None            172.16.38.2     8.8.4.4         None            None            None            None

刚才用 euca-run-instances 启动的一个 ubuntu 虚拟机实例的 IP 就是从 172.16.38.2 开始的,目前分配的 IP 是 172.16.39.200(从 euca-describe-instances 可以看出来),所以 ssh 登录这个 IP 就登上了我们的 CentOS 云虚拟机:

$ ssh -i mykey.priv root@172.16.39.200
[root@server-25 ~]#

想制作 Windows 虚拟机镜像的话可以看这篇:为 OpenStack Nova 制作 Windows 镜像

为 OpenStack Nova 制作 Ubuntu 镜像

Ref>

http://www.vpsee.com/2011/06/create-ubuntu-kvm-image-for-openstack-nova/

为 OpenStack Nova 制作 Ubuntu 镜像

2011年06月9日 | 标签: cloud, kvm, nova, openstack, ubuntu | 作者:vpsee

最近超级忙,被 Mesh Potato 的项目折腾的不行,发现只要什么东西沾上 “分布式、集群” 这些东西事情就变得格外复杂,一台 Asterisk 服务器做 VoIP 容易,n 台 Asterisk 服务器做集群就不容易;一台 Xen/KVM 服务器做虚拟机容易,n 台 Xen/KVM 服务器做云计算就不是那么容易。上星期我们介绍了在 Ubuntu 上安装和配置 OpenStack Nova, 今天来进一步介绍如何在 OpenStack Nova 环境里制作虚拟机模板(镜像)以及创建虚拟机运行实例(以 Ubuntu 为例子)。为了和我们平时说的 “VMware/Xen/KVM/VirtualBox 虚拟机” 区分开,VPSee 在这里把在 OpenStack Nova、OpenNebula 这样的云计算平台上运行的虚拟机称为 “云虚拟机”。简单说在 OpenStack Nova 平台上运行一个 ubuntu 虚拟机的流程是:先制作一个 ubuntu 虚拟机镜像(模板),然后再以这个镜像为模板来创建 ubuntu 虚拟机(实例)。
安装 Ubuntu 镜像

首先下载要安装的 ubuntu 版本:

$ wget http://releases.ubuntu.com/lucid/ubuntu-10.04.2-server-amd64.iso

创建一个 10GB 大小的 “硬盘”(raw 格式):

$ kvm-img create -f raw ubuntu.img 10G
Formatting 'ubuntu.img', fmt=raw size=10737418240

使用刚才下载的 ubuntu “安装盘” 和刚创建的 “硬盘” 引导启动系统,为了简单起见,VPSee 在这里使用 kvm 虚拟技术,避开 xen 繁琐的配置。-vnc 参数代表打开 vnc 访问,以便可以用其他机器远程登录到这个引导界面进行安装操作:

$ sudo kvm -m 512 -cdrom ubuntu-10.04.2-server-amd64.iso \
-drive file=ubuntu.img -boot d -nographic -vnc :0

用 vncviewer 登录引导界面后按照屏幕的提示完成 ubuntu 的安装工作(和在自己电脑上安装 ubuntu 过程一样)。需要注意的是在分区阶段把 10GB 硬盘全部划分成一个 ext4 root 分区,不要创建多个分区也不要创建 swap 区:

$ vncviewer 172.16.39.111:5900

安装完后退出(必要时 kill 掉 kvm 进程),按照下面命令启动刚刚安装好的虚拟机镜像 ubuntu.img,如果出现 failed to find romfile “pxe-rtf8139.bin” 的错误提示可以通过安装 kvm-pxe 解决:

$ sudo kvm -m 512 -drive file=ubuntu.img -boot c -nographic -vnc :0
kvm: pci_add_option_rom: failed to find romfile "pxe-rtl8139.bin"

$ sudo apt-get install kvm-pxe

再次用 vnc 登录虚拟机镜像,安装一些必要工具(因为这个镜像将会是模板,所以最好保持最简最小化,不要乱装东西):

$ vncviewer 172.16.39.111:5900

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install openssh-server cloud-init

70-persistent-net.rules 会自动添加其他的网络接口,需要删除这个文件避免自动添加除了 eth0 以外的接口。删除后系统基本就准备好了,关闭虚拟机:

$ sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules

$ sudo shutdown -h now

调整 Ubuntu 镜像

因为 OpenStack 只接受 ext4 文件系统格式的镜像,所以需要把上面创建的 raw 镜像(kvm-img create -f raw)转换成 ext4 镜像。下面的步骤用来找出镜像文件里面的分区起点是从哪里开始的:

$ sudo losetup -f ubuntu.img
$ sudo losetup -a
/dev/loop0: [fb00]:24117291 (/home/vpsee/ubuntu.img)

$ sudo fdisk -cul /dev/loop0

Disk /dev/loop0: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000502e6

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1   *        2048    20969471    10483712   83  Linux

上面最后一行显示分区是从扇区(sector)2048开始的,每个扇区是512个字节,所以是从 2048 x 512 = 1048576个字节开始的。记住这个1048576,下面会用到。

卸载 loop 后重新从1048576字节开始挂载:

$ sudo losetup -d /dev/loop0

$ sudo losetup -f -o 1048576 ubuntu.img
$ sudo losetup -a
/dev/loop0: [fb00]:24117291 (/home/vpsee/ubuntu.img), offset 1048576

把这整个分区拷贝到一个新文件就是一个我们要的 ext4 文件系统镜像:

$ sudo dd if=/dev/loop0 of=ubuntutemplate.img
20969472+0 records in
20969472+0 records out
10736369664 bytes (11 GB) copied, 107.455 s, 99.9 MB/s

用完 loop 后记得卸载:

$ sudo losetup -d /dev/loop0

挂载(mount)刚创建的 ext4 文件系统镜像,并修改分区加载表(/etc/fstab),注释或删除以前的,加上 UUID=uec-rootfs 一行:

$ sudo mount -o loop ubuntutemplate.img /mnt

$ sudo vi /mnt/etc/fstab
#UUID=1dc3a59e-faab-41ee-b232-3300163676bf / ext4 errors=remount-ro 0 1
UUID=uec-rootfs                           / ext4 defaults          0 0

把内核(vmlinuz)和内存盘(initrd)文件拷贝出来以便后面和虚拟机镜像一起发布到OpenStack 云里。使用完虚拟机镜像后记得卸载(unmount):

$ sudo cp /mnt/boot/vmlinuz-2.6.32-28-server /home/vpsee/
$ sudo cp /mnt/boot/initrd.img-2.6.32-28-server /home/vpsee/

$ sudo umount /mnt

把刚才的虚拟机镜像 ubuntutemplate.img 的文件系统标志改成 ‘uec-rootfs’:

$ sudo tune2fs -L uec-rootfs ubuntutemplate.img
tune2fs 1.41.14 (22-Dec-2010)

发布 Ubuntu 镜像

好了,ubuntu 镜像已经做好了,现在可以发布到云里了,需要3个东西,虚拟机的内核文件、虚拟机的内存盘文件和虚拟机镜像文件:

$ uec-publish-image -t image --kernel-file vmlinuz-2.6.32-28-server \
--ramdisk-file initrd.img-2.6.32-28-server amd64 ubuntutemplate.img mybucket
ami-00000006 mybucket/ubuntutemplate.img.manifest.xml

等待一段时间后出现 ami-00000006 mybucket/ubuntutemplate.img.manifest.xml 表示我们刚制作的 ubuntu 镜像已经正式发布到云里,以后就可以以这个镜像为模板来快速生成虚拟机实例(instance)。可以通过 euca-describe-images 来查看:

$ euca-describe-images

IMAGE aki-00000001 mybucket/vmlinuz-2.6.32-28-server.manifest.xml  availablpublic  x86_64 kernel
IMAGE ari-00000002  mybucket/initrd.img-2.6.32-28-server.manifest.xml  available public  x86_64 ramdisk
IMAGE ami-00000003 mybucket/ubuntutemplate.img.manifest.xml  untarring public  x86_64 machine aki-00000001 ari-00000002

第一个 Ubuntu 虚拟机实例

有了 ubuntu 镜像(模板)以后我们就可以以这个 “镜像” 为模板来为云计算用户创建 n 个 ubuntu 虚拟机(操作系统)实例,不过在运行实例之前需要 key:

$ euca-add-keypair mykey > mykey.priv
$ chmod 600 mykey.priv

$ euca-describe-keypairs
KEYPAIR mykey 76:7d:93:88:a0:e5:3e:5d:4b:62:cd:85:c5:23:7a:05

$ euca-run-instances -k mykey -t m1.tiny ami-00000003
RESERVATION r-n0lpdme5 vpseecloud default
INSTANCE i-00000001 ami-00000003   scheduling mykey (vpseecloud, None) 0  m1.tin2011-05-20T14:00:34Z unknown zone

上面使用 euca-run-instances 创建一个实例后可以用 nova-manage 命令看到:

$ sudo nova-manage vm list
instance   node            type       state      launched            image        kernel       ramdisk       project    user       zone       index
i-00000001 node01           launching  None                3            1            2             vpseecloud    vpsee       None       0

还记得上篇:在 Ubuntu 上安装和配置 OpenStack Nova 的创建网络部分吗?可以看看现在的云里面 IP 分配情况:

$ sudo nova-manage network list
network            netmask         start address   DNS
192.168.3.0/25     255.255.255.128 192.168.3.3     None

刚才用 euca-run-instances 启动的一个 ubuntu 虚拟机实例的 IP 就是从 192.168.3.3 开始的,所以 ssh 登录这个 IP 就登上了我们的第一个云虚拟机:)

$ ssh 192.168.3.3
vpsee@i-00000001:~$

想制作 CentOS 虚拟机镜像的话可以看:为 OpenStack Nova 制作 CentOS 镜像;想制作 Windows 虚拟机镜像的话可以看:为 OpenStack Nova 制作 Windows 镜像

重置 OpenStack Nova 数据库

Ref>

http://www.vpsee.com/2011/12/reset-openstack-nova-database/

重置 OpenStack Nova 数据库

2011年12月16日 | 标签: cloud, database, openstack nova | 作者:vpsee

如果使用 OpenStack 的时候遇到莫名其妙的问题,或者直接操作 OpenStack 数据表的时候把里面的关系或记录搞砸了,或者使用一些从网上抄来连自己都不理解的命令把数据库记录弄乱了,或者自己想推倒重来等等,碰到这些问题的时候大家想到的第一个办法就是“重装系统,重装 OpenStack”,其实大部分时候都不必要重装,只需要重置一下数据库就可以了,避免重复劳动把操作命令整理到下面的简单脚本里:

#!/bin/bash

# Reset nova database and restart nova services

# written by vpsee.com

# Delete the database and create a new one

mysql -u root -ppassword -e "drop database nova;"

mysql -u root -ppassword -e "create database nova;"

mysql -u root -ppassword -e "set password for 'root'@'%'=password('password');"

mysql -u root -ppassword -e "grant all privileges on *.* to 'root'@'%';"

# Sync up the database scheme

nova-manage db sync

# Create a network

nova-manage network create private 10.0.1.0/24 1 256

nova-manage floating create 192.168.2.240/28

# Create a admin user and a project and assign the admin user to it

nova-manage user admin vpsee

nova-manage project create vpseecloud vpsee

# Restart all the services

restart libvirt-bin

restart nova-api

restart nova-scheduler

restart nova-network

restart nova-volume

restart nova-compute

# Create novarc

nova-manage project zipfile vpseecloud vpsee

unzip nova.zip

. novarc

# Allowing icmp and ssh access to instances

euca-authorize -P icmp -t -1:-1 default

euca-authorize -P tcp -p 22 default

# Create a keypair

euca-add-keypair vpsee > vpsee.priv

chmod 600 vpsee.priv

Warning: failed to parse error message from AWS: :1:0: syntax error

Ref>
http://www.vpsee.com/2011/12/how-to-solve-failed-to-parse-error-message-from-aws-problem/

解决 Warning: failed to parse error message from AWS: :1:0: syntax error 问题

2011年12月6日 | 标签: openstack nova | 作者:vpsee

Warning: failed to parse error message from AWS: :1:0: syntax error 是个常见问题,很多朋友都在 Ubuntu 上安装和配置 OpenStack Nova 的时候遇到,100楼,120和120楼都遇到这个问题。引起这个问题的原因很多。如果遇到 nova-manage service list 服务都正常而 euca-describe-availability-zones verbose 报错的情况通常都是因为 novarc 这个文件捣鬼,nova 不能正确读取 novarc 里面的权限设置使得认证失败,认证失败当然也就不能正确执行命令了。
# nova-manage service list
Binary           Host      Zone        Status     State Updated_At
nova-scheduler   vpsee     nova        enabled    :-)   2011-12-05 13:26:51
nova-volume      vpsee     nova        enabled    :-)   2011-12-05 13:26:49
nova-network     vpsee     nova        enabled    :-)   2011-12-05 13:26:51
nova-compute     vpsee     nova        enabled    :-)   2011-12-05 13:26:52

# euca-describe-availability-zones verbose
Warning: failed to parse error message from AWS: :1:0: syntax error
None: None
修改 nova.conf 文件,在末尾明确加上 –use_deprecated_auth=true 这行(这个设置本来是默认的,以前版本的 OpenStack Nova 是不需要的),然后重启 nova 服务并重新生成 novacreds.zip,记得一定要 source novarc 哟:
# vi /etc/nova/nova.conf
...
--use_deprecated_auth=true

# restart libvirt-bin; restart nova-network; restart nova-compute;
restart nova-api; restart nova-objectstore; restart nova-scheduler;
restart nova-volume; restart glance-api; restart glance-registry

# nova-manage project zipfile mycloud vpsee /home/vpsee/creds/novacreds.zip
# cd /home/vpsee/creds
# unzip novacreds.zip
# chown -R vpsee:vpsee /home/vpsee/creds/

# source /home/vpsee/creds/novarc

# euca-describe-availability-zones verbose
AVAILABILITYZONE nova available
AVAILABILITYZONE |- vpsee
AVAILABILITYZONE | |- nova-scheduler enabled :-) 2011-12-05 13:32:44
AVAILABILITYZONE | |- nova-volume enabled :-) 2011-12-05 13:32:43
AVAILABILITYZONE | |- nova-network enabled :-) 2011-12-05 13:32:44
AVAILABILITYZONE | |- nova-compute enabled :-) 2011-12-05 13:32:47
再附带一句,OpenStack 正在飞速发展中,这样或那样的问题也许在新版本里就不存在了,以前没有的问题也可能第一次出现在新版本中。


error_deleting @OpenStack Nova Volume

Ref>

http://www.vpsee.com/2011/09/how-to-delete-a-openstack-nova-volume-when-the-status-is-error_deleting/

删除 OpenStack Nova Volume 时遇到的 error_deleting 问题

2011年09月15日 | 标签: cloud, lvm, openstack nova, volume | 作者:vpsee

前段时间 VPSee 在 OpenStack Nova 上删除一个 volume 的时候(vol-00000002)报错,检查了一下 volume 的状态是 error_deleting 然后就无法删除了,不管用 euca-delete-volume 还是 nova-manage volume delete 都无法删除。

# euca-delete-volume vol-00000002
ApiError: ApiError: Volume status must be available

# euca-describe-volumes
VOLUME vol-00000002  10  nova error_deleting (mycloud, node01, None, None) 2011-08-30T13:15:24Z
VOLUME vol-00000003  10  nova available (mycloud, node01, None, None) 2011-08-30T13:20:04Z

查了一下要删除的 volume-00000002 的情况:

# lvdisplay
...
--- Logical volume ---
  LV Name                /dev/nova-volumes/volume-00000002
  VG Name                nova-volumes
  LV UUID                UgOwdr-W61E-MrdG-PrdY-IToa-LBi8-2XJjXF
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:2
...

既然用工具没法删除的话就干脆从数据库里直接删除,无非就是一条记录而已,先从 nova 数据库里找到这条 volume 记录并设置状态为 deleted,然后删除实际对应的 LVM. 从数据库里找到相应的表和记录后设置 status 为 deleted 状态:

# mysql -u root -p
Enter password:

mysql> use nova;

mysql> select status,id from volumes;
+----------------+----+
| status         | id |
+----------------+----+
| creating       |  1 |
| error_deleting |  2 |
| available      |  3 |
+----------------+----+
3 rows in set (0.00 sec)

mysql> update volumes set status='deleted' where id='2';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

退出 mysql 数据库操作回到命令行就会看到 vol-00000002 的状态是 deleted 的,然后用 lvmremove 命令删除:

# euca-describe-volumes
VOLUME vol-00000002  10  nova deleted (mycloud, node01, None, None) 2011-08-30T13:15:24Z

# ls /dev/nova-volumes/
volume-00000002 volume-00000003

# lvremove /dev/nova-volumes/volume-00000002
Do you really want to remove active logical volume volume-00000002? [y/n]: y
  Logical volume "volume-00000002" successfully removed

最后用 nova-manage 命令从数据库里彻底删除 vol-00000002(当然也可以直接在 mysql 里用 SQL 语句操作删除对应的记录 DELETE FROM volumes WHERE id=’2′;):

# nova-manage volume delete vol-00000002

# euca-describe-volumes
VOLUME vol-00000003  10  nova available (mycloud, node01, None, None) 2011-08-30T13:20:0

DataSourceEc2.py[WARNING]: 'http://169.254.169.254' failed: url error

Ref>

http://www.vpsee.com/2011/11/how-to-solve-datasourceec2-pywarning-http169-254-169-254-failed-url-error-problem/

解决 DataSourceEc2.py[WARNING]: ‘http://169.254.169.254′ failed: url error 问题

2011年11月1日 | 标签: openstack nova | 作者:vpsee

上周在一台 Ubuntu 11.10 服务器上安装和配置 OpenStack Nova 后,上传一个从 Ubuntu 官方下载的 oneiric-server-cloudimg-amd64.tar.gz 模板,然后启动一个 Ubuntu 11.10 实例(instance)的时候过了很长时间才能从 vnc 看到 Ubuntu login: 界面,打印出终端输出结果如下,貌似系统多次尝试从 http://169.254.169.254 得到 metadata 失败:

# euca-run-instances -k vpsee -t m1.tiny ami-00000002

# euca-get-console-output i-00000128
...
[    0.980222] init: lxcguest pre-start process (57) terminated with status 1
cloud-init start-local running: Mon, 24 Oct 2011 13:19:49 +0000. up 2.61 seconds
no instance data found in start-local
ci-info: lo    : 1 127.0.0.1       255.0.0.0
ci-info: eth0  : 1 172.16.38.2     255.255.254.0   02:16:3e:4f:61:4e
ci-info: route-0: 0.0.0.0         172.16.38.1     0.0.0.0         eth0   UG
ci-info: route-1: 172.16.38.0     0.0.0.0         255.255.254.0   eth0   U
cloud-init start running: Mon, 24 Oct 2011 13:19:52 +0000. up 5.23 seconds
2011-10-24 13:19:55,312 - DataSourceEc2.py[WARNING]: 'http://169.254.169.254' failed: url error [timed out]
2011-10-24 13:19:59,321 - DataSourceEc2.py[WARNING]: 'http://169.254.169.254' failed: url error [timed out]
2011-10-24 13:20:31,944 - DataSourceEc2.py[CRITICAL]: giving up on md after 208 seconds
...

找了一下资料发现网上有人用绑定 169.254.169.254 到 eth0 的办法,不过 VPSee 试了行不通。

$ sudo ip addr add 169.254.169.254/32 scope link dev eth0

metadata 的转发需要网关来完成,但是从下面的代码(nova/network/linux_net.py)来看,nova 只在 FlatDHCPManager 和 VlanManager 网络模式下调用 metadata_forward() 函数,nova 在 FlatManager 网络模式下不做任何设置,所以需要手动配置 iptable 转发 169.254.169.254 的 80 端口到 nova api 服务器上(网关)。

def metadata_forward():
    """Create forwarding rule for metadata"""
    _confirm_rule("PREROUTING", "-t nat -s 0.0.0.0/0 "
             "-d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT "
             "--to-destination %s:%s" % (FLAGS.ec2_dmz_host, FLAGS.ec2_port))

所以解决办法有两个,要么在网关(nova api 所运行的服务器)上手动运行 iptable 定向端口:

$ sudo iptables -t nat -A PREROUTING -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination 172.16.39.110:8773

要么改变 nova.conf 配置使用 FlatDHCPManager 模式:

$ sudo vi /etc/nova/nova.conf
--daemonize=1
--dhcpbridge_flagfile=/etc/nova/nova.conf
--dhcpbridge=/usr/bin/nova-dhcpbridge
--logdir=/var/log/nova
--state_path=/var/lib/nova
--lock_path=/var/lock/nova
--verbose
--ec2_host=http://172.16.39.110
--osapi_host=http://172.16.39.110
--rabbit_host=172.16.39.110
--glance_api_server=172.16.39.110:9292
--routing_source_ip=172.16.39.110
--sql_connection=mysql://vpsee:vpsee@172.16.39.110/nova
--image_service=nova.image.glance.GlanceImageService
--network_manager=nova.network.manager.FlatDHCPManager
--fixed_range=172.16.38.0/23
--flat_interface=dummy0
--public_interface=eth0

重启 nova 各个服务以后再重新启动一个新 instance 并输出 console:

# euca-run-instances -k vpsee -t m1.tiny ami-00000002

# euca-describe-instances
RESERVATION r-0xzn6el3 cloud default
INSTANCE i-00000215 ami-00000002 172.16.39.121 172.16.39.121 running vpsee (cloud, cloud00) 0  m1.tiny 2011-10-28T12:46:52Z nova aki-00000001 ami-00000000

# euca-get-console-output i-00000215
...
cloud-init start-local running: Fri, 28 Oct 2011 12:47:05 +0000. up 2.94 seconds
no instance data found in start-local
ci-info: lo    : 1 127.0.0.1       255.0.0.0
ci-info: eth0  : 1 172.16.39.121   255.255.254.0   02:16:3e:6d:9b:b6
ci-info: route-0: 0.0.0.0         172.16.38.1     0.0.0.0         eth0   UG
ci-info: route-1: 172.16.38.0     0.0.0.0         255.255.254.0   eth0   U
cloud-init start running: Fri, 28 Oct 2011 12:47:08 +0000. up 5.49 seconds
found data source: DataSourceEc2
Generating public/private rsa key pair.
...

最后用 ssh 登录刚启动的 instance 测试一下,很多朋友在这篇文章的 评论里问到“我的 instance 可以 ping 通,为啥不能 ssh?”的问题,可能是 ssh 的时候忘了带上 key。需要注意的是 cloud-init 这个脚本在启动 instance 后自动把 ssh 密钥注射到了 instance,ssh 的时候需要带上 vpsee.pem(还记得启动的时候用了 # euca-run-instances -k vpsee …吗?),还需要注意的是 Ubuntu 官方下载的 oneiric-server-cloudimg-amd64.tar.gz 模板的默认用户名是 ubuntu(不是 root),不需要密码登录(用 ssh key 登录):

# ssh -i vpsee.pem ubuntu@172.16.39.121

Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-12-virtual x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Fri Oct 28 10:29:14 UTC 2011

  System load:  0.0               Processes:           54
  Usage of /:   46.2% of 1.35GB   Users logged in:     0
  Memory usage: 8%                IP address for eth0: 172.16.39.121
  Swap usage:   0%

  Graph this data and manage this system at https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest

http://www.ubuntu.com/business/services/cloud

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

ubuntu@server-24:~$

FlatManager @OpenStack Nova

Ref>
http://www.vpsee.com/2011/08/openstack-nova-network-settings-for-flatmanager/

OpenStack Nova 安装后的 FlatManager 网络配置

2011年08月29日 | 标签: cloud, openstack nova | 作者:vpsee

这篇在 Ubuntu 上安装和配置 OpenStack Nova 的评论比较多,至少有6位网友遇到 ping 不通的问题,说实话 ping 不通的原因有很多(最常见的是 euca-authorize 授权问题),如果没有提供有用信息只是留下一句“ping 不通”很难判断问题所在,建议大家以后留言的时候尽量把自己的情况说清楚,尽量多的提供一些信息。OpenStack Nova 的网络设置很复杂,controller 上可以有多个网卡,compute 上也可以有多网卡,controller 和 compute 的网络设置还可以不同,并且每个设置还可以分为 FlatManager, FlatDHCPManager, VlanManager,每个 project 允许不同的网络设置,并且每个 user 可以创建多个 project 和 network,晕了吧-~
这里只介绍最简单的一种情况,只有一个网卡、一个 user 创建一个 project 和 network、直接使用现有的局域网 IP 地址不干扰现有网络。就是说把安装好的 OpenStack Nova Controller/Compute 并入到现有的局域网里,在 Nova 上创建的 instance 通过 bridge 使用现有局域网的 IP(而不是另建一个私有网络)。比如 VPSee 实验室现在已经有了 172.16.38.0/23 这个网络,如何利用这个网络和配置 OpenStack Nova 呢?
先检查一下 Nova 的配置文件:
$ sudo vi /etc/nova/nova.conf
--logdir=/var/log/nova
--state_path=/var/lib/nova
--lock_path=/var/lock/nova
--verbose
--s3_host=172.16.39.111
--rabbit_host=172.16.39.111
--cc_host=172.16.39.111
--ec2_url=http://172.16.39.111:8773/services/Cloud
--FAKE_subdomain=ec2
--sql_connection=mysql://root:vpsee@172.16.39.111/nova
--glance_host=172.16.39.111
--image_service=nova.image.glance.GlanceImageService
--my_ip=172.16.39.111
--network_manager=nova.network.manager.FlatManager
--fixed_range=172.16.38.0/23
--num_networks=1
--flat_injected=true
看看 bridge 网卡配置是否正确:
$ sudo vi /etc/network/interfaces
auto lo
iface lo inet loopback

auto br100
iface br100 inet static
address 172.16.39.111
netmask 255.255.254.0
gateway 172.16.38.1
bridge_ports eth0
bridge_stp off
bridge_maxwait 0
bridge_fd 0
如果修改了上面的配置需要重启 Nova 的各个模块和 Ubuntu 的网络,怕麻烦的话还是直接重启系统吧:
$ sudo reboot
如果 nova-manage network list 发现有以前留下的网络需要 delete 掉,删除所有以前残留的网络然后重新创建一个 172.16.38.0/23 新网络:
$ sudo nova-manage network delete 192.168.3.0/24 1 255

$ sudo nova-manage network create 172.16.38.0/23 1 512

$ sudo nova-manage network list
network            netmask         start address   DNS
172.16.38.0/23     255.255.254.0   172.16.38.2     8.8.4.4
因为有些 IP 地址是我们局域网正在用的,新建的 VM 不能占用这些 IP,所以需要划分一些 IP 留给 OpenStack Nova 用,需要进入数据库后修改 fixed_ips 这个表的 reserved 为 0,比如我们想把 172.16.39.222-226 这5个 IP 留给 OpenStack Nova instances:
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 135
Server version: 5.1.54-1ubuntu4 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use nova;
Database changed

mysql> update fixed_ips set reserved = '1';
Query OK, 6 rows affected (0.00 sec)
Rows matched: 1448  Changed: 6  Warnings: 0

mysql> update fixed_ips set reserved = '0' where address='172.16.39.222';
mysql> update fixed_ips set reserved = '0' where address='172.16.39.223';
mysql> update fixed_ips set reserved = '0' where address='172.16.39.224';
mysql> update fixed_ips set reserved = '0' where address='172.16.39.225';
mysql> update fixed_ips set reserved = '0' where address='172.16.39.226';
重启 OpenStack Nova 的各个模块,然后新建一个 ubuntu instance 测试一下是否得到了正确的 IP 并能 ping 通网关(172.16.38.1)。


OpenNebula @CentOS

Ref>
http://www.vpsee.com/2011/02/install-opennebula-on-centos/

在 CentOS 上安装和配置 OpenNebula

2011年02月25日 | 标签: centos, cloud computing, iaas, kvm, opennebula, xen | 作者:vpsee

我们提到的云计算一般有三种类型:软件即服务(Software as a Service, SaaS),平台即服务(Platform as a Service, PaaS)和基础架构即服务(Infrastructure as a Service, IaaS)。云概念刚出来的时候被人说的云里雾里摸不着头,现在云技术已经深入人心,也许你正在使用云而自己没有察觉呢,比如每天使用的 Gmail 就在 Google 大云上。为了更好理解这三种不同的云,我们可以拿 Google 来举例,刚好这家公司提供了三种形式的云服务,首先看 SaaS,Google Gmail/Docs/Gtalk/Maps 这些 Apps 都运行在 Google 云上,所以他们为普通用户提供了 “软件即服务”;Google 同时提供面向开发人员的 AppEngine,可以让开发人员在他们的平台(Platform)上使用 Python, Java 等语言和他们提供的 API 开发软件和服务,所以他们为开发人员提供了 “平台即服务”;Google 自己内部构建了基于 GFS, BigTable, MapReduce 之上的庞大基础云设施,为自己内部人员提供了 “基础架构即服务”,这就是三种不同类型的云。
OpenNebula 是一套开源的云计算基础管理工具,用来方便管理员在数据中心统一部署、创建、分配和管理大量的虚拟机,企业数据中心可以利用这套工具搭建自己的私有云,为 自己内部提供 IaaS 服务,类似的开源产品还有 Eucalyptus, openQRM 等。以下的安装过程在 VPSee 的两台装有 CentOS 5.5 系统的服务器上完成,一台服务器做 OpenNubula 前端(node00),另一台服务器用来做节点(node01),搭建一个最小的 “云”,如果想扩展这个云的话,只需要逐步增加节点(node02, node03, …)就可以了。如果对其他类似的开源云计算平台感兴趣的话可以看看:在 Ubuntu 上安装和配置 OpenStack Nova.

 

安装和配置前端(Front-End)

增加 CentOS Karan 源:

# cd /etc/yum.repos.d
# wget http://centos.karan.org/kbsingh-CentOS-Extras.repo
# yum update

安装 OpenNebula 需要的软件包以及编译 OpenNebula 源代码所需的工具:

# yum install gcc gcc-c++ make openssl-devel flex bison

# yum install ruby ruby-devel ruby-docs ruby-ri ruby-irb ruby-rdoc
# yum install rubygems
# gem install nokogiri rake xmlparser

# yum install scons
# yum install xmlrpc-c xmlrpc-c-devel

CentOS 自带的 sqlite 版本不行,需要下载和编译 sqlite 3.6.17 版本:

# wget http://www.sqlite.org/sqlite-amalgamation-3.6.17.tar.gz
# tar xvzf sqlite-amalgamation-3.6.17.tar.gz
# cd sqlite-3.6.17/
# ./configure; make; make install

下载和编译 opennebula 2.0.1 源码包后,解压、编译和安装:

# tar zxvf opennebula-2.0.1.tar.gz
# cd opennebula-2.0.1
# scons
# ./install.sh -d /srv/cloud/one

# ls /srv/cloud/one/
bin  etc  include  lib  share  var

启动 OpenNebula 前需要配置 ONE_AUTH 环境变量,这个环境变量从 $HOME/.one/one_auth 这个文件读取,所以要先创建 one_auth 这个文件后再启动 one(OpenNebula 服务程序):

# cd /root/
# mkdir .one
# cd .one/
# echo "oneadmin:password" > one_auth

# one start

OpenNebula 支持 KVM, Xen 和 VMware 三种虚拟技术,我们还需要告诉 OpenNebula 我们想用哪种,并重启 one 以便配置生效:

# vi /etc/one/oned.conf
...
IM_MAD = [
    name       = "im_xen",
    executable = "one_im_ssh",
    arguments  = "xen" ]

VM_MAD = [
    name       = "vmm_xen",
    executable = "one_vmm_ssh",
    arguments  = "xen",
    default    = "vmm_ssh/vmm_ssh_xen.conf",
    type       = "xen" ]
...

# one stop
# one start

安装和配置节点(Compute Node)

需要在每个 node 上都安装 Xen 或 KVM 的虚拟环境,具体请参考:在 CentOS 上安装和配置 Xen 和 在 CentOS 上安装和配置 KVM,还需要 ruby 运行环境:

# yum install ruby

交换 SSH Key

因为 OpenNebula Front 和 Nodes 之间是通过 SSH 通讯的,所以 front 和 nodes 之间要设置成 SSH 无密码登录避免 front 运行 node 上脚本或克隆镜像的时候输入密码,首先在 front 和 nodes 上配置 sshd:

# vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes

# /etc/init.d/sshd restart

在 front (node00) 上创建 key 后拷贝到 node (node01):

# ssh-keygen -t rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub node01

在1个 node (node01) 上创建 key 后拷贝到 front (node00):

# ssh-keygen -t rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub node00

onehost

front 和 每个 node 都能无密码 ssh 沟通后,就可以在 front 上 onehost create 命令来逐个加入 node,并用 onehost list 来查看是否创建成功:

# onehost create node01 im_xen vmm_xen tm_ssh

# onehost list
  ID NAME              CLUSTER  RVM   TCPU   FCPU   ACPU    TMEM    FMEM STAT
  1 node01     default    0    400    400    400    3.8G    383M   on

如果执行 onehost create 报错,查看 oned.log 日志发现 sudo: sorry, you must have a tty to run sudo 字样,原因则是 OpenNebula 需要远程 ssh/sudo 执行命令,而 CentOS 的 sudo 选项 requiretty 是默认打开的,ssh 需要一个 tty 才能执行,所以远程 sudo 就会出错,:

# onehost create node01 im_xen vmm_xen tm_ssh

# tail /var/log/one/oned.log
Tue Feb 22 11:08:58 2011 [InM][I]: Command execution fail: 'if [ -x "/var/tmp/one/im/run_probes" ]; then /var/tmp/one/im/run_probes xen 172.16.39.111; else                              exit 42; fi'
Tue Feb 22 11:08:58 2011 [InM][I]: STDERR follows.
Tue Feb 22 11:08:58 2011 [InM][I]: sudo: sorry, you must have a tty to run sudo
Tue Feb 22 11:08:58 2011 [InM][I]: Error executing xen.rb
...

解决办法就是关闭(注释掉) requiretty 这行:

# chmod 600 /etc/sudoers
# vi /etc/sudoers
#Defaults    requiretty

因为 VPSee 的这两台服务器使用了 HTTP 代理上网,所以 OpenNebula 读取了系统的 http_proxy 环境变量,在 sched.log 日志里发现了 HTTP response 错误,这时候需要关闭 http_proxy:

# cat /var/log/one/sched.log
Tue Feb 22 14:27:39 2011 [HOST][E]: Exception raised: Unable to transport XML to server and get XML response back.  HTTP response: 504
Tue Feb 22 14:27:39 2011 [POOL][E]: Could not retrieve pool info from ONE

# unset http_proxy

onevnet

创建和编辑虚拟网络配置文件,然后创建一个 OpenNebula 虚拟网络:

# vi small_network.net
NAME = "Small network"
TYPE = FIXED

BRIDGE = br0
LEASES = [ IP="192.168.0.5"]
LEASES = [ IP="192.168.0.6"]
LEASES = [ IP="192.168.0.7"]

# onevnet create small_network.net

# onevnet list
  ID USER     NAME              TYPE BRIDGE P #LEASES
   0 oneadmin Small network    Fixed    br0 N       0

onevm

创建和编辑虚拟机的启动配置文件,这里的 centos.5.5.x86.img 可以从 http://stacklet.com/ 下载(收费)或者自己利用 Xen 工具创建一个:

# wget http://stacklet.com/sites/default/files/centos/
centos.5.5.x86.img.tar.bz2
# tar jxvf centos.5.5.x86.img.tar.bz2
# mv centos.5.5.x86.img /srv/cloud/one/var/images/

# vi centos.one
NAME   = centos
CPU    = 1
MEMORY = 256

DISK = [
  source   = "/srv/cloud/one/var/images/centos.5.5.x86.img",
  target   = "sda1",
  clone    = "yes",
  readonly = "no" ]

NIC = [ MAC = "00:16:3E:00:02:64", bridge = xenbr0 ]

OS = [ bootloader     = "/usr/bin/pygrub" ]

用 onevm create 命令启动上面的 VM 配置文件,就会在 node01 上创建一个虚拟机,用 onevm list 查看会看到 prol 状态,表示正在创建过程中,创建完毕后状态会变成 runn:

# onevm create centos.one

# onevm list
   ID     USER     NAME STAT CPU     MEM  HOSTNAME        TIME
    1 oneadmin   centos prol   0      0K  node01   00 00:09:09

# onevm list
   ID     USER     NAME STAT CPU     MEM  HOSTNAME        TIME
    1 oneadmin   centos runn   0      0K  node01   00 00:22:17

就这样,我们在 node00 (front) 和 node01 (node) 这两台服务器上部署了一个最小的云,并且在 node01 上运行了一个基于 Xen 的虚拟机实例。



OpenStack Nova @CentOS5.6

Ref>

http://www.vpsee.com/2011/08/install-openstack-nova-on-centos/

在 CentOS 上安装和配置 OpenStack Nova

2011年08月17日 | 标签: centos, cloud, nova, openstack | 作者:vpsee

因为 Python 的版本问题,在 CentOS 5.6 上安装 OpenStack 不是件容易的事情,因为 OpenStack 是 Python 2.6 写的,CentOS 5.6 上默认的是 Python 2.4 的环境,一些关键工具(比如 yum 等)和依赖关系都需要 2.4,不容易直接升级到 2.6,所以要在 CentOS 上安装 OpenStack 的话简单的办法是直接用 CentOS 6.0(默认是 Python 2.6). OpenStack 的基本介绍以及如何在 Ubuntu 上安装 OpenStack Nova 可以看:在 Ubuntu 上安装和配置 OpenStack Nova. 对云计算平台感兴趣的朋友可以看看另一个开源的云计算系统:在 CentOS 上安装和配置 OpenNebula

安装和配置基本系统

在安装完基本的 CentOS 6.0 系统后(最小化安装)升级和更新整个系统,然后关闭 SELINUX 后重启,为了简单方便最好也关闭 iptables:

# yum update
# yum upgrade

# vi /etc/sysconfig/selinux
SELINUX=disabled

# chkconfig iptables off
# service iptables stop

# shutdown -r now

安装 OpenStack Nova

下载和安装 OpenStack 源:

# wget http://yum.griddynamics.net/yum/diablo-3/openstack/openstack-repo-2011.3-0.3.noarch.rpm
# rpm -ivh openstack-repo-2011.3-0.3.noarch.rpm

OpenStack Nova 需要在控制结点(Cloud Controller)和计算结点(Cloud Compute)上都安装和启用 libvirtd:

# yum install libvirt
# chkconfig libvirtd on
# service libvirtd start

如果服务器用来做 Cloud Controller 结点需要安装(OpenStack Nova 云里至少要有一台服务器作为控制结点):

# yum install euca2ools openstack-nova-node-full unzip

如果服务器只是做 Cloud Compute 结点则需要在每个计算结点上都安装(理论上 OpenStack Nova 云里可以有无数个计算结点):

# yum install openstack-nova-node-compute

配置 MySQL 数据库

OpenStack Nova 需要数据库的支持,这里用的是 MySQL:

# service mysqld start
# chkconfig mysqld on
# service rabbitmq-server start
# chkconfig rabbitmq-server on

修改 MySQL 绑定地址,以便其他的节点服务器也能访问这个数据库:

# vi /etc/my.cnf
...
#bind-address           = 127.0.0.1
bind-address            = 0.0.0.0
...

# service mysql restart

创建一个名为 nova 的数据库,并设置 root 从任何 IP 访问的权限和密码:

# mysql -uroot -ppassword -e 'CREATE DATABASE nova;'
# mysql -uroot -ppassword -e "GRANT ALL PRIVILEGES ON *.* TO \
'root'@'%' WITH GRANT OPTION;"
# mysql -uroot -ppassword -e "SET PASSWORD FOR \
'root'@'%' = PASSWORD('password');"

配置 Nova:

$ sudo vi /etc/nova/nova.conf
--verbose=false
--ec2_url=http://172.16.39.111:8773/services/Cloud
--s3_host=172.16.39.111
--cc_host=172.16.39.111
--rabbit_host=172.16.39.111
--sql_connection=mysql://nova:nova@172.16.39.111/nova
--glance_api_servers=172.16.39.111:9292
--use_s3=true
--libvirt_type=kvm
--use_syslog=false
--node_availability_zone=nova
--logdir=/var/log/nova
--logging_context_format_string=%(asctime)s %(name)s: %(levelname)s [%(request_id)s %(user)s %(project)s] %(message)s
--logging_default_format_string=%(asctime)s %(name)s: %(message)s
--logging_debug_format_suffix=
--use_cow_images=true
--auth_driver=nova.auth.dbdriver.DbDriver
--network_manager=nova.network.manager.VlanManager
--scheduler_driver=nova.scheduler.zone.ZoneScheduler
--image_service=nova.image.glance.GlanceImageService
--use_ipv6=false
--ca_path=/var/lib/nova/CA
--keys_path=/var/lib/nova/keys
--images_path=/var/lib/nova/images
--buckets_path=/var/lib/nova/buckets
--instances_path=/var/lib/nova/instances
--networks_path=/var/lib/nova/networks
--dhcpbridge_flagfile=/etc/nova/nova.conf
--dhcpbridge=/usr/bin/nova-dhcpbridge
--injected_network_template=/usr/share/nova/interfaces/
--libvirt_xml_template=/usr/share/nova/libvirt.xml.template
--vpn_client_template=/usr/share/nova/client.ovpn.template
--credentials_template=/usr/share/nova/novarc.template
--state_path=/var/lib/nova
--lock_path=/var/lib/nova/tmp
--vnc_enabled=true
--vncproxy_url=http://172.16.39.111:6080
--vncserver_host=0.0.0.0
--vnc_token_ttl=300

每次重启一堆服务很麻烦,写个脚本方便重启 nova 所有服务:

# vi nova-restart-all.sh
#!/bin/bash
for n in api compute network objectstore scheduler vncproxy; do service openstack-nova-$n restart; done
service openstack-glance-api restart
service openstack-glance-registry restart

# chmod +x nova-restart-all.sh

# ./nova-restart-all.sh

使用 Nova

接下来的步骤和在 Ubuntu 上安装和配置 OpenStack Nova 差不多,这里就不再赘述:

# nova-manage db sync
# nova-manage network create 192.168.0.0/24 1 255
# nova-manage floating create 10.10.10.2 10.10.10.224/27
# nova-manage user admin vpsee
# nova-manage project create mycloud vpsee

导出权限信息:

# mkdir /home/vpsee/creds
# nova-manage project zipfile mycloud vpsee /home/vpsee/creds/novacreds.zip

# cd /home/vpsee/creds
# unzip novacreds.zip
# chown -R vpsee:vpsee /home/vpsee/creds/

# source /home/vpsee/creds/novarc

再次重启 nova 相关的所有服务:

# ./nova-restart-all.sh

如果一切正常的话,应该可以看到下面的类似信息,这样 OpenStack Nova 就成功安装了:

# euca-describe-availability-zones verbose
AVAILABILITYZONE nova available
AVAILABILITYZONE |- node00
AVAILABILITYZONE | |- nova-network enabled :-) 2011-08-16 19:28:13
AVAILABILITYZONE | |- nova-compute enabled :-) 2011-08-16 19:28:22
AVAILABILITYZONE | |- nova-scheduler enabled :-) 2011-08-16 19:28:14

启动第一个实例

启动实例之前需要先上传一个系统模版(称之为镜像 image),自己制作 image 有点麻烦,可以参考:为 OpenStack Nova 制作 Ubuntu 镜像为 OpenStack Nova 制作 Windows 镜像

有了 image 后就可以启动实例了,就像在 C++/Java 等面向对象语言里面有了类(class)以后可以创建实例(instance)一样,这里有了 OS image 以后就可以创建 OS instance 了。启动和访问实例可以看这篇 的相关部分。

OpenStack Nova @Ubuntu11.04

Ref>

http://www.vpsee.com/2011/05/install-openstack-nova-on-ubuntu/

在 Ubuntu 上安装和配置 OpenStack Nova

2011年05月24日 | 标签: cloud, nova, openstack, ubuntu | 作者:vpsee

OpenStack 是由 Rackspace 和 NASA 共同开发的云计算平台,帮助服务商和企业内部实现类似于 Amazon EC2 和 S3 的云基础架构服务(Infrastructure as a Service, IaaS)。OpenStack 包含两个主要模块:Nova 和 Swift,前者是 NASA 开发的虚拟服务器部署和业务计算模块;后者是 Rackspack 开发的分布式云存储模块,两者可以一起用,也可以分开单独用。OpenStack 是开源项目,除了有 Rackspace 和 NASA 的大力支持外,后面还有包括 Dell, Citrix, Cisco, Canonical 这些重量级公司的贡献和支持,发展速度非常快,有取代另一个业界领先开源云平台 Eucalyptus 的态势。

OpenStack 是 Python 2.6 写的,CentOS 5.6 上默认的是 Python 2.4 的环境并且还有很多依赖关系不容易升级到 2.6,所以在 Ubuntu 上安装会简单一些,而且 Ubuntu 是 OpenStack 的官方首选系统,文档都是按 Ubuntu 写的,所以这里 VPSee 采用最新的 Ubuntu 11.04 Server 64bit 版本来安装和配置 OpenStack Nova. 使用 CentOS 的朋友可以看看:在 CentOS 上安装和配置 OpenStack Nova;如果对其他类似的开源云计算平台感兴趣的话可以看看:在 CentOS 上安装和配置 OpenNebula.

配置网络

在安装完基本的 Ubuntu 11.04 Server 系统后升级和更新整个系统,安装完 bridge-utils 包后重启系统:

$ sudo apt-get update
$ sudo apt-get upgrade

$ sudo apt-get install bridge-utils

$ sudo reboot

配置网桥:

$ sudo vi /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 172.16.39.111
netmask 255.255.254.0
gateway 172.16.38.1

auto br100
iface br100 inet static
bridge_ports eth1
bridge_stp off
bridge_maxwait 0
bridge_fd 0
address 192.168.0.1
netmask 255.255.0.0
broadcast 192.168.255.255

关于 FlatManager 网络配置可参考:OpenStack Nova 安装后的 FlatManager 网络配置

安装 NTP 服务

OpenStack Nova 需要 NTP 服务器来保持所有节点服务器(Cloud Compute)的时间同步,所以需要在前端控制服务器(Cloud Controller)上安装 NTP 服务器,然后在节点服务器上安装 NTP 客户端保持与前端的同步:

$ sudo apt-get install ntp

$ sudo vi /etc/ntp.conf
server 127.127.1.0
fudge 127.127.1.0 stratum 10

$ sudo /etc/init.d/ntp restart

安装和配置 MySQL 数据库

OpenStack Nova 需要数据库的支持,这里选用 MySQL(当然也可以用其他的数据库,比如 PostgreSQL 等):

$ sudo apt-get install mysql-server

修改 MySQL 绑定地址,以便其他的节点服务器也能访问这个数据库:

$ sudo vi /etc/mysql/my.cnf
...
#bind-address           = 127.0.0.1
bind-address            = 0.0.0.0
...

$ sudo /etc/init.d/mysql restart

创建一个名为 nova 的数据库,并设置 root 从任何 IP 访问的权限和密码:

$ sudo mysql -uroot -ppassword -e 'CREATE DATABASE nova;'
$ sudo mysql -uroot -ppassword -e "GRANT ALL PRIVILEGES ON *.* TO \
'root'@'%' WITH GRANT OPTION;"
$ sudo mysql -uroot -ppassword -e "SET PASSWORD FOR \
'root'@'%' = PASSWORD('password');"

安装 Glance 镜像服务

Glance 是个镜像服务器,用来给 OpenStack Nova 提供操作系统镜像(image)服务,提供可选择的操作系统模版(镜像)。

$ sudo apt-get install glance

安装 OpenStack Nova

OpenStack Nova 已经进入 Ubuntu 11.04 源,所以直接安装就可以了,不必源码安装:

$ sudo apt-get install rabbitmq-server nova-common nova-doc python-nova
nova-api nova-network nova-volume nova-objectstore nova-scheduler nova-compute

$ sudo apt-get install -y euca2ools

$ sudo apt-get install -y unzip

配置 Nova:

$ sudo vi /etc/nova/nova.conf
--dhcpbridge_flagfile=/etc/nova/nova.conf
--dhcpbridge=/usr/bin/nova-dhcpbridge
--logdir=/var/log/nova
--state_path=/var/lib/nova
--lock_path=/var/lock/nova
--verbose
--s3_host=172.16.39.111
--rabbit_host=192.168.0.1
--cc_host=192.168.0.1
--ec2_url=http://172.16.39.111:8773/services/Cloud
--fixed_range=192.168.0.0/16
--network_size=8
--FAKE_subdomain=ec2
--routing_source_ip=192.168.0.1
--sql_connection=mysql://root:password@172.16.39.111/nova
--glance_host=192.168.0.1
--image_service=nova.image.glance.GlanceImageService

重启 nova 相关服务以便设置生效:

$ sudo restart libvirt-bin; sudo restart nova-network;
sudo restart nova-compute; sudo restart nova-api;
sudo restart nova-objectstore; sudo restart nova-scheduler;
sudo restart nova-volume; sudo restart glance-api; sudo restart glance-registry

使用 Nova

开始使用 Nova 前需要创建 nova 数据库表、创建网络、创建管理员帐号、创建云并联到刚才创建的管理员上:

$ sudo nova-manage db sync
$ sudo nova-manage network create 192.168.0.0/24 1 255
$ sudo nova-manage floating create 10.10.10.2 10.10.10.224/27
$ sudo nova-manage user admin vpsee
$ sudo nova-manage project create mycloud vpsee

因为多个管理员可以创建多个不同的云,所以某个云的管理员需要特定的权限才能访问和管理自己的 Nova 云,创建权限信息,并解压到自己的目录里,需要注意的是每次使用 nova 管理云的时候都需要读取 novarc 里面的配置信息:

$ mkdir /home/vpsee/creds
$ sudo nova-manage project zipfile mycloud vpsee /home/vpsee/creds/novacreds.zip

$ cd /home/vpsee/creds
$ unzip novacreds.zip
$ sudo chown -R vpsee:vpsee /home/vpsee/creds/

$ source /home/vpsee/creds/novarc

每次用 nova 的时候都要用到 novarc 里面的环境变量,每次 source novarc 很麻烦,所以最好加到 .bashrc 里面:

$ cat  /home/vpsee/creds/novarc >> /home/vpsee/.bashrc
$ source /home/vpsee/.bashrc

再次重启 nova 相关的所有服务:

$ sudo restart libvirt-bin; sudo restart nova-network;
sudo restart nova-compute; sudo restart nova-api;
sudo restart nova-objectstore; sudo restart nova-scheduler;
sudo restart nova-volume; sudo restart glance-api; sudo restart glance-registry

如果一切正常的话,应该可以打印出如下的类似信息:

$ euca-describe-availability-zones verbose
AVAILABILITYZONE nova available
AVAILABILITYZONE |- node00
AVAILABILITYZONE | |- nova-scheduler enabled :-) 2011-05-22 10:32:31
AVAILABILITYZONE | |- nova-network enabled :-) 2011-05-22 10:32:32
AVAILABILITYZONE | |- nova-compute enabled :-) 2011-05-22 10:32:24

如果出现这个问题,检查 novarc 这个文件看看 EC2_URL, S3_URL, NOVA_URL 这三行是不是有两个连续的 http://?

$ euca-describe-availability-zones verbose
invalid literal for int() with base 10: ''

$ vi /home/vpsee/creds/novarc
...
export EC2_URL="http://http://172.16.39.100:8773/services/Cloud"
export S3_URL="http://http://172.16.39.100:3333"
...
export NOVA_URL="http://http://172.16.39.100:8774/v1.1/"
...

删除一个 http:// 就可以了:

$ vi /home/vpsee/creds/novarc
...
export EC2_URL="http://172.16.39.100:8773/services/Cloud"
export S3_URL="http://172.16.39.100:3333"
...
export NOVA_URL="http://172.16.39.100:8774/v1.1/"
...

启动第一个实例

启动实例之前需要先上传一个系统模版,我们称之为镜像(image),自己制作操作系统镜像有点麻烦(请看:为 OpenStack Nova 制作 Ubuntu 镜像为 OpenStack Nova 制作 CentOS 镜像为 OpenStack Nova 制作 Windows 镜像。),这里直接使用一个已经做好的 Ubuntu 10.10 版本镜像,下载已经做好的镜像文件并上传到镜像服务器(这里镜像服务器和前端服务器在同一台物理服务器上):

$ wget http://c0179148.cdn1.cloudfiles.rackspacecloud.com/ubuntu1010-UEC-localuser-image.tar.gz

$ uec-publish-tarball ubuntu1010-UEC-localuser-image.tar.gz ubuntu1010-bucket x86_64

列出云里现有的可以加载的镜像,并以某个镜像(比如编号为 ami-00000003)为模版启动一个实例(操作系统):



$ euca-describe-images
IMAGE aki-00000001 ubuntu1010-bucket/vmlinuz-2.6.32-28-server.manifest.xml  available public  x86_64 kernel
IMAGE ari-00000002 ubuntu1010-bucket/initrd.img-2.6.32-28-server.manifest.xmavailable public  x86_64 ramdisk
IMAGE ami-00000003 ubuntu1010-bucket/maverick-server-uec-amd64.img.manifest.xml  available public  x86_64 machine aki-00000001 ari-00000002


$ euca-add-keypair mykey > mykey.priv

$ euca-run-instances -k mykey -t m1.tiny ami-00000003

检查一下实例是否成功启动和运行:

$ virsh list
 Id Name                 State
----------------------------------
  1 instance-00000001    running

访问实例

启动实例后怎么访问呢?和访问 VPS 一样,需要 IP 地址然后 ssh 访问,还记得上面的网络配置么,新创建的系统将按照 192.168.0.x 的形式分配 IP,所以 192.168.0.3 就是刚刚 euca-run-instances 创建的实例的 IP 地址:

$ ssh ubuntu@192.168.0.3

Troubleshooting

解决 DataSourceEc2.py[WARNING]: ‘http://169.254.169.254′ failed: url error 问题
删除 OpenStack Nova Volume 时遇到的 error_deleting 问题
解决 Warning: failed to parse error message from AWS: :1:0: syntax error 问题
重置 OpenStack Nova 数据库

2012/04/20

AMD Athlon II X4 638

AMD Athlon™ II Processor Model Numbers and Comparisons 

AMD Athlon™ II X4 Quad-Core Processor
Model Number Frequency CMOS Technology Total Dedicated L2 Cache Packaging Thermal Design Power
651 3.0 GHz 32nm SOI 4MB socket FM1 100W
645 3.1 GHz 45nm SOI 2MB socket AM3 95W
641 2.8 GHz 32nm SOI 4MB socket FM1 100W
640 3.0 GHz 45nm SOI 2MB socket AM3 95W
638 2.7 GHz 32nm SOI 4MB socket FM1 65W
631 2.6 GHz 32nm SOI 4MB socket FM1 100W
Energy Efficient AMD Athlon™ II X4 Quad-Core Processor
Model Number Frequency CMOS Technology Total Dedicated L2 Cache Packaging Thermal Design Power
620e 2.6 GHz 45nm SOI 2MB socket AM3 45W
615e 2.5 GHz 45nm SOI 2MB socket AM3 45W
AMD Athlon™ II X3 Triple-Core Processor
Model Number Frequency CMOS Technology Total Dedicated L2 Cache Packaging Thermal Design Power
460 3.4 GHz 45nm SOI 1.5MB socket AM3 95W
455 3.3 GHz 45nm SOI 1.5MB socket AM3 95W
450 3.2 GHz 45nm SOI 1.5MB socket AM3 95W
Energy Efficient AMD Athlon™ II X3 Triple-Core Processor
Model Number Frequency CMOS Technology Total Dedicated L2 Cache Packaging Thermal Design Power
425e 2.7 GHz 45nm SOI 1.5MB socket AM3 45W
420e 2.6 GHz 45nm SOI 1.5MB socket AM3 45W
AMD Athlon™ II X2 Dual-Core Processor
Model Number Frequency CMOS Technology Total Dedicated L2 Cache Packaging Thermal Design Power
270 3.4 GHz 45nm SOI 2MB socket AM3 65W
265 3.3 GHz 45nm SOI 2MB socket AM3 65W
260 3.2 GHz 45nm SOI 2MB socket AM3 65W
255 3.1 GHz 45nm SOI 2MB socket AM3 65W
250 3.0 GHz 45nm SOI 2MB socket AM3 65W
240 2.8 GHz 45nm SOI 2MB socket AM3 65W
Energy Efficient AMD Athlon™ II X2 Dual-Core Processor
Model Number Frequency CMOS Technology Total Dedicated L2 Cache Packaging Thermal Design Power
250e 3.0GHz 45nm SOI 2MB socket AM3 45W
245e 2.9GHz 45nm SOI 2MB socket AM3 45W
AMD64 Technology Yes
Simultaneous 32- & 64-bit computing Yes
L1 Cache (Instruction + Data) 64K of L1 instruction and 64K of L1 data cache per core X2 - 256KB total L1 per processor X3 – 384KB total L1 per processor X4 - 512KB total L1 per processor
L2 Cache (total dedicated) X2 - 2MB X3 – 1.5MB  X4 - 2MB
Integrated DDR Memory Controller Yes
Memory Controller Width 128-bit
Type of Memory Supported X2 - Support for unregistered DIMMs up to PC2-8500 (DDR2-1066MHz) -AND- PC3-8500 (DDR3-1066MHz) X3 and X4 - Support for unregistered DIMMs up to PC2-8500 (DDR2-1066MHz) -AND- PC3 10600 (DDR3-1333MHz)
Total Processor-to-System Bandwidth X2 – Up to 33.1GB/s bandwidth [Up to 17.1 GB/s total bandwidth (DDR3-1066) + 16.0GB/s (HT3)] Up to 28.8GB/s bandwidth  [Up to 12.8 GB/s total bandwidth (DDR2-1066) + 16.0GB/s (HT3)] X3 and X4 – Up to 37.3GB/s total bandwidth [Up to 21.3 GB/s memory bandwidth (DDR3-1333) + 16.0GB/s (HT3)] Up to 28.8GB/s bandwidth [Up to 12.8 GB/s total bandwidth (DDR2-1066) + 16.0GB/s (HT3)]
Thermal Design Power 45W, 65W and 95W
Manufacturing Sites GLOBALFOUNDRIES Fab 1 Module 1.



© 2009 Advanced Micro Devices, Inc. AMD, the AMD Arrow logo, AMD Athlon, and combinations thereof, are trademarks of Advanced Micro Devices, Inc. HyperTransport is a licensed trademark of the HyperTransport Technology Consortium. Other names are for informational purposes only and may be trademarks of their respective

Ref>
http://www.amd.com/us/products/desktop/processors/athlon-ii-x2/Pages/AMD-athlon-ii-x2-processor-model-numbers-feature-comparison.aspx

1Z0-042 7p20q

1Z0-042

1.You have a text file that maintains information on thousands of items. The end-user application requires
the transfer of that information into a table in the database. What would you use to achieve this task?
(Choose two.)
A. Data Pump
B. SQL*Loader
C. External table
D. Oracle Text
E. Oracle Import
Answer: BC

2.Which step do you need to perform to enable a user with the SYSDBA privilege to log in as SYSDBA in
iSQL*Plus.?
A. The user must be granted the database administrator (DBA) privilege.
B. Set up a user in the Oracle Application Server Containers for J2EE (OC4J) user manager, and grant
the webDba role to the user.
C. The user must be listed in the password file for the authentication.
D. No special setup is needed for the user to connect as SYSDBA in iSQL*Plus.
Answer: B

3.You specified extent management as local for a tablespace. How will it affect space management in the
tablespace?
A. The tablespace will be system managed and the users cannot specify the extent size.
B. Free extents will be managed by the data dictionary tables.
C. All the extents will be of the same size.
D. Bitmap will be used to record free and allocated extents.
Answer: D

4.Which two operations require undo data? (Choose two.)
A. recovering from failed transactions
B. recording a transaction to redo log files
C. rolling back a transaction
D. committing a transaction
E. rolling forward during instance recovery
Answer: AC

5.The employee IDs of employees who have made sales in the company are transferred from the
EMPLOYEES table to the BONUS table with a default bonus value. Later, the human resources
department decides to give bonuses to employees as per the following conditions:
1. Employees with a salary of $8,000 or less should receive a bonus.
2. Employees who have not made sales get a bonus of 1% of their salary.
3. Employees who already made sales get an increase in their bonus equal to 1% of their salary.
What would you do to implement these changes in one step?
A. Use SQL*Loader utility.
B. Use the MERGE statement.
C. Use a multitable insert operation.
D. Use a correlated UPDATE statement.
Answer: B

6.The ST_INFO master table has millions of rows that are updated very rarely. It has a STATE_CODE
column that contains the value for 25 states. The table is frequently queried on the STATE_CODE column.
Which type of index would you suggest to improve the query performance?
A. bitmap
B. B-tree
C. function based
D. reverse key
Answer: A

7.You want to monitor and control the resource usage by sessions. You want to be warned automatically
when more than 100 sessions are opened with your database. What action would you take to achieve
this?
A. Set the warning threshold for the Current Logons Count metric.
B. Set the limits in the profiles used by users.
C. Use the Database Resource Manager.
D. Modify the SESSIONS initialization parameter.
Answer: A

8.User Scott has updated the salary of one of the employees in the EMPLOYEES table and has not
committed the transaction. What are the two types of locks that this scenario would lead to? (Choose
two.)
A. a shareable table lock for the table containing the row
B. null lock on the table containing the row
C. exclusive table-level lock for the table containing the row
D. null lock on the row being updated
E. ROW SHARE lock for the row being updated
F. shared row-exclusive lock for the row being updated
G. ROW EXCLUSIVE lock for the row being updated
Answer: AG

9.Which statement regarding the contents of the V$PARAMETER view is true?
A. displays only the list of default values
B. displays the current contents of the server parameter file
C. displays the currently in effect parameter values
D. displays the list of all the parameter files of a database
E. displays only the list of all advanced parameters
F. displays only the list of all basic parameters
Answer: C

10.Redo log files are not multiplexed in your database. Redo log blocks are corrupted in group 2, and
archiving has stopped. All the redo logs are filled and database activity is halted. Database writer has
written everything to disk. Which command would you execute to proceed further?
A. ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2;
B. RECOVER LOGFILE BLOCK GROUP 2;
C. ALTER DATABASE CLEAR LOGFILE GROUP 2;
D. ALTER DATABASE DROP LOGFILE GROUP 2;
E. ALTER DATABASE RECOVER LOGFILE GROUP 2;
Answer: A

11.Which three statements are true regarding the fine-grained auditing (FGA)? (Choose three.)
A. FGA is possible on SELECT statements only.
B. The audit trail for FGA is stored in the AUD_LOG$ table.
C. FGA includes the SQL statement used by the user as part of the audit event entry.
D. FGA enables a SQL predicate to define when to audit an event.
E. The audit trail for FGA is stored in the FGA_LOG$ table.
F. FGA audits DELETE statements only when audit columns are specified.
Answer: CDE

12.Your database instance is started using the server parameter file (SPFILE). Control files are
multiplexed and stored on different disks. Because of a disk failure, you lost one of these control files. You
replaced the damaged disk. What is the correct sequence of steps that you would follow to recover the
control file?
1. Shut down the instance, if not already done.
2. Copy one of the remaining control files to a new location.
3. Change the value of the CONTROL_FILES initialization parameter to correspond to the new location of
the control files.
4. Start up the database instance to the NOMOUNT stage.
5. Recover the database to the point of failure of the control file.
6. Open the database.
A. 2,4,3,4,5
B. 5,2,3,4
C. 4,5,6,2,3
D. 1,2,4,3,5
Answer: D

13.You executed the STARTUP MOUNT command to start your database. For which database operation
do you need to start the database in the MOUNT state?
A. dropping a user in your database
B. dropping a tablespace in your database
C. enabling or disabling redo log archiving
D. renaming the control files
E. re-creating the control files, after you lost all the control files in your database
Answer: C

14.View the Exhibit to see the source and target databases.
You have created a database link, devdb.us.oracle.com, between the databases PRODDB and DEVDB.
You want to import schema objects of the HR user using Oracle Data Pump from the
development database, DEVDB, to the production database, PRODDB. You execute the following
command on the target database server:
$impdp system/manager directory = DB_DATA
dumpfile = schemas.dat
schemas = hr
flashback_time = 2004-02-03 09:00
The command fails, displaying the following error:
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "/home/oracle/schema/schemas.dat" for read
ORA-27037: unable to obtain file status
What would you do to overcome the error?











A. remove the dumpfile option in the command
B. remove the flashback_time option in the command
C. remove the dumpfile option and add the network_link = devdb.us.oracle.com option in the command
D. add the user, SYSTEM, to the schemas option in the command
E. remove the schemas option and add the network_link = devdb.us.oracle.com option in the command
F. add network_link = devdb.us.oracle.com option in the command
Answer: C

15.You want to create a tablespace with the following specifications:
1. The tablespace extends automatically.
2. Used and free extents should be managed by bitmaps.
3. Default PCTUSED attribute is set to 60.
4. All the extents would be of size 1 MB.
Which three options would you choose to create the tablespace? (Choose three.)
A. tablespace with segment space management as automatic
B. tablespace with AUTOEXTEND enabled
C. tablespace with a uniform extent allocation of 1 MB
D. tablespace with dictionary-managed extents
E. tablespace with segment space management as manual
Answer: BCE

16.Examine the following commands executed in your database:
SQL> ALTER SESSION RECYCLEBIN=ON;
Session altered
SQL> CREATE TABLE emp TABLESPACE tbsfd AS SELECT * FROM hr.employees; Table created.
Further, you executed the following command to drop the table:
SQL> DROP TABLE emp;
Table dropped.
What happens in this scenario?
A. The table is moved to the SYSTEM tablespace.
B. The table is renamed and remains in the TBSFD tablespace.
C. The table is moved to the SYSAUX tablespace.
D. The table is removed from the database permanently.
Answer: B

17.Which two statements are true about the roles in the Oracle database? (Choose two.)
A. A role cannot be assigned external authentication.
B. Roles can be granted to other roles.
C. Roles are owned by the SYS user.
D. A role can be granted to itself.
E. A role can contain both system and object privileges.
Answer: BE

18.The user SCOTT executes the following command successfully to increase the salary values in one of
his sessions:
SQL> UPDATE emp SET sal=sal*1.15 WHERE deptno=20;
Before SCOTT ends the transaction, user HR who has the privileges on EMP table executes a query to
fetch the salary details but finds the old salary values instead of the increased values.
Why does HR still see the old data?
A. because of redo data from redo log file
B. because of data from a temporary tablespace
C. because of undo data from the undo tablespace
D. because of data from database buffer cache
Answer: C

19.In your database, the snapshot interval is set to 10 minutes for the Automatic Workload Repository
(AWR). The database instance is running for the past 30 days.
View the Exhibit to examine the Automatic Database Diagnostic Monitor (ADDM) task.
The ADDM task is performed every 10 minutes, except the last task. What could be the reason for this?










A. The snapshot retention period for the AWR was increased before the last task.
B. The STATISTICS_LEVEL initialization parameter was changed to BASIC and reset to TYPICAL before
the last task.
C. The optimizer statistics was collected manually by using the DBMS_STATS package before the last
task.
D. The optimizer statistics for few objects in the database were locked before the last task.
Answer: B

20.You plan to use static database registration for a new listener when you create it. What could be the
two reasons for this? (Choose two.)
A. The Oracle Enterprise Manager is to be used to monitor an Oracle9i database.
B. More than one database is to be registered with the listener.
C. The listener is not configured on the default port of 1521 and the instance is not configured to register
with a nondefault port.
D. The users will connect the database by using the host naming method.
E. The database that is to be registered with the listener is configured in shared server mode.
Answer: AC