Azure App Service 및 Azure Database for MySQL으로 마이그레이션 해보고자 합니다.
Azure Cloud Shell을 통해 Azure 명령을 쉽게 실행할 수 있습니다. 또한 리소스 그룹은 이번 실습을 위해 사용할 것입니다.
2.1.1. 오른쪽 윗 부분에서 >_
모양 아이콘을 클릭합니다.
2.1.2. 유형은 Bash
를 선택한 다음, 저장소 만들기
를 클릭합니다.
2.1.3. Azure Cloud Shell에서 다음을 실행하여 리소스 그룹을 만듭니다. (GUI에서도 가능합니다)
az group create --name BootcampPaaS --location "East US"
2.2.1 이름이 중복되지 않도록 이름 뒤에 숫자를 적절히 변경하여 생성합니다 (예: bootcampmysql23
)
az mysql server create --resource-group BootcampPaaS --name bootcampmysql23 \
--location "East US" --admin-user demouser --admin-password bootcamp@pass1 \
--sku-name B_Gen4_1 --storage-size 51200 --ssl-enforcement Disabled
완료 예시:
choi@Azure:~$ az mysql server create --resource-group BootcampPaaS --name bootcampmysql23 \
> --location "East US" --admin-user demouser --admin-password bootcamp@pass1 \
> --sku-name B_Gen4_1 --storage-size 51200 --ssl-enforcement Disabled
{
"additionalProperties": {},
"administratorLogin": "demouser",
"earliestRestoreDate": "2018-04-20T20:50:02.070000+00:00",
"fullyQualifiedDomainName": "bootcampmysql23.mysql.database.azure.com",
"id": "/subscriptions/08c1ceff-e148-4d07-b041-f88ef848a5b2/resourceGroups/BootcampPaaS/providers/Microsoft.DBforMySQL/servers/bootcampmysql23",
"location": "eastus",
"name": "bootcampmysql23",
"resourceGroup": "BootcampPaaS",
"sku": {
"additionalProperties": {},
"capacity": 1,
"family": "Gen4",
"name": "B_Gen4_1",
"size": null,
"tier": "Basic"
},
"sslEnforcement": "Disabled",
"storageProfile": {
"additionalProperties": {},
"backupRetentionDays": 7,
"geoRedundantBackup": "Disabled",
"storageMb": 51200
},
"tags": null,
"type": "Microsoft.DBforMySQL/servers",
"userVisibleState": "Ready",
"version": "5.7"
}
2.2.2 네트워크 시큐리티 그룹 규칙을 추가합니다. 여기에서는 실습 목적으로 전체 허용을 하였습니다.
az mysql server firewall-rule create --resource-group BootcampPaaS \
--server-name bootcampmysql23 --name Internet --start-ip-address 0.0.0.0 \
--end-ip-address 255.255.255.255
2.2.3 Azure Portal 에서 해당 자원을 선택하여 연결 문자열
을 복사합니다.
2.2.4 변수 부분에 대해 항목을 변경해 봅니다. 예를 들어,
Database={your_database}; Data Source={host_name}; User Id={your_username}; Password={your_password}
를 다음과 같이 변경합니다. 데이터베이스 이름은 osticket
으로 하겠습니다.
Database=osticket; Data Source=bootcampmysql23.mysql.database.azure.com; User Id=demouser@bootcampmysql23; Password=bootcamp@pass1
2.3.1 기존 LAB 머신에 접속하여 MySQL Workbench를 실행합니다.
2.3.2 MySQL Connections
오른쪽에 + 버튼을 누르고 다음과 같이 데이터베이스에 접속합니다.
- Connection Name: 연결 문자열에서 Data Source 부분 복사 & 붙여넣기
- Connection Method: Standard TCP/IP
- MySQL Hostname: 연결 문자열에서 Data Source 부분 복사 & 붙여넣기
- MySQL Server Port: 3306
- Username: 연결 문자열에서 User Id 부분 복사 & 붙여넣기
- Password: bootcamp@pass1
2.3.3 Test Connection
을 통해 연결을 테스트한 후 Ok를 눌러 연결을 추가합니다.
2.3.4 추가한 연결을 더블클릭합니다.
2.3.5 진행자를 통해 온-프레미스 credential을 입력하여 접속한 후, 데이터를 export합니다.
2.3.6 Data Import/Restore
를 선택한 다음 Import from Self-Contained File
에서 export하였던 데이터 파일을 선택합니다.
2.3.7 osticket
데이터베이스로 가져온 다음 결과를 확인합니다.
2.4.1 Azure Cloud Shell에서 다음 명령어를 실행하여 앱 서비스 플랜을 만듭니다.
az appservice plan create -n bootcampwebplan23 -g BootcampPaaS --is-linux \
-l "EastUS 2" --sku S1 --number-of-workers 1
2.4.2 다음 명령어를 실행하여 PHP 7.0 기반 웹 앱을 생성합니다.
az webapp create -n bootcampwebapp23 -g BootcampPaaS \
-p bootcampwebplan23 -r "php|7.0"
2.4.3 만들어진 웹 앱을 GUI에서 확인합니다.
2.4.4 응용 프로그램 설정
에서 아래 새 연결 문자열 추가
를 클릭하고, 이전에 만들어 놓았던 연결 문자열을 붙여넣습니다. 연결 문자열 이름은 osticket
으로, 유형은 MySQL
으로 설정합니다. 완료 후, 위 저장
버튼을 클릭합니다.
2.4.5 https://github.com/ianychoi/php-osticket URL로 접속하여 fork합니다.
2.4.6 include/ost-config.php
파일에서 DBHOST, DBNAME, DBUSER, DBPASS를 변경하여 커밋을 합니다.
2.4.7 Azure 웹 앱에서 배포 옵션
탭을 선택합니다.
2.4.8 소스를 GitHub
으로 선택한 다음, GitHub 계정에 대해 권한을 부여합니다.
2.4.9 프로젝트를 php-osticket
으로 선택하고 지점은 디폴트 master
를 사용합니다.
2.4.10 배포가 완료된 후, 결과를 웹 사이트에서 확인해 봅니다.
더 이상 사용하지 않는 자원에 대해서는 제거를 하는 것이 좋습니다.