SlideShare a Scribd company logo
使用 Load Balancer 與 Redis
部署 LAMP Server 高併發架構
Laird Cheng
Laird Cheng
『成功不易複製,但Knowhow可以。』
● 資深工程師
● Android, iOS, Web, Unity
● Java, SwiftUI, PHP, Python
● CodeIgniter, Laravel
● Azure, LAMP, CentOS, Ubuntu
● [Study] Flutter, CI/CD, 自動化測試
Agenda
1. 建立 Azure Cli VM
2. 建立/更新 VM 、安裝 GUI
3. NoMachine 遠端桌面
4. 安裝/啟動 XAMPP
5. 建立/設定 Redis
6. 安裝/啟動 SmartGit
7. 複製 VM
8. 建立/掛載 LoadBalancer
9. 驗證&測試
Live Demo
Thank you!
議程文檔整理
1. 建立 Azure Cli VM
1. 建立 Azure Cli VM
Portal 建立 VM:Cli-CentOS-0425
[由個人電腦SSH連線至VM後]
CentOS 指令:
sudo rpm --import
https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[azure-cli]
name=Azure CLI
baseurl=https://packages.microsoft.com/yumrepos/azure-cli
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc" >
/etc/yum.repos.d/azure-cli.repo'
sudo yum install azure-cli
1. 建立 Azure Cli VM
*Cli使用:
[由個人電腦SSH連線至VM後]
//登入Azure
az login
https://microsoft.com/devicelogin
輸入驗證碼,並登入Azure帳戶
Done.
2. 建立/更新 VM 、安裝 GUI
2. 建立/更新 VM 、安裝 GUI
Azure Cli 指令:
建立Vnet
az network vnet create --resource-group TEST 
--location eastasia --name Test-Vnet 
--address-prefix 192.168.0.0/16 
--subnet-name Test-Subnet 
--subnet-prefix 192.168.1.0/24
2. 建立/更新 VM 、安裝 GUI
Azure Cli 指令:
建立IP
az network public-ip create --resource-group TEST 
--location eastasia --name Test1_CentOS_IP 
--dns-name laird0425tw1 
--allocation-method static 
--idle-timeout 4
2. 建立/更新 VM 、安裝 GUI
Azure Cli 指令:
建立NIC
az network nic create --resource-group TEST 
--location eastasia --name Test1_NIC 
--vnet-name Test-Vnet --subnet Test-Subnet 
--public-ip-address Test1_CentOS_IP
2. 建立/更新 VM 、安裝 GUI
Azure Cli 指令:
建立VM
az vm create 
--resource-group TEST 
--name Test1_CentOS_0425 
--image OpenLogic:CentOS:7.7:latest 
--size Standard_D2s_v3 
--admin-username <username> 
--admin-password <password> 
--nics Test1_NIC 
--availability-set Test_AS 
--os-disk-name Test1_OsDisk 
--os-disk-size-gb 30 
--no-wait
2. 建立/更新 VM 、安裝 GUI
*坑!!
Loadbalancer需要
--availability-set
Portal 建立可用性設定組 Availability Set
2. 建立/更新 VM 、安裝 GUI
Portal 建立網路安全群組 NSG
Test_NSG_0425
接著前往 NSG 資源
選擇”網路介面”=>”關聯”
打開常用的Port:
22 SSH(預設公開)
80 HTTP
443 HTTPS
3389 RDP
4000 NoMachine
2. 建立/更新 VM 、安裝 GUI
[SSH連線至VM]
CentOS 指令:
//清除中繼資料
sudo yum clean all
//更新套件
sudo yum -y update
//安裝開發套件
sudo yum groupinstall 'Development Tools'
2. 建立/更新 VM 、安裝 GUI
//安裝GUI(約需5分鐘)
sudo yum groupinstall "Server with GUI"
//開機自動進入GUI模式
sudo systemctl set-default graphical.target
//重新開機
sudo reboot
Done.
3. NoMachine 遠端桌面
3. NoMachine 遠端桌面
//下載NoMachine
sudo wget
https://download.nomachine.com/download/6.9/
Linux/nomachine_6.9.2_1_x86_64.rpm
//安裝rpm
sudo rpm -i nomachine_6.9.2_1_x86_64.rpm
Done.
4. 安裝/啟動 XAMPP
4. 安裝/啟動 XAMPP
CentOS 指令:
//下載XAMPP
sudo wget
https://www.apachefriends.org/xampp-files/7.4.2/
xampp-linux-x64-7.4.2-0-installer.run
//改檔案權限
sudo chmod 755
xampp-linux-x64-7.4.2-0-installer.run
//安裝
sudo ./xampp-linux-x64-7.4.2-0-installer.run
4. 安裝/啟動 XAMPP
CentOS 指令:
啟動 XAMPP GUI
sudo /opt/lampp/manager-linux-x64.run
啟動 Apache / MySQL
Done.
5. 建立/設定 Redis
5. 建立/設定 Redis
Portal 建立 Azure Cache for Redis
test-redis-0425
[PHP 使用 Redis 儲存 Session]
編輯php.ini
opt/lampp/etc/php.ini
session.save_handler = redis
(預設值 files )
session.save_path =
“tcp://<Azure_Redis_Endpoint>:6379?auth=<url encoded key>”
(預設值 "/opt/lampp/temp" )
5. 建立/設定 Redis
*坑!!
<url encoded key>
Source
Tool: UrlEncoder
//session自動start,不需要再session_start()
session.auto_start=1
(預設為 0 )
重啟 Apache
Done.
6. 安裝/啟動 SmartGit
6. 安裝/啟動 SmartGit
CentOS 指令:
//安裝Git
sudo yum install git
//開啟 Firefox 下載 Linux (tar.gz bundle),Save File
https://www.syntevo.com/smartgit/download/
//切換路徑
cd Downloads
//安裝SmartGit
sudo ./smartgit/bin/smartgit.sh
6. 安裝/啟動 SmartGit
“Programming” 啟動 SmartGit
Clone Repo 至 htdocs
測試網站/會員登入功能
Done.
7. 複製 VM
7. 複製 VM
Azure Cli 指令:
複製受控磁碟
az disk create --resource-group TEST 
--name Test2_OsDisk 
--source Test1_OsDisk
7. 複製 VM
Azure Cli 指令:
建立IP
az network public-ip create --resource-group TEST 
--location eastasia --name Test2_CentOS_IP 
--dns-name laird0425tw2 
--allocation-method static 
--idle-timeout 4
7. 複製 VM
Azure Cli 指令:
建立NIC
az network nic create --resource-group TEST 
--location eastasia --name Test2_NIC 
--vnet-name Test-Vnet --subnet Test-Subnet 
--public-ip-address Test2_CentOS_IP
7. 複製 VM
Azure Cli 指令:
基於OsDisk建立VM
az vm create 
--resource-group TEST 
--name Test2_CentOS_0425 
--size Standard_D2s_v3 
--nics Test2_NIC 
--availability-set Test_AS 
--attach-os-disk Test2_OsDisk
--no-wait
Done.
8. 建立/掛載 LoadBalancer
8. 建立/掛載 LoadBalancer
Azure Cli 指令:
建立負載平衡IP
az network public-ip create
--resource-group TEST 
--location eastasia --name Test_LB_IP 
--dns-name laird0425tw 
--allocation-method static 
--idle-timeout 4
8. 建立/掛載 LoadBalancer
Protal 建立 LoadBalancer
Test_LB
新增前端IP:LoadBalancerFrontEnd
選擇 Test_LB_IP
新增後端集區:BackendPool
關聯對象
Test1_CentOS_0425
Test2_CentOS_0425
Done.
9. 測試&驗證
9. 測試&驗證
1. [驗證分流]
修改專案code,Refresh首頁會顯示不同內容
9. 測試&驗證
2. [驗證Session共用]
Redis共用Session
=>登入會員後,Refresh都會是登入狀態
將VM1的php.ini改回原來設定
session.save_handler = files
session.save_path = /opt/lampp/temp
重啟Apache
Refresh首頁
=>LB分流進到VM1時,會是無登入狀態
Done.
Thank you!

More Related Content

What's hot

Vagrant教學
Vagrant教學Vagrant教學
Vagrant教學
Onnie Fong
 
Npm 套件管理 & 常用開發工具介紹
Npm 套件管理 & 常用開發工具介紹Npm 套件管理 & 常用開發工具介紹
Npm 套件管理 & 常用開發工具介紹
wantingj
 
Npm node.js的套件管理程式
Npm node.js的套件管理程式Npm node.js的套件管理程式
Npm node.js的套件管理程式
Chuyi Huang
 
從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用
謝 宗穎
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理haiyuan ning
 
GNU Build System
GNU Build SystemGNU Build System
GNU Build System
imacat .
 
使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式
Will Huang
 
用Maven管理專案的依賴關係
用Maven管理專案的依賴關係用Maven管理專案的依賴關係
用Maven管理專案的依賴關係
Huang Bruce
 
20150604 docker 新手入門
20150604 docker 新手入門20150604 docker 新手入門
20150604 docker 新手入門
azole Lai
 
HPE SimpliVity 使用PowerShell 控制
HPE SimpliVity 使用PowerShell 控制HPE SimpliVity 使用PowerShell 控制
HPE SimpliVity 使用PowerShell 控制
裝機安 Angelo
 
Admin generator
Admin generatorAdmin generator
Admin generator
Ricky Su
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorial
azole Lai
 
前端工程師一定要知道的 Docker 虛擬化容器技巧
前端工程師一定要知道的 Docker 虛擬化容器技巧前端工程師一定要知道的 Docker 虛擬化容器技巧
前端工程師一定要知道的 Docker 虛擬化容器技巧
Chu-Siang Lai
 
Vagrant introduction
Vagrant introductionVagrant introduction
Vagrant introduction
Chyi-Shian Jiang
 
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程Simon Su
 
Koa 正在等一個人
Koa 正在等一個人Koa 正在等一個人
Koa 正在等一個人
Fred Chien
 
Continuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CIContinuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CI
Chu-Siang Lai
 
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
Shengyou Fan
 
(2020-04)HPE SimpliVity node 關機
(2020-04)HPE SimpliVity node 關機(2020-04)HPE SimpliVity node 關機
(2020-04)HPE SimpliVity node 關機
裝機安 Angelo
 

What's hot (20)

Vagrant教學
Vagrant教學Vagrant教學
Vagrant教學
 
Npm 套件管理 & 常用開發工具介紹
Npm 套件管理 & 常用開發工具介紹Npm 套件管理 & 常用開發工具介紹
Npm 套件管理 & 常用開發工具介紹
 
Banquet 01
Banquet 01Banquet 01
Banquet 01
 
Npm node.js的套件管理程式
Npm node.js的套件管理程式Npm node.js的套件管理程式
Npm node.js的套件管理程式
 
從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理
 
GNU Build System
GNU Build SystemGNU Build System
GNU Build System
 
使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式使用 Visual Studio Code 建構 JavaScript 應用程式
使用 Visual Studio Code 建構 JavaScript 應用程式
 
用Maven管理專案的依賴關係
用Maven管理專案的依賴關係用Maven管理專案的依賴關係
用Maven管理專案的依賴關係
 
20150604 docker 新手入門
20150604 docker 新手入門20150604 docker 新手入門
20150604 docker 新手入門
 
HPE SimpliVity 使用PowerShell 控制
HPE SimpliVity 使用PowerShell 控制HPE SimpliVity 使用PowerShell 控制
HPE SimpliVity 使用PowerShell 控制
 
Admin generator
Admin generatorAdmin generator
Admin generator
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorial
 
前端工程師一定要知道的 Docker 虛擬化容器技巧
前端工程師一定要知道的 Docker 虛擬化容器技巧前端工程師一定要知道的 Docker 虛擬化容器技巧
前端工程師一定要知道的 Docker 虛擬化容器技巧
 
Vagrant introduction
Vagrant introductionVagrant introduction
Vagrant introduction
 
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程
 
Koa 正在等一個人
Koa 正在等一個人Koa 正在等一個人
Koa 正在等一個人
 
Continuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CIContinuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CI
 
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
[Modern Web 2016] 讓你的 PHP 開發流程再次潮起來
 
(2020-04)HPE SimpliVity node 關機
(2020-04)HPE SimpliVity node 關機(2020-04)HPE SimpliVity node 關機
(2020-04)HPE SimpliVity node 關機
 

Similar to 使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 @ 集思北科大

Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuRuby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
MarsZ Chen
 
2, installation
2, installation2, installation
2, installation
ted-xu
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
Chu-Siang Lai
 
自动化运维管理
自动化运维管理自动化运维管理
自动化运维管理frankwsj
 
使用Samba提升linux平台开发效率
使用Samba提升linux平台开发效率使用Samba提升linux平台开发效率
使用Samba提升linux平台开发效率Zhen Li
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
Kenny (netman)
 
Hadoop平台搭建
Hadoop平台搭建Hadoop平台搭建
Hadoop平台搭建Liyang Tang
 
Apache安装配置mod security
Apache安装配置mod securityApache安装配置mod security
Apache安装配置mod security
Huang Toby
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理Jason Zheng
 
CloudStack Installation on Ubuntu
CloudStack Installation on UbuntuCloudStack Installation on Ubuntu
CloudStack Installation on Ubuntu康志強 大人
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩Wen-Tien Chang
 
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
裝機安 Angelo
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结Yiwei Ma
 
Ruby on Rails 開發環境建置 for Mac
Ruby on Rails 開發環境建置 for MacRuby on Rails 開發環境建置 for Mac
Ruby on Rails 開發環境建置 for Mac
MarsZ Chen
 
Linuxguide4f2e
Linuxguide4f2eLinuxguide4f2e
Linuxguide4f2e
tb-vertical-guide
 
GNU Autoconf / Automake #1
GNU Autoconf / Automake #1GNU Autoconf / Automake #1
GNU Autoconf / Automake #1
imacat .
 
Hadoop 安装
Hadoop 安装Hadoop 安装
Hadoop 安装
feng lee
 
Configuration tutorial for pytorch environment under windows.pdf
Configuration tutorial for pytorch environment under windows.pdfConfiguration tutorial for pytorch environment under windows.pdf
Configuration tutorial for pytorch environment under windows.pdf
shuaihaohan135
 
Nova与虚拟机管理
Nova与虚拟机管理Nova与虚拟机管理
Nova与虚拟机管理
OpenCity Community
 

Similar to 使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 @ 集思北科大 (20)

Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuRuby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
 
2, installation
2, installation2, installation
2, installation
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
 
自动化运维管理
自动化运维管理自动化运维管理
自动化运维管理
 
使用Samba提升linux平台开发效率
使用Samba提升linux平台开发效率使用Samba提升linux平台开发效率
使用Samba提升linux平台开发效率
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
 
Hadoop平台搭建
Hadoop平台搭建Hadoop平台搭建
Hadoop平台搭建
 
Apache安装配置mod security
Apache安装配置mod securityApache安装配置mod security
Apache安装配置mod security
 
使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理使用Rpm&yum进行基础软件管理
使用Rpm&yum进行基础软件管理
 
CloudStack Installation on Ubuntu
CloudStack Installation on UbuntuCloudStack Installation on Ubuntu
CloudStack Installation on Ubuntu
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
 
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
HPE SimpliVity install mgmt guide 201907-01 (Taiwan-Chinese) ;HPE SimpliVity ...
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结
 
Ruby on Rails 開發環境建置 for Mac
Ruby on Rails 開發環境建置 for MacRuby on Rails 開發環境建置 for Mac
Ruby on Rails 開發環境建置 for Mac
 
Linuxguide4f2e
Linuxguide4f2eLinuxguide4f2e
Linuxguide4f2e
 
LinuxGuide4F2E
LinuxGuide4F2ELinuxGuide4F2E
LinuxGuide4F2E
 
GNU Autoconf / Automake #1
GNU Autoconf / Automake #1GNU Autoconf / Automake #1
GNU Autoconf / Automake #1
 
Hadoop 安装
Hadoop 安装Hadoop 安装
Hadoop 安装
 
Configuration tutorial for pytorch environment under windows.pdf
Configuration tutorial for pytorch environment under windows.pdfConfiguration tutorial for pytorch environment under windows.pdf
Configuration tutorial for pytorch environment under windows.pdf
 
Nova与虚拟机管理
Nova与虚拟机管理Nova与虚拟机管理
Nova与虚拟机管理
 

使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 @ 集思北科大

  • 1. 使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 Laird Cheng
  • 2. Laird Cheng 『成功不易複製,但Knowhow可以。』 ● 資深工程師 ● Android, iOS, Web, Unity ● Java, SwiftUI, PHP, Python ● CodeIgniter, Laravel ● Azure, LAMP, CentOS, Ubuntu ● [Study] Flutter, CI/CD, 自動化測試
  • 3. Agenda 1. 建立 Azure Cli VM 2. 建立/更新 VM 、安裝 GUI 3. NoMachine 遠端桌面 4. 安裝/啟動 XAMPP 5. 建立/設定 Redis 6. 安裝/啟動 SmartGit 7. 複製 VM 8. 建立/掛載 LoadBalancer 9. 驗證&測試
  • 8. 1. 建立 Azure Cli VM Portal 建立 VM:Cli-CentOS-0425 [由個人電腦SSH連線至VM後] CentOS 指令: sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo sh -c 'echo -e "[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/azure-cli enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo' sudo yum install azure-cli
  • 9. 1. 建立 Azure Cli VM *Cli使用: [由個人電腦SSH連線至VM後] //登入Azure az login https://microsoft.com/devicelogin 輸入驗證碼,並登入Azure帳戶 Done.
  • 10. 2. 建立/更新 VM 、安裝 GUI
  • 11. 2. 建立/更新 VM 、安裝 GUI Azure Cli 指令: 建立Vnet az network vnet create --resource-group TEST --location eastasia --name Test-Vnet --address-prefix 192.168.0.0/16 --subnet-name Test-Subnet --subnet-prefix 192.168.1.0/24
  • 12. 2. 建立/更新 VM 、安裝 GUI Azure Cli 指令: 建立IP az network public-ip create --resource-group TEST --location eastasia --name Test1_CentOS_IP --dns-name laird0425tw1 --allocation-method static --idle-timeout 4
  • 13. 2. 建立/更新 VM 、安裝 GUI Azure Cli 指令: 建立NIC az network nic create --resource-group TEST --location eastasia --name Test1_NIC --vnet-name Test-Vnet --subnet Test-Subnet --public-ip-address Test1_CentOS_IP
  • 14. 2. 建立/更新 VM 、安裝 GUI Azure Cli 指令: 建立VM az vm create --resource-group TEST --name Test1_CentOS_0425 --image OpenLogic:CentOS:7.7:latest --size Standard_D2s_v3 --admin-username <username> --admin-password <password> --nics Test1_NIC --availability-set Test_AS --os-disk-name Test1_OsDisk --os-disk-size-gb 30 --no-wait
  • 15. 2. 建立/更新 VM 、安裝 GUI *坑!! Loadbalancer需要 --availability-set Portal 建立可用性設定組 Availability Set
  • 16. 2. 建立/更新 VM 、安裝 GUI Portal 建立網路安全群組 NSG Test_NSG_0425 接著前往 NSG 資源 選擇”網路介面”=>”關聯” 打開常用的Port: 22 SSH(預設公開) 80 HTTP 443 HTTPS 3389 RDP 4000 NoMachine
  • 17. 2. 建立/更新 VM 、安裝 GUI [SSH連線至VM] CentOS 指令: //清除中繼資料 sudo yum clean all //更新套件 sudo yum -y update //安裝開發套件 sudo yum groupinstall 'Development Tools'
  • 18. 2. 建立/更新 VM 、安裝 GUI //安裝GUI(約需5分鐘) sudo yum groupinstall "Server with GUI" //開機自動進入GUI模式 sudo systemctl set-default graphical.target //重新開機 sudo reboot Done.
  • 20. 3. NoMachine 遠端桌面 //下載NoMachine sudo wget https://download.nomachine.com/download/6.9/ Linux/nomachine_6.9.2_1_x86_64.rpm //安裝rpm sudo rpm -i nomachine_6.9.2_1_x86_64.rpm Done.
  • 22. 4. 安裝/啟動 XAMPP CentOS 指令: //下載XAMPP sudo wget https://www.apachefriends.org/xampp-files/7.4.2/ xampp-linux-x64-7.4.2-0-installer.run //改檔案權限 sudo chmod 755 xampp-linux-x64-7.4.2-0-installer.run //安裝 sudo ./xampp-linux-x64-7.4.2-0-installer.run
  • 23. 4. 安裝/啟動 XAMPP CentOS 指令: 啟動 XAMPP GUI sudo /opt/lampp/manager-linux-x64.run 啟動 Apache / MySQL Done.
  • 25. 5. 建立/設定 Redis Portal 建立 Azure Cache for Redis test-redis-0425 [PHP 使用 Redis 儲存 Session] 編輯php.ini opt/lampp/etc/php.ini session.save_handler = redis (預設值 files ) session.save_path = “tcp://<Azure_Redis_Endpoint>:6379?auth=<url encoded key>” (預設值 "/opt/lampp/temp" )
  • 26. 5. 建立/設定 Redis *坑!! <url encoded key> Source Tool: UrlEncoder //session自動start,不需要再session_start() session.auto_start=1 (預設為 0 ) 重啟 Apache Done.
  • 28. 6. 安裝/啟動 SmartGit CentOS 指令: //安裝Git sudo yum install git //開啟 Firefox 下載 Linux (tar.gz bundle),Save File https://www.syntevo.com/smartgit/download/ //切換路徑 cd Downloads //安裝SmartGit sudo ./smartgit/bin/smartgit.sh
  • 29. 6. 安裝/啟動 SmartGit “Programming” 啟動 SmartGit Clone Repo 至 htdocs 測試網站/會員登入功能 Done.
  • 31. 7. 複製 VM Azure Cli 指令: 複製受控磁碟 az disk create --resource-group TEST --name Test2_OsDisk --source Test1_OsDisk
  • 32. 7. 複製 VM Azure Cli 指令: 建立IP az network public-ip create --resource-group TEST --location eastasia --name Test2_CentOS_IP --dns-name laird0425tw2 --allocation-method static --idle-timeout 4
  • 33. 7. 複製 VM Azure Cli 指令: 建立NIC az network nic create --resource-group TEST --location eastasia --name Test2_NIC --vnet-name Test-Vnet --subnet Test-Subnet --public-ip-address Test2_CentOS_IP
  • 34. 7. 複製 VM Azure Cli 指令: 基於OsDisk建立VM az vm create --resource-group TEST --name Test2_CentOS_0425 --size Standard_D2s_v3 --nics Test2_NIC --availability-set Test_AS --attach-os-disk Test2_OsDisk --no-wait Done.
  • 36. 8. 建立/掛載 LoadBalancer Azure Cli 指令: 建立負載平衡IP az network public-ip create --resource-group TEST --location eastasia --name Test_LB_IP --dns-name laird0425tw --allocation-method static --idle-timeout 4
  • 37. 8. 建立/掛載 LoadBalancer Protal 建立 LoadBalancer Test_LB 新增前端IP:LoadBalancerFrontEnd 選擇 Test_LB_IP 新增後端集區:BackendPool 關聯對象 Test1_CentOS_0425 Test2_CentOS_0425 Done.
  • 40. 9. 測試&驗證 2. [驗證Session共用] Redis共用Session =>登入會員後,Refresh都會是登入狀態 將VM1的php.ini改回原來設定 session.save_handler = files session.save_path = /opt/lampp/temp 重啟Apache Refresh首頁 =>LB分流進到VM1時,會是無登入狀態 Done.