Monday, August 3, 2015
Example to create a Windows Batch script to run DB2 backup commands
db2cmd /c /w "db2 backup database sampledb online to "d:\backup" include logs without prompting"
And schedule the script using Windows Scheduler.
DB2 Online backup and restoration example
C:\Program Files\IBM\SQLLIB\BIN>db2 get db config |findstr LOGRETAIN
Log retain for recovery enabled (LOGRETAIN) = OFF
C:\Program Files\IBM\SQLLIB\BIN>db2 get db config |findstr LOGARCHMETH1
First log archive method (LOGARCHMETH1) = OFF
C:\Program Files\IBM\SQLLIB\BIN>db2 update db config using logretain "recovery"
C:\Program Files\IBM\SQLLIB\BIN>db2 update db config using logarchmeth1 "disk:c:\DB2\Logs"
C:\Program Files\IBM\SQLLIB\BIN>db2stop force
C:\Program Files\IBM\SQLLIB\BIN>db2start
C:\Program Files\IBM\SQLLIB\BIN>db2 backup database sampledb online to "d:\backup" include logs without prompting
Backup successful. The timestamp for this backup image is : 20150803223509
C:\Program Files\IBM\SQLLIB\BIN>db2 force application all
C:\Program Files\IBM\SQLLIB\BIN>db2 restore database sampledb from "d:\backup" taken at 20150803223509
C:\Program Files\IBM\SQLLIB\BIN>db2 rollforward database sampledb to end of backup and complete
Rollforward Status
Input database alias = sampledb
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000004.LOG - S0000005.LOG
Last committed transaction = 2015-08-03-14.35.14.000000 UTC
DB20000I The ROLLFORWARD command completed successfully.
Sunday, August 2, 2015
The domain join cannot be completed because the SID of the domain you attempted to join was identical to the SID of this machine
---------------------------
Computer Name/Domain Changes
---------------------------
The following error occurred attempting to join the domain "dbaglobe.com":
The domain join cannot be completed because the SID of the domain you attempted to join was identical to the SID of this machine. This is a symptom of an improperly cloned operating system install. You should run sysprep on this machine in order to generate a new machine SID. Please see http://go.microsoft.com/fwlink/?LinkId=168895 for more information.
---------------------------
OK
---------------------------
How to fix:
c:\Windows>cd c:\windows\system32\sysprep
c:\Windows\System32\Sysprep>dir
Volume in drive C has no label.
Volume Serial Number is 4EBE-B271
Directory of c:\Windows\System32\Sysprep
03/21/2014 12:18 PM <DIR> .
03/21/2014 12:18 PM <DIR> ..
08/01/2015 06:47 PM <DIR> ActionFiles
03/21/2014 11:09 AM <DIR> en-US
08/01/2015 05:33 PM <DIR> Panther
03/21/2014 11:49 AM 432,640 sysprep.exe
08/22/2013 04:02 AM 991,744 unbcl.dll
2 File(s) 1,424,384 bytes
5 Dir(s) 40,658,804,736 bytes free
c:\Windows\System32\Sysprep>Sysprep /generalize /shutdown /oobe
After sysprep generalization, it works per normal:
Reference: https://technet.microsoft.com/en-us/library/hh824938.aspx
Saturday, August 1, 2015
Sample on optimizing SQL Server queries using indexed view
Sample DW query:
| SELECT |
Create indexed View:
| if object_id('VW_EnglishEducation') is not null create view VW_EnglishEducation with schemabinding |
Limitations and Restrictions
-
The definition of an indexed view must be deterministic.
-
The user that executes CREATE INDEX must be the owner of the view.
-
When you create the index, the IGNORE_DUP_KEY option must be set to OFF (the default setting).
-
Tables must be referenced by two-part names, schema.tablename in the view definition.
-
User-defined functions referenced in the view must be created by using the WITH SCHEMABINDING option.
-
Any user-defined functions referenced in the view must be referenced by two-part names, schema.function.
-
The data access property of a user-defined function must be NO SQL, and external access property must be NO.
-
Common language runtime (CLR) functions can appear in the select list of the view, but cannot be part of the definition of the clustered index key. CLR functions cannot appear in the WHERE clause of the view or the ON clause of a JOIN operation in the view.
-
The view must be created by using the WITH SCHEMABINDING option.
-
The view must reference only base tables that are in the same database as the view. The view cannot reference other views.
-
If GROUP BY is present, the VIEW definition must contain COUNT_BIG(*) and must not contain HAVING. These GROUP BY restrictions are applicable only to the indexed view definition. A query can use an indexed view in its execution plan even if it does not satisfy these GROUP BY restrictions.
-
If the view definition contains a GROUP BY clause, the key of the unique clustered index can reference only the columns specified in the GROUP BY clause.
-
The SELECT statement in the view definition must not contain the following Transact-SQL elements:
COUNT
ROWSET functions (OPENDATASOURCE, OPENQUERY, OPENROWSET, AND OPENXML)
OUTER joins (LEFT, RIGHT, or FULL)
Derived table (defined by specifying a SELECT statement in the FROM clause)
Self-joins
Specifying columns by using SELECT * or SELECT table_name.*
DISTINCT
STDEV, STDEVP, VAR, VARP, or AVG
Common table expression (CTE)
float*, text, ntext, image, XML, or filestream columns
Subquery
OVER clause, which includes ranking or aggregate window functions
Full-text predicates (CONTAIN, FREETEXT)
SUM function that references a nullable expression
ORDER BY
CLR user-defined aggregate function
TOP
CUBE, ROLLUP, or GROUPING SETS operators
MIN, MAX
UNION, EXCEPT, or INTERSECT operators
TABLESAMPLE
Table variables
OUTER APPLY or CROSS APPLY
PIVOT, UNPIVOT
Sparse column sets
Inline or multi-statement table-valued functions
OFFSET
CHECKSUM_AGG
*The indexed view can contain float columns; however, such columns cannot be included in the clustered index key.
What is about the warning icon:
Monday, July 27, 2015
Database hang or may fail to OPEN in 12c IBM AIX - ORA-742
DEADLOCK or ORA-742 "Log read detects lost write" or ORA-600 [kcrfrgv_nextlwn_scn] during instance OPEN or ORA-600 [krr_process_read_error_2] during Recovery.
PMON may terminate the instance while extensive block recovery is being performed.
-- Restart the database or all instances of the RAC database
Saturday, July 11, 2015
Oracle FailSafe Security Setup Tool Must be Run With Administrative Privileges
FsSvrSec.bat) from the Windows Start menu, the utility executes and reports that it ran sucessfully, even though it did not actually succeed in changing the account or password for the OracleMSCSServices service. The Windows Application event log shows the following events (note that error 5 is ERROR_ACCESS_DENIED, "Access is denied"):Failed to open Service Control Manager with error: 5
Unable to set the user account for OracleMSCSServices service.
Unable to open cluster on local node.
Failed to open cluster with error 0
Failed to register Oracle Services for MSCS server with error: 10007.
Failed to create NT registry key AppID\{239D150B-FA41-11D1-BF40-00805FE9145B} with error: 5
Unable to set RunAs for OracleMSCSServices DCOM component.
FsSvrSec.bat file must be started from an MS-DOS command prompt that has been started with the Run as administrator option selected.Monday, July 6, 2015
MySQL innodb hotbackup (mysqlbackup) with table filtering
MySQL Enterprise Backup version 3.12.0 Windows-6.0-x86 [10.03.2015 ]
Copyright (c) 2003, 2015, Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
mysqlbackup.exe -u root -p --include-tables=^sakila.(actor|address)
--with-timestamp --backup-dir=c:\mysql\backup backup
mysqlbackup: INFO:
Enter password: ********
mysqlbackup: INFO: MySQL server version is '5.6.25-enterprise-commercial-advanced-log'.
mysqlbackup: INFO: Got some server configuration information from running server.
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'backup' run mysqlbackup
prints "mysqlbackup completed OK!".
150706 22:39:31 mysqlbackup: INFO: MEB logfile created at c:\mysql\backup\2015-07-06_22-39-31\meta\MEB_2015-07-06.22-39-31_backup.log
--------------------------------------------------------------------
Server Repository Options:
--------------------------------------------------------------------
datadir = C:\ProgramData\MySQL\MySQL Server 5.6\Data\
innodb_data_home_dir =
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = C:\ProgramData\MySQL\MySQL Server 5.6\Data\
innodb_log_files_in_group = 2
innodb_log_file_size = 50331648
innodb_page_size = 16384
innodb_checksum_algorithm = crc32
innodb_undo_directory = C:\ProgramData\MySQL\MySQL Server 5.6\Data\
innodb_undo_tablespaces = 0
innodb_undo_logs = 128
--------------------------------------------------------------------
Backup Config Options:
--------------------------------------------------------------------
datadir = c:\mysql\backup\2015-07-06_22-39-31\datadir
innodb_data_home_dir = c:\mysql\backup\2015-07-06_22-39-31\datadir
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = c:\mysql\backup\2015-07-06_22-39-31\datadir
innodb_log_files_in_group = 2
innodb_log_file_size = 50331648
innodb_page_size = 16384
innodb_checksum_algorithm = crc32
innodb_undo_directory = c:\mysql\backup\2015-07-06_22-39-31\datadir
innodb_undo_tablespaces = 0
innodb_undo_logs = 128
mysqlbackup: INFO: Unique generated backup id for this is 14361935712403634
mysqlbackup: INFO: Creating 14 buffers each of size 16777216.
150706 22:39:33 mysqlbackup: INFO: Full Backup operation starts with following threads
1 read-threads 6 process-threads 1 write-threads
150706 22:39:33 mysqlbackup: INFO: System tablespace file format is Antelope.
150706 22:39:33 mysqlbackup: INFO: Starting to copy all innodb files...
150706 22:39:33 mysqlbackup: INFO: Found checkpoint at lsn 8424992.
150706 22:39:33 mysqlbackup: INFO: Copying C:\ProgramData\MySQL\MySQL Server 5.6\Data\ibdata1 (Antelope file format).
150706 22:39:33 mysqlbackup: INFO: Starting log scan from lsn 8424960.
150706 22:39:33 mysqlbackup: INFO: Copying log...
150706 22:39:33 mysqlbackup: INFO: Log copied, lsn 8424992.
150706 22:39:33 mysqlbackup: INFO: Copying C:\ProgramData\MySQL\MySQL Server 5.6\Data\sakila\actor.ibd (Antelope file format).
150706 22:39:33 mysqlbackup: INFO: Copying C:\ProgramData\MySQL\MySQL Server 5.6\Data\sakila\address.ibd (Antelope file format).
150706 22:39:33 mysqlbackup: INFO: Completing the copy of innodb files.
150706 22:39:33 mysqlbackup: INFO: Starting to copy Binlog files...
150706 22:39:33 mysqlbackup: INFO: Copying C:\ProgramData\MySQL\MySQL Server 5.6\Data\VMMDB01-bin.000001.
150706 22:39:33 mysqlbackup: INFO: Copying C:\ProgramData\MySQL\MySQL Server 5.6\Data\VMMDB01-bin.000003.
150706 22:39:33 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
150706 22:39:33 mysqlbackup: INFO: Starting to lock all the tables...
150706 22:39:33 mysqlbackup: INFO: All tables are locked and flushed to disk
150706 22:39:33 mysqlbackup: INFO: Copying C:\ProgramData\MySQL\MySQL Server 5.6\Data\VMMDB01-bin.000004.
150706 22:39:34 mysqlbackup: INFO: Completed the copy of binlog files...
150706 22:39:34 mysqlbackup: INFO: Opening backup source directory 'C:\ProgramData\MySQL\MySQL Server 5.6\Data\'
150706 22:39:34 mysqlbackup: INFO: Starting to backup all non-innodb files in
subdirectories of 'C:\ProgramData\MySQL\MySQL Server 5.6\Data\'
150706 22:39:34 mysqlbackup: INFO: Copying the database directory 'sakila'
150706 22:39:34 mysqlbackup: INFO: Completing the copy of all non-innodb files.
150706 22:39:35 mysqlbackup: INFO: A copied database page was modified at 8424992.
(This is the highest lsn found on page)
Scanned log up to lsn 8424992.
Was able to parse the log up to lsn 8424992.
Maximum page number for a log record 0
150706 22:39:35 mysqlbackup: INFO: All tables unlocked
150706 22:39:35 mysqlbackup: INFO: All MySQL tables were locked for 1.783 seconds.
150706 22:39:35 mysqlbackup: INFO: Reading all global variables from the server.
150706 22:39:35 mysqlbackup: INFO: Completed reading of all global variables from the server.
150706 22:39:35 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in c:\mysql\backup\2015-07-06_22-39-31
150706 22:39:35 mysqlbackup: INFO: Full Backup operation completed successfully.
150706 22:39:35 mysqlbackup: INFO: Backup created in directory 'c:\mysql\backup\2015-07-06_22-39-31'
150706 22:39:35 mysqlbackup: INFO: MySQL binlog position: filename VMMDB01-bin.000004, position 120
-------------------------------------------------------------
Parameters Summary
-------------------------------------------------------------
Start LSN : 8424960
End LSN : 8424992
-------------------------------------------------------------
mysqlbackup completed OK!