

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# AWS Lambda 및 Task Scheduler를 사용하여 Amazon EC2에서 실행되는 SQL Server Express 에디션에서 데이터베이스 작업 자동화
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2"></a>

*Subhani Shaik, Amazon Web Services*

## 요약
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-summary"></a>

이 패턴은 SQL Server의 무료 버전인 SQL Server Express 에디션에서 데이터베이스 작업을 예약하고 관리하는 방법을 보여줍니다. 하지만 SQL Server Express 에디션에는 일반적으로 자동화된 데이터베이스 작업을 처리하는 SQL Server Agent 서비스가 없습니다. 이 패턴에서는 Amazon Elastic Compute Cloud(Amazon EC2) 인스턴스에서 실행되는 SQL Server Express 에디션에서 데이터베이스 작업을 자동화하기 위한 대안으로 작업 스케줄러와 Lambda를 사용하는 방법을 설명합니다.

[Task Scheduler](https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page)는 일상적인 작업의 자동 실행을 지원하는 기본 제공 Windows 시스템 유틸리티입니다. 자동 작업을 예약하고 관리하는 메커니즘을 제공하므로 반복 프로세스에서 수동 개입이 필요하지 않습니다. [AWS Lambda](https://aws.amazon.com/lambda/)는 기본 인프라를 관리할 필요 없이 이벤트에 대한 응답으로 코드를 자동으로 실행하는 서버리스 컴퓨팅 서비스입니다.

## 사전 조건 및 제한 사항
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-prereqs"></a>

**사전 조건 **
+ 활성 AWS 계정
+ Amazon Virtual Private Cloud(Amazon VPC)로 생성된 가상 프라이빗 클라우드(VPC)
+ Windows Server를 사용하는 Amazon EC2 인스턴스
+ Windows Server를 사용하여 Amazon EC2 인스턴스에 연결된 Amazon Elastic Block Store(Amazon EBS) 볼륨
+ [SQL Server Express 에디션](https://www.microsoft.com/en-us/download/details.aspx?id=101064) 바이너리

**제한 사항 **
+ SQL Server Express 에디션의 기능 제한에 대한 자세한 내용은 [Microsoft 웹 사이트](https://learn.microsoft.com/en-us/sql/sql-server/editions-and-components-of-sql-server-2019?view=sql-server-ver16)를 참조하세요.
+ 일부 AWS 서비스 는 전혀 사용할 수 없습니다 AWS 리전. 리전별 가용성은 [리전별AWS 서비스](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/)를 참조하세요. 구체적인 엔드포인트는 [서비스 엔드포인트 및 할당량](https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html)을 참조하고 서비스 링크를 선택합니다.

**제품 버전**
+ SQL Server Express 에디션을 사용하는 SQL Server 2016 이상

## 아키텍처
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-architecture"></a>

다음 다이어그램은 SQL Server Express 에디션이 설치된 상태에서 실행 중인 Amazon EC2 인스턴스를 보여줍니다. 인스턴스는 RDP(원격 데스크톱 프로토콜) 클라이언트 또는에서 액세스할 수 있습니다 AWS Systems Manager Session Manager. AWS Key Management Service (AWS KMS)는 Amazon EBS 볼륨의 데이터 암호화를 처리하여 data-at-rest 보안을 보장합니다. 인프라에는 액세스 제어를 제공하고 Lambda 함수 실행에 대한 권한을 관리하는 AWS Identity and Access Management (IAM)도 포함됩니다. Amazon Simple Storage Service(Amazon S3)에는 Lambda 함수가 저장됩니다.

![\[프라이빗 서브넷에 설치된 SQL Server Express 에디션으로 실행되는 Amazon EC2 인스턴스.\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/3af2174d-bf49-4e43-86f7-34759e5eea84/images/3a37dcb8-10af-42f2-8ff1-fab4f87eb646.png)


## 도구
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-tools"></a>

**AWS 서비스**
+ [Amazon Elastic Block Store(Amazon EBS)](https://docs.aws.amazon.com/ebs/latest/userguide/what-is-ebs.html)는 Amazon EC2 인스턴스에 사용할 수 있는 블록 스토리지 볼륨을 제공합니다.
+ [Amazon Elastic Compute Cloud(Amazon EC2)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)는 AWS 클라우드에서 확장 가능한 컴퓨팅 용량을 제공합니다. 필요한 만큼 가상 서버를 시작하고 빠르게 스케일 업하거나 스케일 다운할 수 있습니다.
+ [AWS Identity and Access Management (IAM)](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)는 AWS 리소스에 대한 액세스를 인증하고 사용할 수 있는 권한을 부여받은 사용자를 제어하여 리소스에 대한 액세스를 안전하게 관리하는 데 도움이 됩니다.
+ [AWS Key Management Service (AWS KMS)](https://docs.aws.amazon.com/kms/latest/developerguide/overview.html)를 사용하면 암호화 키를 생성하고 제어하여 데이터를 보호할 수 있습니다.
+ [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)는 서버를 프로비저닝하거나 관리할 필요 없이 코드를 실행하는 데 도움이 되는 컴퓨팅 서비스입니다. 필요할 때만 코드를 실행하며 자동으로 확장이 가능하므로 사용한 컴퓨팅 시간만큼만 비용을 지불합니다.
+ [Amazon Simple Storage Service(Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)는 원하는 양의 데이터를 저장, 보호 및 검색하는 데 도움이 되는 클라우드 기반 객체 스토리지 서비스입니다.
+ [AWS Systems Manager Session Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html)는 완전 관리형 AWS Systems Manager 도구입니다. Session Manager를 사용하여 Amazon EC2 인스턴스, 엣지 디바이스, 온프레미스 서버 및 가상 머신을 관리할 수 있습니다.
+ [Amazon Virtual Private Cloud(Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html)를 사용하면 정의한 가상 네트워크에서 AWS 리소스를 시작할 수 있습니다. 이 가상 네트워크는 AWS의 확장 가능한 인프라를 사용한다는 이점과 함께 고객의 자체 데이터 센터에서 운영하는 기존 네트워크와 유사합니다.

**기타 도구**
+ [Microsoft SQL Server Management Studio(SSMS)](https://learn.microsoft.com/en-us/ssms/download-sql-server-management-studio-ssms)는 SQL 서버 구성 요소에 대한 액세스, 구성 및 관리를 포함하여 SQL Server를 관리하기 위한 도구입니다.
+ [Python](https://www.python.org/)은 범용 컴퓨터 프로그래밍 언어입니다. 이를 사용하여 [AWS 클라우드](https://aws.amazon.com/developer/language/python/)에서 애플리케이션을 구축하고, 작업을 자동화하고, 서비스를 개발할 수 있습니다.
+ [작업 스케줄러](https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page)는 컴퓨터에서 일상적인 작업을 자동으로 예약하는 데 사용할 수 있는 Microsoft 도구입니다.

## 모범 사례
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-best-practices"></a>
+ [Amazon EC2 모범 사례](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-best-practices.html)
+ [Amazon EC2에 Microsoft SQL Server 배포를 위한 모범 사례](https://docs.aws.amazon.com/prescriptive-guidance/latest/sql-server-ec2-best-practices/welcome.html)
+ [AWS Lambda 함수 작업 모범 사례](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)
+ [IAM의 보안 모범 사례](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)

## 에픽
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-epics"></a>

### Amazon EC2 인스턴스 생성 및 SQL Server Express 에디션 설치
<a name="create-an-amazon-ec2-instance-and-install-sql-server-express-edition"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| Amazon EC2 인스턴스를 배포합니다. | Amazon EC2 인스턴스를 생성하려면 [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/)에서 Amazon EC2 콘솔을 열고 Windows Server에 사용할 수 있는 인스턴스 목록에서 [Amazon Machine Image(AMI)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html)를 선택합니다.자세한 내용은 AWS 설명서의 [ Amazon EC2 인스턴스 시작을](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/LaunchingAndUsingInstances.html) 참조하세요. | DBA, AWS DevOps | 
| SQL Server Express 에디션을 설치합니다. | SQL Server Express 에디션을 설치하려면 다음 단계를 완료합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html) | DBA, AWS DevOps | 

### 자동 데이터베이스 유지 관리 작업 생성
<a name="create-automated-database-maintenance-tasks"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 일상적인 작업을 찾습니다. | 자동화할 일상 작업을 찾습니다. 예를 들어 다음과 같은 작업이 자동화에 적합합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html) | DBA | 
| SQL 스크립트를 준비합니다. | SQL 스크립트를 준비하려면 다음을 수행합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html) | DBA | 
| 액세스 권한을 구성합니다. | 액세스 권한을 구성하려면 다음을 수행합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html) | DBA | 

### 작업 스케줄러를 사용하여 작업 자동화
<a name="automate-tasks-with-task-scheduler"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 배치 파일을 생성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html)<pre>sqlcmd -S servername -U username -P password -i <T-SQL query path.sql></pre>[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html)<pre><br />@echo off<br />sqlcmd -S [ServerName] -d [DatabaseName] -U username -P password -i "PathToSQLScript\Script.sql" -o "PathToOutput\Output.txt"</pre> | AWS DevOps, DBA | 
| 작업 스케줄러에서 작업을 생성합니다. | 작업 스케줄러에서 작업을 생성하려면 다음 단계를 따릅니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html)작업을 수동으로 실행하려면 새로 생성된 작업을 마우스 오른쪽 버튼으로 클릭한 다음 **실행**을 선택합니다. | DBA | 
| 작업 상태를 봅니다. | 작업 스케줄러에서 작업 상태를 보려면 다음 단계를 사용합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html) | DBA, AWS DevOps | 

### 를 사용하여 작업 자동화 AWS Lambda
<a name="automate-tasks-with-lamlong"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 솔루션을 구현합니다. | 이 패턴의 솔루션을 구현하려면 다음 단계를 따릅니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2.html) | AWS DevOps, DevOps 엔지니어 | 

## 문제 해결
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-troubleshooting"></a>


| 문제 | Solution | 
| --- | --- | 
| Lambda 문제 | 사용 시 발생할 수 있는 오류 및 문제에 대한 도움말은 AWS 설명서[의 Lambda 문제 해결을](https://docs.aws.amazon.com/lambda/latest/dg/lambda-troubleshooting.html) AWS Lambda참조하세요. | 

## 관련 리소스
<a name="automate-database-tasks-in-sql-server-express-edition-running-on-amazon-ec2-resources"></a>
+ [Amazon EC2 인스턴스 유형](https://aws.amazon.com/ec2/instance-types/)
+ [AWS Lambda 설명서](https://docs.aws.amazon.com/lambda/latest/dg/with-eventbridge-scheduler.html)
+ [AWS Lambda 요금](https://aws.amazon.com/lambda/pricing/)
+ [개발자용 작업 스케줄러](https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page)(Microsoft 웹 사이트)