aws rds监控慢sql
In this article, we are going to explore Analysis Service for AWS RDS SQL Server in detail.
在本文中,我们将详细探讨适用于AWS RDS SQL Server的Analysis Service。
Amazon offers various database services to support completely managed database infrastructure. We can deploy RDS for SQL Server, but it supports only database service until now. If we look at the relational database Microsoft SQL Server, it offers the following useful services as well:
Amazon提供了各种数据库服务来支持完全托管的数据库基础架构。 我们可以为SQL Server部署RDS,但是到目前为止它仅支持数据库服务。 如果我们查看关系数据库Microsoft SQL Server,它还提供以下有用的服务:
- SQL Server Analysis Service – SSAS SQL Server分析服务– SSAS
- SQL Server Reporting Service – SSRS SQL Server报告服务– SSRS
- SQL Server Integration Service – SSIS SQL Server集成服务– SSIS
But RDS limitation to database service was stopping a few users from migrating on it. Recently AWS announced that we can now run the Analysis Service on AWS RDS SQL Server as well.
但是RDS对数据库服务的限制阻止了一些用户对其进行迁移。 最近,AWS宣布我们现在也可以在AWS RDS SQL Server上运行Analysis Service 。
先决条件 (Prerequisites)
支持的版本 (Supported editions)
RDS supports SQL Server Analysis Service on the following SQL Server editions:
RDS在以下SQL Server版本上支持SQL Server Analysis Service:
- SQL Server 2016 Standard or Enterprise edition (minimum version:13.00.5426.0.v1) SQL Server 2016 Standard或Enterprise版本(最低版本:13.00.5426.0.v1)
- SQL Server 2017 Standard or Enterprise edition(minimum version:14.00.3223.3.v1) SQL Server 2017 Standard或Enterprise版本(最低版本:14.00.3223.3.v1)
Follow the article AWS RDS SQL Server – Launching a new database instance to launch a new AWS RDS SQL Server instance.
按照文章AWS RDS SQL Server –启动新的数据库实例启动新的AWS RDS SQL Server实例。
You can verify the SQL instance edition in the RDS dashboard, as shown below:
您可以在RDS仪表板中验证SQL实例版本,如下所示:
加入域的RDS实例 (Domain Joined RDS instance)
Join this RDS instance with an Amazon managed Active directory.
将此RDS实例与Amazon托管的Active Directory加入。
将EC2实例配置为域的成员 (Configure EC2 instance as a member of Domain)
Create an EC2 instance, and it should be part of the same active directory.
创建一个EC2实例,它应该是同一活动目录的一部分。
For requirement 2 and 3, follow the articles below:
对于要求2和3,请遵循以下文章:
- Initial Windows Authentication configurations in AWS RDS SQL Server AWS RDS SQL Server中的初始Windows身份验证配置
- Advanced Windows Authentication configurations in AWS RDS SQL Server AWS RDS SQL Server中的高级Windows身份验证配置
Once you follow steps 2 and 3, you can use the Windows authentication to connect to AWS RDS SQL Server:
完成步骤2和步骤3后,即可使用Windows身份验证连接到AWS RDS SQL Server:
将Amazon S3存储桶与AWS RDS SQL Server集成 (Integrate an Amazon S3 bucket with AWS RDS SQL Server)
We require an S3 bucket to transfer tabular database models, backups between the AWS instance and S3 bucket. I have already associated the SQLshackdemo bucket with my RDS instance.
我们需要一个S3存储桶来传输表格数据库模型,AWS实例和S3存储桶之间的备份。 我已经将SQLshackdemo存储桶与我的RDS实例相关联。
In the below image, we can see the sqlshackrole role associated with the RDS instance for the S3 integration feature. This role should have permissions to do tasks in the S3 bucket for RDS instance.
在下图中,我们可以看到与S3集成功能的RDS实例关联的sqlshackrole角色。 该角色应具有在R3实例的S3存储桶中执行任务的权限。
Refer to the article Integrating an AWS RDS SQL Server with Amazon S3 bucket to go through the integration process.
请参阅文章将AWS RDS SQL Server与Amazon S3存储桶集成以完成集成过程。
SSMS安装 (SSMS installation)
Launch EC2 instance and install SQL Server Management Studio to connect with RDS DB and Analysis Service instance
启动EC2实例并安装SQL Server Management Studio以与RDS DB和Analysis Service实例连接
带有SQL Server数据工具(SSDT)的Visual Studio (Visual Studio with SQL Server Data Tools (SSDT))
We require Visual Studio 2019 along with SQL Server data tools for creating database projects. You can install Visual Studio in the EC2 instance and enable the extension for the Analysis Service project.
我们需要Visual Studio 2019以及SQL Server数据工具来创建数据库项目。 您可以在EC2实例中安装Visual Studio,并为Analysis Service项目启用扩展。
Refer to the article Download SQL Server Data Tools (SSDT) for Visual Studio for more details.
有关更多详细信息,请参阅文章下载Visual StudioSQL Server数据工具(SSDT) 。
Note: Complete all prerequisites specified so far in this article to go further.
注意 :完成本文到目前为止指定的所有先决条件,以进一步进行操作。
在AWS RDS SQL Server上启用SSAS (Enable SSAS on the AWS RDS SQL Server)
SQL Server Analysis Service is an Online analytical processing (OLAP) application. In a traditional SQL Server, we get two options to choose, Tabular or Multi-dimensional. RDS supports the tabular model.
SQL Server Analysis Service是一个联机分析处理(OLAP)应用程序。 在传统SQL Server中,我们有两个选项可供选择:表格格式或多维格式。 RDS支持表格模型。
To enable the Analysis Service in RDS, we need to add an option group in the RDS instance. In the RDS dashboard, click on Options groups. You can see existing options groups as well on this page.
要在RDS中启用分析服务,我们需要在RDS实例中添加一个选项组。 在RDS仪表板中,单击“ 选项”组。 您也可以在此页面上看到现有的选项组。
Click on Create group to configure a new option group:
单击创建组以配置新的选项组:
为RDS创建一个新的选项组 (Create a new Option group for RDS)
On this Create option group page, enter the name and description. We also need to select the SQL engine (standard, enterprise, express) along with the SQL version:
在此创建选项组页面上,输入名称和描述。 我们还需要选择SQL引擎(标准,企业,快递)以及SQL版本:
It creates the option group, but it is not configured for any services yet. We need to select the newly created option group and click on Add option:
它创建了选项组,但尚未为任何服务进行配置。 我们需要选择新创建的选项组,然后单击添加选项:
在选项组中添加SQL Server Analysis Service (Add SQL Server Analysis Service in the option group)
In the option details page, select the SSAS option from the drop-down. It gives you brief information that this option enables SQL Server Analysis Services on the DB instance.
在选项详细信息页面中,从下拉列表中选择SSAS选项。 它为您提供了有关此选项在数据库实例上启用SQL Server Analysis Services的简要信息。
Analysis Service runs on port 2383, so this port should be allowed in the security groups (AWS firewall) from the EC2 instance. Refer to article security groups for your VPC for more detail.
Analysis Service在端口2383上运行,因此应在EC2实例的安全组(AWS防火墙)中允许该端口。 有关更多详细信息,请参阅VPC的文章安全组 。
We also need to configure the Max memory for the Analysis Service. You might be aware that Analysis Service is a memory-intensive application, and you might do bulk data processing, so max memory should be configured appropriately. Analysis Service instance runs on the same RDS database, so if we specify a high memory, it might impact memory available for RDS instance. I allocated 50% memory for the SSAS instance.
我们还需要为Analysis Service配置最大内存 。 您可能知道Analysis Service是一个占用大量内存的应用程序,并且可能会进行批量数据处理,因此应适当配置最大内存。 Analysis Service实例在同一RDS数据库上运行,因此,如果我们指定高内存,则可能会影响RDS实例的可用内存。 我为SSAS实例分配了50%的内存。
The RDS instance and options group must remain in the same VPC. You can verify the RDS instance VPC in the connectivity & Security tab:
RDS实例和选项组必须保留在同一VPC中。 您可以在“ 连接性和安全性”选项卡中验证RDS实例VPC:
Select the RDS instance VPC (in my case vpc-9c710fe6) in the security groups as shown below:
在安全组中选择RDS实例VPC(在我的情况下为vpc-9c710fe6 ),如下所示:
Scroll down, and you can schedule to add the option group immediately or on next scheduled maintenance window:
向下滚动,您可以计划立即或在下一个计划的维护窗口中添加选项组:
It adds the SSAS in the newly created option group, and you get a message for it as well:
它将SSAS添加到新创建的选项组中,并且您也收到一条消息:
修改RDS实例以使用SSAS选项组 (Modify RDS instance to use SSAS option group)
Now, lunch SSMS in EC2 instance and try to connect the Analysis Services using the RDS endpoint. We get the error message that connection did not succeed:
现在,在EC2实例中午餐SSMS,然后尝试使用RDS端点连接Analysis Services。 我们收到错误消息,连接未成功:
The above error comes because we have not assigned an option group for the RDS instance. Click on modify on RDS instance and select the option group (in my case SSASforRDS) we created earlier:
出现上述错误是因为我们尚未为RDS实例分配选项组。 单击修改RDS实例,然后选择我们之前创建的选项组(在我的情况下为SSASforRDS ):
We can view the modification summary for the option group in the below image. Apply the changes immediately. It restarts the RDS instances and enables Analysis Services for the selected SQL instance:
我们可以在下图中查看选项组的修改摘要。 立即应用更改。 它将重新启动RDS实例并为所选SQL实例启用Analysis Services:
Now, connect to SSAS service again from the EC2 SSMS using Windows authentication. We do not see any database in this instance by default:
现在,使用Windows身份验证从EC2 SSMS重新连接到SSAS服务。 默认情况下,我们在此实例中看不到任何数据库:
Right-click on the connected instance and view the properties of the Analysis Server. You can see its hostname, Server mode, version, and supported compatibility level:
右键单击连接的实例,然后查看Analysis Server的属性。 您可以查看其主机名,服务器模式,版本和支持的兼容性级别:
为RDS创建Analysis Service表格项目 (Create an Analysis Service tabular project for RDS )
We will create a sample project for this demonstration. We already installed Visual Studio for creating projects. Go to start and launch Visual Studio 2019 and create a new project for Analysis Service tabular database:
我们将为此演示创建一个示例项目。 我们已经安装了Visual Studio来创建项目。 转到启动并启动Visual Studio 2019并为Analysis Service表格数据库创建一个新项目:
Specify a project name, solution name, and the directory that holds all the required project files:
指定项目名称,解决方案名称以及包含所有必需项目文件的目录:
Click on Create. In the next tabular model designer, select the option Integrated workspace:
单击创建。 在下一个表格模型设计器中,选择选项集成工作区 :
It creates a solution and project. Right-click on the project solution and view its properties. In the processing option, select the value Do Not Process:
它创建一个解决方案和项目。 右键单击项目解决方案,然后查看其属性。 在处理选项中,选择值不处理 :
You can also view the database name TestProject in the below screenshot. We require this database name in the following SQL queries:
您还可以在下面的屏幕快照中查看数据库名称TestProject 。 在以下SQL查询中,我们需要此数据库名称:
In the Visual Studio, go to Build > Build Solution:
在Visual Studio中,转到“ 构建”>“构建解决方案”:
Now, go to the directory that we specified earlier while creating the project. Here, we see the project solution file and a folder holding project files:
现在,转到我们在创建项目时指定的目录。 在这里,我们看到了项目解决方案文件和一个保存项目文件的文件夹:
Open the folder, and you can see two files highlighted below:
打开文件夹,您将看到下面突出显示的两个文件:
- Model.asdatabase模型数据库
- Model.deploymentoptions模型部署选项
Open the S3 bucket that is integrated with AWS RDS SQL Server and upload the files into S3:
打开与AWS RDS SQL Server集成的S3存储桶,并将文件上传到S3:
We use the msdb.dbo.rds_download_from_s3 stored procedure to download the project files from the S3 bucket to the RDS instance. Connect to the AWS RDS SQL instance in the SSMS and execute the following queries. In these queries, we specified the project file name that we uploaded in the S3 bucket:
我们使用msdb.dbo.rds_download_from_s3存储过程将项目文件从S3存储桶下载到RDS实例。 连接到SSMS中的AWS RDS SQL实例,然后执行以下查询。 在这些查询中,我们指定了我们在S3存储桶中上传的项目文件名:
exec msdb.dbo.rds_download_from_s3 @s3_arn_of_file='arn:aws:s3:::sqlshackdemo/Model.asdatabase' , @rds_file_path='d:\S3\model.asdatabase' , @overwrite_file=1
exec msdb.dbo.rds_download_from_s3 @s3_arn_of_file='arn:aws:s3:::sqlshackdemo/Model.deploymentoptions' , @rds_file_path='d:\S3\model.deploymentoptions' , @overwrite_file=1
It starts the tasks to download the files from the S3 bucket to the RDS instance folder:
它开始执行将文件从S3存储桶下载到RDS实例文件夹的任务:
We can check the status of the tasks using the stored procedure msdb.dbo.rds_fn_task_status using the task ID we got earlier. The first parameter is always a NULL value:
我们可以使用存储过程msdb.dbo.rds_fn_task_status和我们之前获得的任务ID来检查任务的状态。 第一个参数始终为NULL值:
SELECT * FROM msdb.dbo.rds_fn_task_status(null,19);
SELECT * FROM msdb.dbo.rds_fn_task_status(null,20);
We can see that both tasks completed successfully:
我们可以看到两个任务都成功完成了:
Now, we are ready to deploy the tabular project in the RDS instance. It uses the msdb.dbo.rds_msbi_task stored procedure with the following arguments:
现在,我们准备在RDS实例中部署表格项目。 它使用msdb.dbo.rds_msbi_task存储过程以及以下参数:
- @task_type:@task_type :
- @file_path: @file_path :D:\S3 D:\ S3
exec msdb.dbo.rds_msbi_task @task_type='SSAS_DEPLOY_PROJECT', @file_path='d:\S3\Model.asdatabase';
It also starts a task for the RDS instance. Once we track it using the msdb.dbo.rds_fn_task_status, its status shows success after some time. It might take longer, depending on the project:
它还为RDS实例启动任务。 一旦使用msdb.dbo.rds_fn_task_status对其进行跟踪,一段时间后它的状态就会显示成功。 可能需要更长的时间,具体取决于项目:
We also need to give permissions to the user that connects with the AWS RDS SQL Server Analysis Service. To do so, we use the stored procedure msdb.dbo.rds_msbi_task with the following arguments:
我们还需要向与AWS RDS SQL Server Analysis Service连接的用户授予权限。 为此,我们将存储过程msdb.dbo.rds_msbi_task与以下参数一起使用:
- @task_type:@task_type :SSAS_ADD_DB_ADMIN_MEMBER in this argument SSAS_ADD_DB_ADMIN_MEMBER
- @Database_name:@Database_name :
- @ssas_role_name@ssas_role_name
- @ssas_role_member@ssas_role_member
exec msdb.dbo.rds_msbi_task @task_type='SSAS_ADD_DB_ADMIN_MEMBER',
@database_name='Testproject', @ssas_role_name='Sample', @ssas_role_member='sqlshackdemo\rajendra.gupta';
We can see this stored procedure successfully added specified user in the specified role:
我们可以看到此存储过程已成功以指定角色添加了指定用户:
Now, refresh the Analysis Server connection in SSMS. We can see the TestProject database in the Analysis Service of AWS RDS SQL Server:
现在,刷新SSMS中的Analysis Server连接。 我们可以在AWS RDS SQL Server的Analysis Service中看到TestProject数据库:
结论 (Conclusion)
In this article, we explored that AWS RDS now supports SQL Server Analysis Service as well. We can configure it for RDS instance and deploy projects using Visual Studio, and RDS stored procedures. We deployed a primary tabular database in this demonstration.
在本文中,我们探讨了AWS RDS现在也支持SQL Server Analysis Service。 我们可以为RDS实例配置它,并使用Visual Studio和RDS存储过程部署项目。 在此演示中,我们部署了一个主要的表格数据库。
Follow the article Creating your first SSAS tabular model database to create a tabular model database in RDS.
请按照文章创建第一个SSAS表格模型数据库来在RDS中创建表格模型数据库。
翻译自: https://www.sqlshack.com/deploy-tabular-databases-in-ssas-on-aws-rds-sql-server/
aws rds监控慢sql