next up previous contents
Next: Instance 管理 cinder 空間 Up: Nova Compute and Controller Previous: 建立 Instances   Contents

測試 Instances 虛擬機

  1. 遠端登入虛擬機。
    [root@dywH ~]# ssh 192.168.122.10
    The authenticity of host '192.168.122.10 (192.168.122.10)' can't be established.
    RSA key fingerprint is 14:9f:cd:45:1e:fe:cd:15:98:57:76:c9:18:99:77:49.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.122.10' (RSA) to the list of known hosts.
    root@192.168.122.10's password: 
    Warning: No xauth data; using fake authentication data for X11 forwarding.
    Last login: Mon Jan 27 07:22:25 2014 from 192.168.122.4
    [root@kvm3 ~]#
    
  2. 虛擬機可連上 internet。
    [root@kvm3 ~]# ping -c 3 163.17.1.1
    PING 163.17.1.1 (163.17.1.1) 56(84) bytes of data.
    64 bytes from 163.17.1.1: icmp_seq=1 ttl=53 time=140 ms
    
    --- 163.17.1.1 ping statistics ---
    3 packets transmitted, 1 received, 66% packet loss, time 3005ms
    rtt min/avg/max/mdev = 140.077/140.077/140.077/0.000 ms
    
  3. 設定 DNS。
    [root@kvm3 ~]# vi /etc/resolv.conf 
    ; generated by /sbin/dhclient-script
    search openstacklocal
    nameserver 192.168.122.1
    nameserver 192.168.32.3
    
  4. 虛擬機的安全性由 openstack 主機控制,故關閉本身防火牆。
    [root@kvm3 ~]# chkconfig iptables off
    [root@kvm3 ~]# /etc/init.d/iptables stop
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Unloading modules:
    
  5. 安裝 httpd。
    [root@kvm3 ~]# yum -y install httpd
    
  6. 啟動網頁服務 httpd,並設定開機啟動。
    [root@kvm3 ~]# /etc/init.d/httpd start
    Starting httpd:                                    [  OK  ]
    [root@kvm3 ~]# chkconfig httpd on
    
  7. 產生 index.html。
    [root@kvm3 ~]# echo 'Instance kvm3 web test.' >> /var/www/html/index.html
    
  8. 到 openstack 主機,改變環境變數為一般使用者 myuser。
    [root@kvm4 ~(keystone_admin)]# source keystonerc_myuser 
    [root@kvm4 ~(keystone_myuser)]#
    
  9. 增加 mysecgroup icmp port,讓遠端可以 ping 虛擬機。
    [root@kvm4 ~(keystone_myuser)]# nova secgroup-add-rule mysecgroup icmp -1 -1 0.0.0.0/0 
    +-------------+-----------+---------+-----------+--------------+
    | IP Protocol | From Port | To Port | IP Range  | Source Group |
    +-------------+-----------+---------+-----------+--------------+
    | icmp        | -1        | -1      | 0.0.0.0/0 |              |
    +-------------+-----------+---------+-----------+--------------+
    
  10. 增加 mysecgroup 80 port。
    [root@kvm4 ~(keystone_myuser)]# nova secgroup-add-rule mysecgroup tcp 80 80 0.0.0.0/0 
    +-------------+-----------+---------+-----------+--------------+
    | IP Protocol | From Port | To Port | IP Range  | Source Group |
    +-------------+-----------+---------+-----------+--------------+
    | tcp         | 80        | 80      | 0.0.0.0/0 |              |
    +-------------+-----------+---------+-----------+--------------+
    
  11. 列出 mysecgroup 開放的 ports。
    [root@kvm4 ~(keystone_myuser)]# nova secgroup-list-rules mysecgroup
    +-------------+-----------+---------+-----------+--------------+
    | IP Protocol | From Port | To Port | IP Range  | Source Group |
    +-------------+-----------+---------+-----------+--------------+
    | icmp        | -1        | -1      | 0.0.0.0/0 |              |
    | tcp         | 22        | 22      | 0.0.0.0/0 |              |
    | tcp         | 80        | 80      | 0.0.0.0/0 |              |
    +-------------+-----------+---------+-----------+--------------+
    
  12. ping 虛擬機。
    [root@kvm4 ~(keystone_myuser)]# ping -c 3 192.168.122.10
    PING 192.168.122.10 (192.168.122.10) 56(84) bytes of data.
    64 bytes from 192.168.122.10: icmp_seq=1 ttl=63 time=2.24 ms
    64 bytes from 192.168.122.10: icmp_seq=2 ttl=63 time=0.348 ms
    64 bytes from 192.168.122.10: icmp_seq=3 ttl=63 time=0.393 ms
    
    --- 192.168.122.10 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2002ms
    rtt min/avg/max/mdev = 0.348/0.993/2.240/0.882 ms
    
  13. 測試虛擬機網頁。
    [root@kvm4 ~(keystone_myuser)]# wget http://192.168.122.10
    --2014-01-27 08:44:44--  http://192.168.122.10/
    Connecting to 192.168.122.10:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 24 [text/html]
    Saving to: “index.html”
    
    100%[======================================>] 24          --.-K/s   in 0s      
    
    2014-01-27 08:44:44 (5.53 MB/s) - “index.html” saved [24/24]
    
    [root@kvm4 ~(keystone_myuser)]# cat index.html 
    Instance kvm3 web test.
    



2015-12-29