---
# System prepended metadata

title: 安裝openstack並建立虛擬機

---

# 安裝openstack並建立虛擬機

## 1. 緣由
此為安裝openstack的過程

## 2. 系統簡介
伺服器：Ubuntu 22.04 LTS Server 
伺服器IP：10.2.200.196


## 3. 安裝過程

### 建立stack
```
sudo useradd -s /bin/bash -d /opt/stack -m 
sudo chmod +x /opt/stack
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
```
![image](https://hackmd.io/_uploads/r1xPPwrE7C.png)

### 下載OpenStack相關的套件
```
sudo -u stack -i
sudo apt-get install -y git
git clone https://opendev.org/openstack/devstack
```
![image](https://hackmd.io/_uploads/H1BjPHNmA.png)
![image](https://hackmd.io/_uploads/ByB1dSE7A.png)

### 建立local.conf文件
```
cd devstack
sudo nano local.conf
```
![image](https://hackmd.io/_uploads/B1K35SV7A.png)

![image](https://hackmd.io/_uploads/H1HF5BN7A.png)

### 安裝OpenStack

```
./stack.sh
```

### 登入OpenStack

![image](https://hackmd.io/_uploads/B1xFUUVQ0.png)

### 網路設定

```
Admin -> Network -> Networks -> public -> 子網路 -> 新增子網路
```
![image](https://hackmd.io/_uploads/SkL7DINXC.png)
![image](https://hackmd.io/_uploads/rk7qOLN7A.png)

### 橋接虛擬網卡到實體網卡

```
sudo ovs-vsctl add-port br-ex eno1
sudo ip addr flush dev eno1
```
![image](https://hackmd.io/_uploads/SkYZ9LN7A.png)

```
sudo nano /etc/netplan/00-installer-config.yaml
```
![f35469fd-5eaf-45cb-ae6d-1c414fb17654](https://hackmd.io/_uploads/Hy71h6EXA.jpg)

更新網路配置
```
sudo netplan try
```

```
sudo ip addr add "yourIP" dev br-ex
sudo ip link set br-ex up
```
![image](https://hackmd.io/_uploads/r1M7lvNQ0.png)

### 新增網路

![image](https://hackmd.io/_uploads/HJ5b4PEmA.png)
![image](https://hackmd.io/_uploads/ryVQNPVQR.png)
![image](https://hackmd.io/_uploads/S1UzBvV70.png)

### 新增router

```
Admin -> Network -> Routers -> Create Router
```
![image](https://hackmd.io/_uploads/SyPwzPEXR.png)

### 分配浮動IP

```
Admin -> Network -> Floating IPs -> Allocate IP To Project
```
![image](https://hackmd.io/_uploads/HkSczwVXA.png)

### 發布雲實例

```
Project -> Compute -> Instances -> Launch Instance
```
![image](https://hackmd.io/_uploads/ryDuuw4QR.png)
![image](https://hackmd.io/_uploads/rydS7D4mR.png)
![image](https://hackmd.io/_uploads/rkpnCvVm0.png)
![image](https://hackmd.io/_uploads/rJ23uw47C.png)

## 4. 結論
安裝OpenStack的過程很有挑戰，在安裝過程中，我們學到了不少關於OpenStack相關的知識。

## 5. Reference

https://medium.com/@kcoupal/how-to-install-openstack-on-ubuntu-22-04-with-devstack-3336c01ddcfa
https://hackmd.io/@FrCgWmOfTYe5ewU0YFGFmQ/rJy9bDyr2