Download Database Maintenance

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

SQL wikipedia , lookup

IMDb wikipedia , lookup

Oracle Database wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Ingres (database) wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Concurrency control wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Database wikipedia , lookup

Relational model wikipedia , lookup

ContactPoint wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
EMG
Victoria, BC, Canada
Metering & Control
330 people
Grenoble, France
Electropole and M4 sites
Protection Relays
Entry-Range Metering
175 people
Lavergne, Tennessee, USA
Metering & Control
170 people
Hong Kong, China
Metering & Control
SMS 4.2- Database maintenance
Global EMG Application Expertise Team
Release date:
11/2009
Version:
1.0
Schneider Electric Industries SAS
Written by:
Madleen Laclef
Business Unit Power
Application note
Checked by :
Approved by:
EMG
Summary
1. PURPOSE OF THIS DOCUMENT .............................................................................................. 3
2. SMSPE 4.2 DATABASES..................................................................................................... 4
2.1 What has changed since SMSPE 4.0 .....................................................................................................4
2.2 Database structure ..................................................................................................................................4
3. DEFAULT TASKS FOR DATABASE MAINTENANCE IN SMS ........................................................ 6
4. SMS DATABASE SERVICES ................................................................................................. 9
5. ADVANCED REPORTS DATABASE MAINTENANCE ................................................................. 10
5.1 What is Advanced Reports Database Maintenance? .........................................................................10
5.2 Data Management table ........................................................................................................................10
5.3 Import Data ............................................................................................................................................12
5.4 Data retention table ...............................................................................................................................13
5.5 Backup Data table .................................................................................................................................15
6. ATTACH, DETACH, RESTORE DATABASES WITH
POWERLOGIC.DATABASE.RPTSTGDBMAINTSERVICE.UI.EXE ................................................. 17
6.1 How to activate PowerLogic.Database.RptStgDBMaintService.UI.exe ...........................................17
6.2 Using PowerLogic.Database.RptStgDBMaintService.UI.exe ............................................................18
7. DBTOOL .......................................................................................................................... 19
7.1 Temp Settings........................................................................................................................................20
7.2 Detach database ....................................................................................................................................20
7.3 Attaching database ...............................................................................................................................20
7.4 Restoring a backup ...............................................................................................................................22
7.5 Performing a back up............................................................................................................................23
7.6 Viewing tables .......................................................................................................................................23
7.7 Running Scripts.....................................................................................................................................24
7.8 Disconnection from DBTool .................................................................................................................24
2
1. Purpose of this document
The purpose of this document is to explain the different mechanisms of databases in SMS version 4.2.
We will see that changes occurred between SMS 4.0 and SMS 4.2.
We will focus on the maintenance of databases. As well the process for archive and backup will be developed.
Various tools to deal with SMS 4.2 databases will be presented.
3
2. SMSPE 4.2 databases
2.1 What has changed since SMSPE 4.0
SMSPE v4.2 has changed from SQL Server 2000 to SQL Server 2005. We will see that this change has
affected the structure of the databases.
As well, Enterprise Manager is now replaced by Management Studio. It can be found under the following
directory: "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe“
If you want to learn more about this new tool, there is a tutorial under:
Start>Programs>Microsoft SQL Server 2005>Documentation and Tutorials>Tutorials>SQL Server Tutorials
Select SQL Server Tools Select SQL Server Management Studio Tutorial
Below is a list of some of the changes between these two versions.

During SQL 2005 installation, the user will now see progress screens: this was done to show progress is
being done.

SQL Passwords are now case sensitive. You must enter the password with the exact case as it was
entered when the account was created. This is a change from SQL 2000 where the passwords are not case
pensive.

There is a new instance name in SQL Server: it is now “PowerLogic”.
 There is a new system administrative account called SMS_SysAdmin in v4.2.
This account was introduced in Advanced Reports; it has the same rights as the “sa” account, but not the same
status. It is used to archive history, create backups, and delete archived history files.
As well, Crystal Enterprise 10 (CE10) uses SMS_SysAdmin instead of the “sa” account to connect to the database.
2.2 Database structure
This section lists the databases of SMS4.2PE.

SMS_SYSTEM
This is the main database that contains all system setup information such as device type information, system
configuration and driver setup, alarm configuration, logging configuration, task configuration and schedules…
It also contains the SMS Activity Log in CS_EVENT_LOG and the SMS Alarm Log in CS_ALARM_HISTORY.
This database will not grow over time except for the previous two tables mentioned. However, by default SMS is
setup to FIFO these two tables.

SMS_HISTORY
This is the basic SMS logging database used by Information Manager to create reports.

SMS_AR_Report
This is the main database of historical data that is used for the reports in Advanced Reports.
It contains historical data that has been pre-processed from the data in SMS_AR_STAGING to give fast
performance when generating reports.
Historical data is organized into a collection of tables by topic groups.
4
Automatic archiving of the data in this database is based upon the topics groups. Below we will see that a user
may want to keep currents/voltages for reports over 3 months, while energies would be kept over a year for a yearby-year comparison report.
We will also see that this default archiving can be modified with the AR Database Management (ARDM) Utility if
desired.

SMS_AR_Staging
This database contains raw historical data from SMS and any other data sources. It is a staging area to prepare
data for reports. This data is pre-processed and then loaded into SMS_AR_REPORT for report generation.

CE10
This database contains information about the reports themselves.
5
3. Default tasks for database maintenance in SMS
Due to the changes between SQL2000 and SQL2005, the following tasks have been added into SMS.
SMS uses these four scheduled tasks to manage the system’s historical data.
Each time you add a system to SMS; these tasks are added to the new system. When you change one of
these tasks for any system, the change is also applied to all of the other systems.




Archive historical data
Backups of system and history databases
Daily maintenance on Advanced Reports database
Delete historical data that has been archived
The above tasks can only be modified through Database Services, even though they will appear in the SMS
scheduled tasks list.
You cannot edit these tasks using SMS, they appear greyed out.
You can execute them manually if needed.
6
If you wish to change them, you must use new tools for database maintenance that will be detailed below.
These tasks in SMS will launch an .exe file called PLJobManager.
 Archive SMS Data: performs a daily archive of SMS historical data.
This job runs once a day, by default at 3:05am. This is a complex job with many steps that include backing up some
records in an archive and then marking them for deletion. This job will use the Advanced Reports Database
Management (ARDM) tool, which will be described later in this document. The scheduled interval cannot be
changed.
Data is archived based on a user selected retention period.
 The Delete Job
In SMS 4.2, the delete job is a scheduled task that, by default, runs every 5 minutes. After data is archived, it
deletes the corresponding data from historical database.
 The Daily Data Maintenance job
This job runs once a day, by default at 11:30pm. It updates statistics in SMS_AR_Reports and SMS_AR_Staging, to
update the Advanced Reports database tables.
7

Back up SMS data job
This job will not appear until you schedule a backup.
8
4. SMS Database Services
This tool can be reached through the menu:
Setup > Administrative> Data base services>SMS database services.
It is through this tool that we used to backup the databases and set the archiving period.
With Advanced Reports, this tool will no longer be used.
If you try to change the parameters here, you will notice when you reopen this window that your changes will not be
saved.
9
5. Advanced Reports Database Maintenance
This tool can be reached through the menu:
Setup > Administrative> AR> Database maintenance
5.1 What is Advanced Reports Database Maintenance?
You will use the Advanced Reports Database Maintenance tool to configure and maintain the Advanced Reports
database. There are default values assigned to each of the topics below, so you will not need to use this utility
unless you want to make changes to the default ways that SMS retains and archives data.
Using the four screens of this utility, you can:
--export historical data to an archive folder or permanently delete historical data (Data Management tab)
--import archived data back into the SMS database (Import Data tab)
--change retention periods for new and archived data (Data Retention tab)
--make backup copies of any of the various databases (Backup Data tab)
Note: Click on Help button in Advanced Reports Database Management window to see the help content about this
tool (there is a different help content than the one in SMS Setup help).
5.2 Data Management table
Here you can see a list with all the tables from Advanced reports.
Use the Data Management table to export and delete historical data from SMS.
- To export the content of a table to the archive (PowerLogic > AdvancedReports > Archive), highlight the table
name, and then click Export.
- To delete the content of a table, highlight the table name, and then click Delete. A prompt displays asking if you
are sure that you want to delete the selected data.
10
Note on the historical data tables:
These are the tables in the database SMS_AR_Report that store historical data:
HST_SuspectData
HST_RejectedSamples
HST_CustomQty
HST_Unassigned
HST_Currents
HST_Voltages
HST_Powers
HST_DemandReadingsHistory
HST_Energies
HST_PowerFactors
HST_PowerQualityReadings
HST_UnbalanceReadings
HST_FundamentalPhasors
HST_MinimumReadings
HST_MaximumReadings
HST_Miscellaneous
HST_Ratings
HST_DemandVoltagesHistory
HST_SpectralComponents
HST_LVBreakerTripUnitStatus
HST_100ms
HST_CycleByCycle
HST_Trending
HST_InputMetering
HST_EN50160
HST_WAGESWater
HST_WAGESAir
HST_WAGESGas
HST_WAGESSteam
HST_WAGESWeather
Historical data in SMS Advanced Reports is spread across this list of HST_xxx tables. Previous versions of
SMS stored historical data in one table.
For AR it was decided to spread this data out because the individual tables remain smaller than if they were
all together, and thus queries on them are faster. Also, since the data is segregated by topic group, it is possible to
apply different retention periods to different types of data when archiving and performing maintenance on the
database.
11
5.3 Import Data
Use the Import Data tab to import data that has been archived into Powerlogic > Advanced Reports >
Archive.
Browse to select the location of the data that you want to restore (import) from archive. By default, this
opens to Powerlogic>Advanced Reports> Archive. If the archived data has been moved to another location, browse
to that location. You can only import one file at a time.
Once you hit Import you get the following message:
The DEL for Import Status will turn Green for a moment, while archived data is being imported. After the
import is complete, it is red again and you should see this message:
Note that to access history data from previous SMS versions; you must use the SMS History Import Utility.
12
5.4 Data retention table
Historical data is stored in separate data groups.
Use the Data Retention tab to change the default retention times for any of these groups.
Data table that is
related to the
data group
selected above
Enter the number of months that you want to
retain logged data. This can include data that
is imported from an earlier version of SMS,
as well as data that is logged after Advanced
Reports was installed.
Enter the number of months that you want
to retain data that has been imported from
the archive (Powerlogic >Advanced
Reports> Archive).
At the end of this period, data is
automatically re-archived.
13
Default Retention Times
Data Group
Logged Data retention
(months)
Archived Data retention
(months)
100ms
Currents
Cycle-by-Cycle
Demand Readings and History
Demand Voltages and History
Energies
Input Metering
Maximum Readings
Minimum Readings
Miscellaneous
Power Factors
Power Quality Readings
Powers
Unbalance Readings
Voltages
WAGES (water, air, gas,
electric, or steam)
EN50160
3
3
3
14
14
36
14
3
3
3
3
3
3
3
3
14
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
Note:
Data in the database is treated as a single unit for each month. Data is archived out of the database once a month,
at the end of the month. Thus, data for the earlier days of the month is retained for a longer time than is the data for
the last day of the month
The archive files are stored in Archive folder as below. There is one .tab file for each table and for each month.
Note: How to set a different archive folder
Follow the steps below. Warning: incorrect usage of registry may damage SMS.
- Stop the PowerLogic.Database.RptStgDBMaint Service
- Open the registry by typing regedit in the command prompt.
- In the Registry, go under Square D Company\Advanced Reports\Report Database\Archive\
- Here change "ArchiveLocation". Be sure to include a slash at the end.
- Restart the service.
14
5.5 Backup Data table
Use the Backup Data table to back up any of the listed databases. You can change the location of default
backup directory.
Backup of SMS_history database is disabled if Information Manager has never been enabled on the
system.
Browse to select the directory in which
you want to create the backup files.
Check the databases to include in the backup
15
In the destination folder, you find one .bak file for each database and one log file for each database.
16
6. Attach, detach, restore databases with
PowerLogic.Database.RptStgDBMaintService.UI.exe
6.1 How to activate PowerLogic.Database.RptStgDBMaintService.UI.exe
PowerLogic.Database.RptStgDBMaintService.UI.exe is not activated by default. There is a change to do in the
registry to use it. Follow the steps below.
- Stop PLServiceManager and PowerLogic Network Server
- Open the registry by typing regedit in the command prompt
- Go to HKEY_LOCAL_MACHINE\Software\Square D Company\Advanced Reports\Report Database
- Add a DWORD called ShowAdvancedOptions with a value of 1.
- Restart PLServiceManager and PowerLogic Network Server
Now that when you have activated the tool, you can run it by opening the folder:
\PowerLogic\AdvancedReports\Bin\PowerLogic.Database.RptStgDBMaintService.UI.exe
Enter sa Password.
By default, it is :
DBMaster
17
6.2 Using PowerLogic.Database.RptStgDBMaintService.UI.exe

Detaching databases
If you hit Detach button, the following message will appear telling you that connections with SQL need to be closed.
Hit
Yes
You can do the same for each database. Note that the database location is:
C:\MSSQL2005\MSSQL.1\MSSQL\Data\

Restoring backup
To be able to use the Restore button, you need to set the Backup Location before detaching the previous database.
If you want to restore a backup follow the steps below:
1. Open PowerLogic.Database.RptStgDBMaintService.UI.exe
2. Enter sa password
3. Under Backup Location, browse to the folder where your backup is located
4. Detach the previous database following the steps above
Note that the Restore
button is no longer greyed
out.
This is because backup
location has been defined
in step 3.
5. Hit Restore and make sure that the backup is successfully restored.

Attaching database
Once the previous database has been detached; you need to browse to the Database Location where the new
database is located.
Then, hit Attach button and make sure that the tools displays a message “Database successfully detached”.
18
7. DBTool
The SMSDBTool is a program that allows the user to do basic database maintenance on the main SMS databases,
while preserving the database user rights that SMS requires.
The latest version of DBTool is compatible with SQL2005.
Once you have selected Application > SMS, and hit Connect button, you will see the following interface.
You are connected to the following databases:
-
SMS_System
SMS_History
SMS_AR_Staging
SMS_AR_Report
CE10
You can see where these databases are stored
by clicking on the “…” button.
By default they are under
C:\MSSQL2005\MSSQL.1\MSSQL\Data
19
For each of these databases, you will be able to perform maintenance with detach, Attach, Back up functions.
The first step is to stop the Powerlogic Network Server, to be able to detach any database.
If you have not stopped this service, you will get the following message:
7.1 Temp Settings
Hit Temp Settings button at the bottom of the window.
Here you can see the folders where database to attach is located, or where backup to restore is located.
By default they are all set to C:\MSSQL2005\MSSQL.1\MSSQL\Data.
7.2 Detach database
Once you have hit the Detach button, you will see the following windows:
Then the database is detached.
7.3 Attaching database
Once the database has been detached, you want to restore another database that you have just copied on the PC.
To do this, the first step is to go to Temp setting. Here you can choose in which folder the .mdf file is located, and
what is its name.
20
Folder of the .mdf
file
Enter the name of
the .mdf file to
attach
Once this has been done and DBTool has recognized the backup file, the Attach button will is not greyed out and
you can start attaching the database.
Hit Attach button.
Wait until you get the
message
“Done”
21
7.4 Restoring a backup
Once the database has been detached, you want to restore another database from a backup file.
To do this, the first step is to go to Temp setting. Here you can choose in which folder the .bak file is located, and
what is its name.
Folder of the .bak ; for
example :
C:\Powerlogic
Here enter the name of
the backup file
Once this has been done and DBTool has recognized the backup file, the Restore button will no longer be greyed
out.
Hit Restore button.
The restore of backup process
will start.
Wait until you get the message
“Done”
22
7.5 Performing a back up
When you connect to the database, you have the possibility to perform a backup of the database.
First, go to Temp Settings to set the location of the folder where you want to save the backup, and the name of this
backup.
Once this is done you just have to hit Backup button.
7.6 Viewing tables
DBTools allows you to view tables from the different databases.
This can be useful to check what data has been recorded for example.
For the relevant database, hit View button.
1. Select the table to view
2. Hit Select
3. View data
23
7.7 Running Scripts
DBTools allows you to run scripts. Hit Run Script button for the relevant database.
1. Hit Run
Script button
2. Hit Browse and
select the SQL script
(.sql) to run.
Then hit Run Script.
7.8 Disconnection from DBTool
Once you have finished working with DBTool, hit Disconnect button at the top of the window.
Restart Powerlogic network service.
24