YourSQLDba版本升级总结
在使用YourSQLDba做数据库备份、维护时,像其它软件一样,版本升级是不可避免的。因为YourSQLDba一直在不停更新版本、扩展功能。下面介绍一下升级YourSQLDba时的具体步骤和一些注意事项。下面案例,YourSQLDba原版本为YourSQLDba version: 5.0.2 2012-06-12,升级到YourSQLDba 6.2.5.1。
步骤1: 首先查看服务器对应YourSQLDba的版本信息。因为不同版本的升级可能有所区别。要做的工作可能不一样。
Exec YourSQLDba.Install.PrintVersionInfo
========================================
YourSQLDba version: 5.0.2 2012-06-12
========================================
步骤2:查看YourSQLDba下的所有作业信息。
这个步骤,主要是因为我们在不同程度的扩展了YourSQLDba的一些功能。另外,有可能你对YourSQLDba_FullBackups_And_Maintenance等作业做了一些修改、变更。所以在升级前对变跟的地方有所了解,记录整理,方便升级后做出对应的修改。 如果你没有对YourSQLDba做任何修改、扩展,那么可以忽略这个步骤。
使用下面SQL将所有YourSQLDba的作业列出来,然后收集、整理是否有做变跟。是否需要在升级后,做出对应的调整、修改。
SELECT j.job_id AS JOB_ID
,j.name AS JOB_NAME
,CASE WHEN [enabled] =1 THEN 'Enabled'
ELSE 'Disabled' END AS JOB_ENABLED
,j.category_id AS JOB_CATEGORY_ID
,c.name AS JOB_CATEGORY_NAME
,[description] AS JOB_DESCRIPTION
,date_created AS DATE_CREATED
,date_modified AS DATE_MODIFIED
FROM msdb.dbo.sysjobs j
INNER JOIN msdb.dbo.syscategories c ON j.category_id = c.category_id
WHERE job_id IN( SELECT job_id
FROM msdb.dbo.sysjobsteps
WHERE database_name = 'YourSQLDba' )
ORDER BY j.name
步骤3:执行YourSQLDba脚本,如果你没有做任何扩展。那么直接执行脚本即可,不需要修改任何脚本。
如果你研究过了脚本,那么你们会发现,YourSQLDba是会保留原来的数据的,在代码里面,你会看到在删除YourSQLDba数据库之前,脚本会将先前YourSQLDba的数据保存到临时表。
If databasepropertyEx('YourSQLDba','status') IS NOT NULL -- db is there
Begin
-- save data about some YourSqlDba tables
If object_id('tempdb..##JobHistory') is not null Drop table ##JobHistory;
If object_id('tempdb..##JobLastBkpLocations') is not null Drop table ##JobLastBkpLocations;
If object_id('tempdb..##JobSeqCheckDb') is not null Drop table ##JobSeqCheckDb;
If object_id('tempdb..##TargetServer') is not null Drop table ##TargetServer;
If object_id('tempdb..##JobSeqUpdStat') is not null Drop table ##JobSeqUpdStat;
If object_id('tempdb..##NetworkDrivesToSetOnStartup') is not null Drop table ##NetworkDrivesToSetOnStartup;
-- If table exists in previous version save its content
If Object_id('YourSqlDba.Maint.JobHistory') IS NOT NULL
Select * Into ##JobHistory From YourSqlDba.Maint.JobHistory
If Object_id('YourSqlDba.Maint.JobLastBkpLocations') IS NOT NULL
Select * Into ##JobLastBkpLocations From YourSqlDba.Maint.JobLastBkpLocations
If Object_id('YourSqlDba.Mirroring.TargetServer') IS NOT NULL
Select * Into ##TargetServer From YourSqlDba.Mirroring.TargetServer
If Object_id('YourSqlDba.Maint.JobSeqUpdStat') IS NOT NULL
Select * Into ##JobSeqUpdStat From YourSqlDba.Maint.JobSeqUpdStat
If Object_id('YourSqlDba.Maint.JobSeqCheckDb') IS NOT NULL
Select * Into ##JobSeqCheckDb From YourSqlDba.Maint.JobSeqCheckDb
If Object_id('YourSqlDba.Maint.NetworkDrivesToSetOnStartup') Is NOT NULL
Select * Into ##NetworkDrivesToSetOnStartup From YourSqlDba.Maint.NetworkDrivesToSetOnStartup
然后在YourSQLDba创建成功后,将数据导入到新建的表后,删除临时表。部分脚本如下所示:
-- if the table doesn't exists create the latest version
If object_id('Maint.JobSeqCheckDb') is null
Begin
Declare @sql nvarchar(max)
Set @sql =
'
Create table Maint.JobSeqCheckDb
(
seq int
)
Insert into Maint.JobSeqCheckDb values(0)
'
Exec (@sql)
If Object_Id('tempdb..##JobSeqCheckDb') IS NOT NULL
Exec
(
'
Insert Into Maint.JobSeqCheckDb (seq)
Select Seq
From ##JobSeqCheckDb
Drop table ##JobSeqCheckDb
'
)
End
GO
如果你做过扩展,例如我按天、周、月监控数据库的增长情况,那么我要在YourSQLDba升级过程中保留这些历史数据,那么就必须修改这部分脚本(这些涉及太多脚本,不宜在此贴过多脚本,在此不做过多探讨)。YourSQLDba脚本升级成功后,会有下面提示信息
步骤4:更新YourSQLDba_FullBackups_And_Maintenance和YourSQLDba_LogBackups作业。
首先,在YourSQLDba升级过程中,脚本并不会更新这两个作业。在前面的几个版本中,都不需要重新新作业YourSQLDba_FullBackups_And_Maintenance等,因为即使版本不一样,但是作业功能基本是一致的。但是像这样两个版本差别大的时候, 作业里面执行的存储过程的参数都不一样了。例如5.0.2,里面全备的执行的存储过程为
exec Maint.YourSqlDba_DoMaint
@oper = 'YourSQLDba_Operator'
, @MaintJobName = 'YourSQLDba: DoInteg,DoUpdateStats,DoReorg,Full backups'
, @DoInteg = 1
, @DoUpdStats = 1
, @DoReorg = 1
, @DoBackup = 'F'
, @FullBackupPath = 'M:\DB_BACKUP\FULL_BACKUP\'
, @LogBackupPath = 'M:\DB_BACKUP\LOG_BACKUP\'
-- Flush database backups older than the number of days
, @FullBkpRetDays = 1
-- Flush log backups older than the number of days
, @LogBkpRetDays = 2
-- Spread Update Stats over 7 days
, @SpreadUpdStatRun =1
-- Maximum number of consecutive days of failed full backups allowed
-- for a database before putting that database (Offline).
, @ConsecutiveDaysOfFailedBackupsToPutDbOffline = 9999
-- Each database inclusion filter must be on its own line between the following quote pair
, @IncDb =
'
'
-- Each database exclusion filter must be on its own line between the following quote pair
, @ExcDb =
'
'
-- Each database exclusion filter must be on its own line between the following quote pair
, @ExcDbFromPolicy_CheckFullRecoveryModel =
'
'
但是6.2.5.1里面,执行的存储过程如下所示,多了参数 @SpreadCheckDb,参数@ConsecutiveDaysOfFailedBackupsToPutDbOffline名字变了,如果不做修改,那么作业就会报错。
exec Maint.YourSqlDba_DoMaint
@oper = 'YourSQLDba_Operator'
, @MaintJobName = 'YourSQLDba: DoInteg,DoUpdateStats,DoReorg,Full backups'
, @DoInteg = 1
, @DoUpdStats = 1
, @DoReorg = 1
, @DoBackup = 'F'
, @FullBackupPath = 'M:\DB_BACKUP\FULL_BACKUP\'
, @LogBackupPath = 'M:\DB_BACKUP\LOG_BACKUP\'
-- Flush database backups older than the number of days
, @FullBkpRetDays = 1
-- Flush log backups older than the number of days
, @LogBkpRetDays =2
-- Spread Update Stats over 7 days
, @SpreadUpdStatRun = 1
-- Spread Check DB without 'PHYSICAL_ONLY' over 7 days
, @SpreadCheckDb = 7
-- Maximum number of consecutive days of failed full backups allowed
-- for a database before putting that database (Offline).
, @ConsecutiveDaysOfFailedBackupsToPutDbOffline = 0
-- Each database inclusion filter must be on its own line between the following quote pair
, @IncDb =
'
'
-- Each database exclusion filter must be on its own line between the following quote pair
, @ExcDb =
'
'
-- Each database exclusion filter must be on its own line between the following quote pair
, @ExcDbFromPolicy_CheckFullRecoveryModel =
'
'
而升级脚本并不会重建或更新作业,所以我们执行初始化脚本YourSQLDba.[Install].[InitialSetupOfYourSqlDba]更新作业。注意,执行该脚本后,你原来的配置参数都会使用初始化参数,例如(@FullBkpRetDays,@LogBkpRetDays…..等),另外,像YourSQLDba_LogBackups作业的Schedule变为15分钟做一次事务日志备份,在执行脚本前,最好记录原来的参数,以免影响原来的备份策略。
EXEC YourSQLDba.[Install].[InitialSetupOfYourSqlDba]
@FullBackupPath = 'M:\DB_BACKUP\FULL_BACKUP\' -- full backup path destination
,@LogBackupPath = 'M:\DB_BACKUP\LOG_BACKUP\' -- log backup path destination
,@email = 'xxx@xxxx.com' -- Email recipients (or distribution list)
,@SmtpMailServer = 'xxx.xxx.xxx.xxx' -- Mail server that accept SMTP mail
,@ConsecutiveDaysOfFailedBackupsToPutDbOffline = 9999
另外,如果我们扩展了YourSQLdba的脚本,此时就必须添加相应存储过程,作业倒不必新建(因为YourSQLDba升级不会删除作业,但是由于YourSQLDba数据库重建了,所以作业里面调用的存储过程可能没有了)。
YourSQLDba版本升级总结的更多相关文章
- SQL Sever 博客文章目录(2016-07-06更新)
SQL Server方面的博客文章也陆陆续续的写了不少了,顺便也将这些知识点整理.归纳一下下.方便自己和他人查看. MS SQL 数据类型 三大数据库对比研究系列--数据类型 MS SQL 表和视图 ...
- Oracle安装部署,版本升级,应用补丁快速参考
一.Oracle安装部署 1.1 单机环境 1.2 Oracle RAC环境 1.3 Oracle DataGuard环境 1.4 主机双机 1.5 客户端部署 二.Oracle版本升级 2.1 单机 ...
- 使用SQLiteOpenHelper的onUpgrade实现数据库版本升级
Andoird的SQLiteOpenHelper类中有一个onUpgrade方法.帮助文档中只是说当数据库升级时该方法被触发.经过实践,解决了我一连串的疑问: 1. 帮助文档里说的"数据库升 ...
- YourSQLDba 配置——修改备份路径
公司一直使用YourSQLDba做本地备份,磁带机将本地备份文件上带做异地容灾备份.近期整理.验证备份时发现本地备份目录命名五花八门 其中有历史原因,也有无规划化的缘故,看着这些五花八门的目录,越看越 ...
- YourSQLDba将数据库置于紧急模式的原因浅析
从SQL SERVER 2000 上迁移了一个数据库到SQL SERVER 2008 R2上,暂且用DataBaseName代替迁移的真实的数据库名(后面的资料也会将数据库真实的名字用DataBase ...
- 杀毒软件导致YourSQLDba备份失败
有一朋友咨询我,他配置的YourSQLDba 备份作业经常出现备份失败的情况,我帮忙查看了一下,首先从告警邮件中查看出错的具体信息,执行了下面SQL语句(来自于告警邮件) Exec YourSQLDb ...
- YourSQLDba开源项目发布到codeplex网站了
今天登录YourSQLDba的官方网站http://yoursqldba.grics.ca/index_en.shtml,发现YourSQLDba项目已经发布到开源网站http://www.codep ...
- YourSQLDba备份失败案例锦集
使用YourSQLDba做备份.维护.管理时,偶尔会收到一些备份失败的邮件.导致YourSQLDba备份失败的情况比价多,打算在此篇中对YourSQLDba备份失败的案例做一些总结.整理. 1:You ...
- YourSQLDba设置共享路径备份
YourSQLDba可以将数据库备份到网络路径(共享路径),这个也是非常灵活的一个功能,以前一直没有使用过这个功能,最近由于一个需求,于是我测试了一下YourSQLDba备份到网络路径,中间遇到了一些 ...
随机推荐
- MongoDB的CRUD操作
1. 前言 在上一篇文章中,我们介绍了MongoDB.现在,我们来看下如何在MongoDB中进行常规的CRUD操作.毕竟,作为一个存储系统,它的基本功能就是对数据进行增删改查操作. MongoDB中的 ...
- JS魔法堂:Data URI Scheme介绍
一.前言 上周五公司内部的Any Topic Conf.上我和同事们分享了这个主题,有同事说这个有用,有同事说这个没啥用,后来还延伸到网站性能的话题上,大家讨论的激烈程度让我觉得这次选题还不错.本篇先 ...
- Cesium原理篇:6 Render模块(6: Instance实例化)
最近研究Cesium的实例化,尽管该技术需要在WebGL2.0,也就是OpenGL ES3.0才支持.调试源码的时候眼前一亮,发现VAO和glDrawBuffers都不是WebGL1.0的标准函数,都 ...
- Fragment基础----创建
1,Fragment的目的及应用场景 fragment 是3.0后引入的类,其字面翻译为“碎片”. 目的是将activity划分成许多单元再进行组合,可以根据不同分辨率屏幕,在不同状态下,灵活创建优化 ...
- Sql Server函数全解(四)日期和时间函数
日期和时间函数主要用来处理日期和时间值,本篇主要介绍各种日期和时间函数的功能和用法,一般的日期函数除了使用date类型的参数外,也可以使用datetime类型的参数,但会忽略这些值的时间部分.相同 ...
- [Q&A] MySQL Error 1050(42S01): Table already exist
[环境说明] 1:MySQL Server 5.5 2:MyEclipse 2014 3:JDK 1.7 造成该问题的可能原因: 1:用 Java 读取 SQL 文件,并执行其中的 sql 语句,但是 ...
- 【C#公共帮助类】分页逻辑处理类
分页逻辑处理类 PageCollection.cs using System; using System.Collections.Generic; using System.Linq; using S ...
- Artificial intelligence(AI)
ORM: https://github.com/sunkaixuan/SqlSugar 微软DEMO: https://github.com/Microsoft/BotBuilder 注册KEY:ht ...
- android raw和assets的区别
*res/raw和assets的相同点: 1.两者目录下的文件在打包后会原封不动的保存在apk包中,不会被编译成二进制. *res/raw和assets的不同点: 1**.res/raw中的文件会被映 ...
- JavaScript类属性
对象的类属性(class attribute)是一个字符串,用以表示对象的类型信息.ECMAScript3和ECMAScript5都未提供设置这个属性的方法,并只有一个间接的方法可以查询它.默认的to ...


