Wednesday, November 30, 2011

process to create database mirroring when servers are not under domain

As the severs are not part of domain, we cannot use ntlm or kerberos to authenticate the user,
so we need to create certificates, then create login and user to use that certificate, create end point using the above user such that both sql servers can trust each other


Principal server steps
----------------------
--CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'pa55w0rd!' ;

USE master;
SELECT * FROM sys.certificates;


USE master;
CREATE CERTIFICATE principal_mirror_cert
WITH SUBJECT = '172.23.5.22 certificate for database mirroring',
EXPIRY_DATE = '1/1/2100';
GO



SELECT name, role_desc, state_desc, connection_auth_desc, encryption_algorithm_desc
FROM sys.database_mirroring_endpoints;

drop ENDPOINT Endpoint_Mirroring


CREATE ENDPOINT Endpoint_Mirroring
STATE = STARTED
AS TCP (
LISTENER_PORT=5023
, LISTENER_IP = ALL
)
FOR DATABASE_MIRRORING (
AUTHENTICATION = CERTIFICATE principal_mirror_cert
, ENCRYPTION = REQUIRED ALGORITHM AES
, ROLE = ALL
);
GO


BACKUP CERTIFICATE principal_mirror_cert TO FILE = 'D:\Mirroring_Cert\principal_mirror_cert.cer';
GO

xp_fixeddrives


USE master;
CREATE LOGIN secondary_mirror_login WITH PASSWORD = 'pa55w0rd!';
GO
--Create a user for that login.

CREATE USER secondary_mirror_user FOR LOGIN secondary_mirror_login;
GO
--Associate the certificate with the user.

CREATE CERTIFICATE secondary_mirror_cert
AUTHORIZATION secondary_mirror_user
FROM FILE = 'D:\Mirroring_Cert\secondary_mirror_cert.cer'
GO

GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO secondary_mirror_login;
GO

--At HOST_A, set server instance on HOST_B as partner (mirror server).
ALTER DATABASE school
SET PARTNER = 'TCP://172.23.5.44:5023';
GO

Mirror Server Steps
-----------------------
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'pa55w0rd!' ;

SELECT * FROM sys.certificates;

USE master;
CREATE CERTIFICATE secondary_mirror_cert
WITH SUBJECT = '172.23.5.44 certificate for database mirroring',
EXPIRY_DATE = '1/1/2100';
GO

drop endpoint Endpoint_Mirroring

CREATE ENDPOINT Endpoint_Mirroring
STATE = STARTED
AS TCP (
LISTENER_PORT=5023
, LISTENER_IP = ALL
)
FOR DATABASE_MIRRORING (
AUTHENTICATION = CERTIFICATE secondary_mirror_cert
, ENCRYPTION = REQUIRED ALGORITHM AES
, ROLE = ALL
);
GO


SELECT name, role_desc, state_desc, connection_auth_desc, encryption_algorithm_desc
FROM sys.database_mirroring_endpoints;

xp_fixeddrives

BACKUP CERTIFICATE secondary_mirror_cert TO FILE = 'D:\Mirroring_Cert\secondary_mirror_cert.cer';
GO


USE master;
CREATE LOGIN principal_mirror_login WITH PASSWORD = 'pa55w0rd!';
GO
--Create a user for that login.

CREATE USER principal_mirror_user FOR LOGIN principal_mirror_login;
GO
--Associate the certificate with the user.

CREATE CERTIFICATE principal_mirror_cert
AUTHORIZATION principal_mirror_user
FROM FILE = 'D:\Mirroring_Cert\principal_mirror_cert.cer'
GO

GRANT CONNECT ON ENDPOINT::Endpoint_Mirroring TO principal_mirror_login;
GO

--At HOST_B, set server instance on HOST_A as partner (principal server):
ALTER DATABASE school
SET PARTNER = 'TCP://172.23.5.22:5023';
GO

ALTER DATABASE school
SET PARTNER off;
GO

Tuesday, November 8, 2011

Excel 2007 automation on top of a Windows Server 2008 x64

This solution is ...

・Windows 2008 Server x64

Please make this folder.

C:\Windows\SysWOW64\config\systemprofile\Desktop

・Windows 2008 Server x86

Please make this folder.

C:\Windows\System32\config\systemprofile\Desktop