學習目標
- 在 AWS EC2 建立 Apache NiFi
前置準備作業
一台能上網的電腦
已擁有 AWS 帳號且能正常使用 AWS 的服務
啟動 AWS EC2 Ubuntu Server
Step 1. 開啟 AWS Portal
❖ 透過覽瀏器開啟下方網址
https://aws.amazon.com/tw/
Step 2. 選取 AWS EC2 服務
❖ 點選 【 Services 】中的 【 EC2 】
Step 3. 進入 Instance 設定頁面
❖ 點選 【 Launch Instance 】
Step 4. 選擇作業系統種類
❖ 點選 【 Ubuntu Server 16.04 LTS (HVM), SSD Volume Type - ami-0f9cf087c1f27d9b1 (64-bit x86) / ami-036ede09922dadc9b (64-bit Arm) 】中的【 Select 】按鈕
Step 5. 選擇 Instance 規格
❖ 選擇【 t2.small 】規格
㊟ 規格可自行決定,本範例使用【 t2.small 】規格示範
㊟ 記憶體至少 2G 以上
Step 6. 設定埠 (Port) 號
❖ 選擇【 6. Configure Security Group 】連結
❖ 點選【 Add Rule 】按鈕
❖ ① 在【 Port Range 】欄位輸入【 8080 】
在【 Source 】欄位輸入【 0.0.0.0/0 】
㊟【 Source 】欄位可依需求調整,本範例使用【 0.0.0.0/0 】
❖ 點選【 Review and Launch 】按鈕
Step 7. 啟動 Instance
❖ 點選【 Launch 】按鈕
Step 8. 設定 key
❖ 依需求建立 key
❖ 點選確認選項
❖ 點選【 Launch Instances 】按鈕
Step 9. Ubuntu Server 建立結果
❖ 點選【 View Instances 】按鈕
❖ 【 Ubuntu Server 】相關資訊
Step 10. 取得 Ubuntu Server 登入資訊
❖ 點選【 Connect 】按鈕
❖ 登入資訊
㊟ 之後登入到 Ubuntu Server 會使用到此資訊
Step 11. 取得傳送檔案到 Ubuntu Server 的資訊
❖ 點選【 Connect 】按鈕
❖ 傳送檔案資訊
㊟ 之後傳送檔案到 Ubuntu Server 會使用到此資訊
Step 12. 登入到 AWS EC2
Step 13. 安裝 OpenJDK 8
① 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
sudo apt update
② 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
sudo apt install -y openjdk-8-jdk
③ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
java -version
④ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
sudo update-alternatives --config java
⑤ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
sudo nano /etc/environment
⑥ 將游標移到最後一行
⑥ 在最後一行輸入下方資訊
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/"
⑦ 按【 Control + x 】離開
輸入【 Y 】
再按【 enter 】鍵
⑧ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
source /etc/environment
⑨ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
echo $JAVA_HOME
Step 14. 下載 Apache NiFi
❖ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
wget ftp://ftp.twaren.net/Unix/Web/apache/nifi/1.8.0/nifi-1.8.0-bin.tar.gz
Step 15. 解壓縮
❖ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
tar zxvf nifi-1.8.0-bin.tar.gz
Step 16. 啟動 NiFi
❖ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
nifi-1.8.0/bin/nifi.sh start
Step 17. 取得 NiFi IP
❖ ① 點選左側的 【 Instances 】
② IP 位於【 IPv4 Public IP 】欄位中
Step 18. Browse NiFi
❖ 於瀏覽器輸入下方網址
http://NiFi-IP:8080/nifi
Step 19. 停止 NiFi
❖ 於終端機 【 macOS 】或 Putty 【 Windows 】中輸入下方指令
nifi-1.8.0/bin/nifi.sh stop