---
# System prepended metadata

title: HW03-1072953-賴約翰

---

# HW03-1072953-賴約翰

# 安裝OpenStack並建置虛擬機
* 緣由
作業需求，在學校電腦安裝OpenStack
* 系統簡介(含硬體說明)
1.vendor_id : GenuineIntel
2.model : 94
3.model name : Intel® Xeon® CPU E3-1220 v5 @ 3.00GHz
4.cpu MHz : 2953.9585
5.core id : 3
6.cpu core : 4
7.cache size : 8192KB
8.電腦作業系統為Ubuntu桌面版本 20.04LTS(5年支援) 64位元版
![](https://i.imgur.com/YyNXwtQ.jpg)

* 安裝過程
參考老師上課ppt(08-p01-Ubuntu Openstack DevStack)以及老師提供網站(http://godleon.blogspot.com/2014/10/openstack-ubuntu-1404-6-vm.html)。

1.確認系統是否跟新
```javascript=
sudo apt-get update
sudo apt-get upgrade -y
```
2.建立一個新的user來設置 openstack
```javascript=
sudo useradd -s /bin/bash -d /opt/stack -m stack
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
sudo su - stack
```
3.下載devstack
```javascript=
sudo apt-get install -y git
git clone https://git.openstack.org/openstack-dev/devstack
git checkout stable/mitaka
```
4.進入devstack資料夾並建立local.comf檔
```javascript=
cd devstack
vim local.conf
```
- local.conf內容
```javascript=
[[local|localrc]]
# Password for KeyStone, Database, RabbitMQ and
Service
ADMIN_PASSWORD=StrongAdminSecret
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
# Host IP - get your Server/VM IP address from ip addr command
HOST_IP=192.168.10.100
```
![](https://i.imgur.com/zfJ87py.jpg)
5.安裝Openstack
```javascript=
./stack.sh
```
6.下載Virtual Image
```javascript=
wget http://download.cirroscloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img
```
7.登入openstack web，並source openrc in your shell和Upload it to Glance.
```javascript=
source openrc 
openstack image create \
--container-format bare \
--disk-format qcow2 \
--file cirros-0.5.2-x86_64-disk.img \
Cirros-0.5.2
```
8.產生金鑰對並設定儲存位址
```javascript=
ssh-keygen
```
![](https://i.imgur.com/gbviDc3.jpg)
9.將金鑰對加入openstack並取名為1072953-key
```javascript=
nova keypair-add --pub-key /opt/stack/.ssh/loli.pub 1072953-key
nova keypair-list
```
![](https://i.imgur.com/JBSiBbl.jpg)

10.選擇需要開創的虛擬機規格，選用m1.tiny
```javascript=
openstack flavor list
```


11.選擇使用的映象檔
```javascript=
openstack image list
```
12.查詢可使用的網路
```javascript=
neutron net-list
```
![](https://i.imgur.com/YQr9lun.png)
13.查詢Security Group
```javascript=
openstack security group list
```
14.啟動VM
```javascript=
nova boot --flavor m1.tiny --image 066f7841-c210-4af7-868c-163a8e30a6ef --nic net-id=cbb65f26-2a6e-4b68-8753-64a4a8f70bbe --security-group default --key-name 1072953-key 1072953
```
![](https://i.imgur.com/PHz0dp2.jpg)
15.確認VM狀態
```javascript=
nova list
```


16.存取 VM instance 並測試
```javascript=
nova get-vnc-console 1072943 novnc
```
17.將取得的網址輸入進瀏覽器中，即可看到虛擬機在運作中，並輸入hostname，可看到主機明成為學號 1072953
```javascript=
hostname
```
![](https://i.imgur.com/ukGUtBm.jpg)



* 結論
這次的作業很複雜，花了很多時間以及和同學討論才好不容易完成。
