Friday, August 27, 2010

SQL Server 2008 R2 - 2 node cluster build

SQL 2008 R2 on Windows Server 2008 R2 Clustered install
On both nodes

- need .NET 3.5 SP1 use the Role Management Tool

- Add Role - Application Server

Run the setup.exe - SQL Server Installation Center

- Click Installation on left > New SQL Server Failover installation

- Setup suport Rules - click OK

- Prod Key - click next

- EULA - accept - next

- Click Install

- Setup support Rules - will tell you more about what else you might want to install for this to work.

-  - MSDTC - not always needed for cluster. install if you want.

-  - MSCS - cluster validation report failure - http://support.microsoft.com/kb/953748 - if you havent validated your cluster, you get an error when trying to install - go to Failover Cluster manager and click Validate this cluster.

- prod key - click next

- EULA - accept - next

- Feature Selection - Database Services, Analysis Services, Reporting Services - next

-

Instance Config

- SQLServer Network Name - obxSQL0801

- Named Instance - SQL1

- next

Disk Space Reqs - you will need at least 4 or 5 gbs of local disk space if you're going to install the services I listed above.  I had to go back and shut down my vms and cut a D drive (thin-vhd) of 20GB on each of my nodes. then you can install all your SQL bits on the new D drive instead of on the OS drive.

- instance root directory - d:\

- next

Cluster Resource Group

- SQL Server cluster resource group name - SQL Server (SQL1)

- next

Cluster Disk Selection

- select both of your cluster disks for data and logs

- next

Cluster Network Configuration

- uncheck DHCP and put in an available non-DHCP address

- next

Cluster Security Policy

- select Use service SIDs (recommended)

- next

Server Config

- create a service account in AD obxClusterService

- use obxbill\obxClusterService

- next

Database Eng Config

- select mixed mode

- specify your sa password

- click add current user

- click Data Directories tab, make sure you're using the correct drive for the type of db file - i.e. R:\Data and L:\Logs and R:\Backup, etc, etc

- next

Analysys Services Config

- click Add current user

- click Data Directories tab, i.e. R:\OLAP\Data, L:\OLAP\Log, R:\OLAP\Temp and R:\OLAP\Backup

- next

Reporting Services Config

- install but do not configure

- next

Error Reporting

- next

Cluster Installation Rules

- all passed - hit next

Ready to Install

- click install, go have a drink and a smoke now.

- maybe call your mom to let them know you passed the CISSP Exam...

- think about what to have for dinner

- go water some houseplants

- decide that a potbelly samich sounds easy enough

Complete

- close

now go to the obxNode04 and start the SQL install just like you did here

- setup.exe - Installation > Add node

Setup Support Rules

- all passed - ok

Prod Key - next

EULA - accept - next

Setup support files - install

Setup Support Rules

- all passed - next

Cluster node config

- select your SQL1 instance

- next

Service Accounts

- enter the password for the service acct you created earlier

- next

Error Reporting

- next

Add Node Rules

- passed

- next

Ready to Add node

- click install

Add Node Progress

- if you havent gone to go get dinner by now.  It's probably a good time. :)

- next

Complete

- success! - close

okie dokie - test your failover cluster by moving the SQL1 application, etc, etc and now go eat sandwich and watch Jeopardy or somethin.

Thursday, August 26, 2010

FreeNAS - This thing rocks.

FreeNAS is a free network-attached storage server OS. Personally, I like to use it as a VM with 256 MB RAM (higher if your going to do RAID5, then you want 512, and if you're thinking ZFS then, better give a gig) and an 8GB thin provisioned VHD on one of my ESXi servers. You could probably get away with an even smaller VHD drive for the OS. Supposedly only 128MB. I figure, I'll give it a thin-provisioned disk and if it ever needs it, it'll grab it then. Minimum Hardware Requirements

  1. Download the ISO file of the version you want from here

  2. Create and start a new VM with 8gb thin vhd, 256 mb ram and give it a name like obxFreeNAS01 with your iso file attached.

  3. Once it's started, choose to install FreeNAS on the local 8gb thin vhd.

  4. Then configure your IP address as DHCP first... then let it initialize.  Now, I know you don't want a stupid DHCP address on that thing. because you don't want your iSCSI initiators out there losing a potentially very important connection to it's drive. But trust me on this...

  5. Test a regular ol web browser and point it to the DCHP address that it was assigned.  Just to make sure you get a login at all.

  6. Shutdown your FreeNAS vm. Now configure a few new thin-provisioned VHDs for this VM.  Make a 5gb, 10gb and a 20GB one.  Later we'll use them for things like a quorum, data drive and a log drive for a SQL 2008 R2 Failover Cluster :)

  7. Start up your FreeNAS vm.

  8. Configure a static IP address for the FreeNAS... let it initialize.

  9. Now, go open a browser and make sure that the login screen for FreeNAS comes up ok.

  10. login with username admin and password freenas Once you're in, you should go update the default password to something else and also create yourself a new user account with admin privs.

  11. Next to come... the steps to create iSCSI Targets for your Windows 2008 R2 nodes to use for a Failover Cluster.

  12. Disks > Management > click the + link, select a disk you want to carve for your cluster (it'll be something like da1)

  13. Give it a description, like Logs. Leave it Unformatted and click Add

  14. Do the same for all of the vhds that you created for your cluster. I've got 3. Quorum of 5gb, Data of 20GB and Logs of 10GB.

  15. Disks > Format > Format UFS for each of your disks, give them a Volume label that matches your descriptions from the previous steps.  There's many ways to skin this cat.  This is simply my little method.

  16. Disks > Mount Points > click the + link. Give it a mount point name and description. I'm boring, I just used the same names I used for the respective volume names and disk descriptions. click Add.

    1. Oh yeah... you might notice that things get stuck in Modifying status... uh... don't forget to click APPLY CHANGES.... it's a sneaky little button at the top of the page in a few places.



  17. Services > iSCSI Target > Settings > Set your Base Name...

    1. I'm using iqn.2007-09.jp.ne.peach.obxFreeNAS01



  18. Services > iSCSI Target > Initiators> create an initiator for your own subnet.

    1. (i.e. 192.168.1.0/24)



  19. Services > iSCSI Target > Portals > use  the static IP address of your FreeNAS VM.

    1. something like this 192.168.1.58:3260



  20. Services > iSCSI Target > Targets > create an extent file for each of your disks

    1. mine looks like this: Extent name - Data0, Type - File, Path - /mnt/Data/data.file, File Size - 20Gib, Comment - Data

    2. now! Create a Target for that extent file we called Data0 and give it a Target Name of Data0

    3. Click Add at the bottom, now click Apply Changes at the top.



  21. ok - now you're ready to build a Windows 2008 R2 cluster.  Just fire your nodes up and use the local iSCSI initiator to connect to your disks. Bring em online, initialize them, format them, give them drive letters and give them a volume name.

Thursday, August 19, 2010

Windows 2008 R2


  1. Create vm with 1gb ram, 12gb hd, with Win2008R2 64bit iso and run

  2. Activate Windows with PID

  3. Update Time Zone

  4. Update computer name and join domain (don't reboot just yet!)

  5. Enable Remote Desktop

  6. Turn off Windows Firewall for Domain, Home and Public

    1. Think about it. This server is in the green zone. And it you wanna have Symantec CSP installed, you eventually want this off anyway.



  7. Install VMWare Tools

  8. Shut down the VM

  9. Reconfig the VM to have only 512mb RAM... yes, thats right folks! Squeeze-em'!

  10. Start the VM, and now RDP straight to the box via either the name or IP

  11. Start > Admin Tools > iSCSI initiator - click yes to turn the service on

  12. Put the IP address of the OpenFiler Server in the Target box on the first tab > click Quick Connect

  13. Connect to each of the disk resources that are going to be clustered (quorum, data, logs)

  14. Click OK

  15. Open Disk Manager and bring each disk online

  16. Then give them the same drive letter as they are on the other node(s)

  17. Open the Initial Configuration Tasks > Add Features > Select Failover Clustering

  18. Click Next > click Install > click Close

  19. Start the Failover Manager

  20. Click Validate Configuration > Add the current server name > click Add

  21. Enter the name of another Windows 2008 R2 Ent x64 VM that is configured the same way up to this step.

  22. Click Next, Run all test > click Next > Confirmation click Next > Click View Report

  23. Create a new cluster > give it a name > give it an IP address > click Next

  24. Confirmation click Next > Summary Success! click Finish

  25. Shut down each node - bring one node online and then bring the other one online.  Reboot each node to test failover of the disk resources.

  26. now you can install SQL 2008 R2 as a cluster

Stop whining list




  1. FreeNas...

  2. Windows 2008 R2 2 node Cluster build

  3. IIS 7.5

    1. php.iis.net

    2. WordPress 3.0 Post Setup

    3. mySQL - with phpmyadmin



  4. SQL 2008 R2 Enterprise cluster build

    1. Majority node set with cluster, witness server

    2. Shared disk with quorum from iSCSI Target from FreeNAS



  5. Self-Signed certs (SSL)

  6. ISA - 443 to 80

  7. RDP default port add/change - entry on http://d.patrickoneill.com/?p=83

  8. MOSS 2007 to MOSS 2010 upgrade/migrate

  9. get patches for Mom's computer :)

Monday, August 9, 2010

Users in SharePoint with email addresses not associated with the domain

This is a pretty easy one actually. 

  1. Start > Run > dsa.msc (this opens Active Directory Users and Computers)

  2. Select the user. On the General Tab, change the email address to an email address that your domain isn't managing (i.e. @yahoo.com, @gmail.com, etc, etc). Click OK

  3. Open SharePoint Central Admin console. Click the SSP link off of the Home page of Central Admin

  4. Login (duh).

  5. Under User Profiles and My Sites > Click User Profiles and Properties

  6. Click Start Full Import

  7. After the import is completed, you should view the target user's profile and remove any Proxy addresses.


Next, if the user has already been granted access to your MOSS Web Application, you will need to remove the user and then re-add the user back into their original permissions. Then, when you go to view the user's profile details, they will show up with the user's new email address.

Friday, August 6, 2010

To put the entire SQL server into single user mode

This is for SQL2005, for SQL 2008, you will need to change the directory where the sqlservr.exe file is located.




Open Cluster Admin - stop SQL services

open cmd prompt and type (or copy/paste) the following:

cd "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn"

sqlservr.exe /s SQL1 /c /m /T3608

- you will see a bunch of stuff fly by on the cmd window, this is normal

start SQL Management Studio

Click CANCEL! on the connection prompt

Click New Query - then select your database from the drop list (it's right under the New Query button)

Paste in your DB reindex t-SQL script in the query window and execute

Set a database into Single User Mode











ALTER DATABASE [URSTUPIDDATABASE] SET MULTI_USER WITH NO_WAIT


ALTER DATABASE [URSTUPIDDATABASE] SET SINGLE_USER WITH NO_WAIT







or





EXEC sp_dboption 'URSTUPIDDATABASE', 'single user', 'false'

EXEC sp_dboption 'URSTUPIDDATABASE', 'single user', 'true'


Thursday, August 5, 2010

t-SQL to allow comments and ping backs on all your posts

If you want to update all of your posts in your Word Press blog site from closed commentsand closed pingbacks, then you can run this update script to update all of your posts to allow comments and pingbacks. Log in to your PHPMyAdmin where your database for your site lives, select the database, then select Query and insert the following, then click Go. :)
UPDATE wp_posts
SET Comment_Status = 'open',Ping_Status = 'open'
WHERE ID > 0

NOTE: Now, sometimes, when these SQL queries are placed in block-quotes, the single quotes get all weird and you might have to re-type them.

Tuesday, August 3, 2010

Virtual Domain Controllers

OK - my domain has 2 Domain Controllers that are physical (real servers).  I'm tired of the noise and space footprint in my office.  So, I've decided to create 2 new virtual machines (DC03 and DC04), promote them to domain controllers, move the roles over to them and then demote the old domain controllers (DC01 and DC02). However, when I tried to just DCPromo them, I got an error message:
The version of the ActiveDirectory schema of the source forest is not compatible with the version of the Active Directory on this computer

Resolution: http://support.microsoft.com/kb/917385

Here's my basic steps:

  • Create 2 VMs with Windows 2003 Standard R2 x86 OS

  • on DC01, copy CMPNENTS\R2\ADPREP from disk 2 of Windows 2003 STD R2

  • Open command prompt


  • ADPrep /ForestPrep

  • Warning message will appear. As long as all DCs are 2003 and up, type C, hit ENTER

  • Wait.......

  • When completed, log off DC01


  • Log onto DC03, Run DCPromo. When completed, reboot and repeat on DC04.

  • Install DNS role to new DC03 and DC04. Validate all DNS Properties of the DNS and Forward lookup settings are the same between DC01 the new DC03 and DC04 DNS servers

  • In stall WINS on DC03

  • Install Remote Access VPN on DC03

  • Install DHCP on DC03 (dont forget to Authorize it when you're done)

Moving the System databases for SQL 2005 on a cluster

Background

Best practices for SQL configuration recommend moving system databases, particularly the TempDB, to a separate drive.  On a cluster, this drive must be a shared cluster resource that is, like all drives supporting the SQL instance, a dependent cluster resource.  While there is no need to separate out the data and log files for system databases, the following instructions will assist in moving system files together to a separate clustered drive.  In the examples below, assume E:\ is a clustered drive resource which can be replaced with whatever specific drive is designed for each particular instance.

1.0 Moving Model Database Files



  1. In Cluster Admin, shut down SQL Server and SQL component cluster resources.

  2. Navigate to a command prompt on the active node and start the SQL server using startup parameters:


"C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe" –s<instance name> –c –m –T3608

NOTE:  Cluster resources for drives, virtual server, and IP address must be online. Also, for more information on the startup parameters, see http://technet.microsoft.com/en-us/library/ms190737.aspx and http://technet.microsoft.com/en-us/library/ms188396.aspx

  1. Ensure the SQL Browser has been restarted.

  2. Open SQL Server Management Studio but cancel the login dialog

  3. Close the Object Explorer window.

  4. Click on New Query and log in as Admin (i.e., ADMIN:ServerName\InstanceName) using sa account (assuming the sa account is system administrator account).

  5. Use the following query:


use master
go
sp_detach_db 'model'
go


  1. Move the Model.mdf and Modellog.ldf files from the current location to the desired location.

  2. Reattach the model database by using the following commands:


use master
go
sp_attach_db 'model','E \model.mdf','E:\Sqldata\modellog.ldf'
go

(NOTE:  Replace the filepath above with the new location of the files.)

10.  Close SQL Server Management Studio

11.  Shut down SQL by typing Ctrl + C at the command prompt where you started SQL.

12.  Bring SQL Resource online in Cluster Administrator.

13.  Open SQL Server Management Studio (you should be able to log in normally as you are no longer in single-user mode).

14.  Verify the location of the model files by running the following query:
use model
go
sp_helpfile
go

2.0 Moving MSDB Database Files



  1. In Cluster Admin, shut down SQL Server and SQL component cluster resources.

  2. Navigate to a command prompt on the active node and start the SQL server using startup parameters:


"C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe" –s<instance name> –c –m –T3608

NOTE: Cluster resources for drives, virtual server, and IP address must be online.

  1. Ensure the SQL Browser has been restarted.

  2. Open SQL Server Management Studio but cancel the login dialog

  3. Close the Object Explorer window.

  4. Click on New Query and log in as Admin (i.e., ADMIN:ServerName\InstanceName) using sa account (assuming the sa account is system administrator).

  5. Use the following query:


use master
go
sp_detach_db 'msdb'
go


  1. Move the Model.mdf and Modellog.ldf files from the current location to the desired location.

  2. Reattach the model database by using the following commands:


use master
go
sp_attach_db 'model','E \msdbdata.mdf','E:\Sqldata\msdblog.ldf'
go

(NOTE:  Replace the filepath above with the new location of the files.)

10.  Close SQL Server Management Studio

11.  Shut down SQL by typing Ctrl + C at the command prompt where you started SQL.

12.  Bring SQL Resource online in Cluster Administrator.

13.  Open SQL Server Management Studio (you should be able to log in normally as you are no longer in single-user mode).

14.  Verify the location of the model files by running the following query:
use msdb
go
sp_helpfile
go

3.0 Moving Master Database Files



  1. From the Start menu, point to All Programs, point to Microsoft SQL Server, point to Configuration Tools, and then click SQL Server Configuration Manager

  2. In the SQL Server Services node, right-click the instance of SQL Server (for example, SQL Server [MSSQLSERVER]) and select Properties

  3. In the SQL Server (instance_name) Properties dialog box, click the Advanced tab.

  4. Edit the Startup Parameters values to point to the planned location for the master database data and log files, and click OK.  Moving the error log file is optional.

  5. The parameter value for the data file must follow the -d parameter and the value for the log file must follow the -l parameter.  The following example shows the parameter values for the default location of the master data and log files.


-dC:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\LOG\ERRORLOG;-lC:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\mastlog.ldf


  1. If the planned relocation for the master data and log files is E:\SQLData, the parameter values would be changed as follows:


-dE:\SQLData\master.mdf;-eC:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\LOG\ERRORLOG;-lE:\SQLData\mastlog.ldf


  1. Stop the instance of SQL Server by right-clicking the instance name and selecting Stop

  2. Move the master.mdf and mastlog.ldf files to the new location.

  3. Restart the instance of SQL Server


10.  Verify the file change for the master database by running the following query:
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID('master');
GO

4.0  Moving TempDB Database Files



  1. Determine the logical file names of the tempdb database and their current location on the disk:


SELECT name, physical_name AS CurrentLocation
FROM sys.master_files
WHERE database_id = DB_ID(N'tempdb');
GO


  1. Change the location of each file by using ALTER DATABASE


USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'E:\SQLData\tempdb.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'E:\SQLLog\templog.ldf');
GO


  1. Stop and restart the instance of SQL Server

  2. Verify the file change:


SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'tempdb');


  1. Delete the tempdb.mdf and templog.ldf files from the original location.

  2. Add additional tempDB files:


ALTER DATABASE tempdb
ADD FILE (NAME = tempdev2, FILENAME = 'X:\tempdb2.mdf', SIZE = 256);
ALTER DATABASE tempdb
ADD FILE (NAME = tempdev3, FILENAME = 'X:\tempdb3.mdf', SIZE = 256);
ALTER DATABASE tempdb
ADD FILE (NAME = tempdev4, FILENAME = 'X:\tempdb4.mdf', SIZE = 256);
GO

NOTE: Replace the path and filename with appropriate target names.

Add as many files as there are processors per MS Best Practices.  The final number is discretionary based on the demand model for the system.

Restart the server and verify the functionality and location of tempDB:
use tempdb
go
sp_helpfile
go

Note: don't forget to delete the old tempdb MDF and LDF files. SQL won't do it...

Monday, August 2, 2010

Updating the TEMPDB

Here's a quick/dirty little script to update your tempdb for SQL to 5GB for the tempdev (tempdb.mdf) file and 512MB for the templog (templog.ldf) file while at the same time turning off Auto Growth.


USE [master]

GO

ALTER DATABASE

[tempdb]

MODIFY FILE

(NAME = N'tempdev', SIZE = 5242880KB , FILEGROWTH = 0)

GO

ALTER DATABASE

[tempdb]

MODIFY FILE

(NAME = N'templog', SIZE = 524288KB , FILEGROWTH = 0)

GO


The restart your SQL Server Agent and SQL Server Services. Mine is on a cluster with the instance named SQL1.  If you are running on an MS Cluster, then you should probably do this via the Cluster Administrator console because even though the services may be online, the cluster admin console may report them to be in a failed state.



net stop SQLAgent$SQL1 & net stop MSSQL$SQL1

net start MSSQL$SQL1 & net start SQLAgent$SQL1




And yes, you can run a single command with that little ampersand (&) thingy there. :)

Here's an example of setting a TempDB with the following:

mdf file at 15GB, max size of 17.5GB, and growth at 10%

ldf file at 1.5GB, max size of 1.8 GB, and growth set to 10%
USE [master]
GO
ALTER DATABASE [tempdb]
MODIFY FILE ( NAME = N'tempdev',
SIZE = 15728640KB ,
MAXSIZE = 18350080KB,
FILEGROWTH = 10% )
GO
ALTER DATABASE [tempdb]
MODIFY FILE ( NAME = N'templog',
SIZE = 1572864KB ,
MAXSIZE = 1835008KB,
FILEGROWTH = 10% )
GO

Special note: If you copy/paste the code from the block-quotes above, and then try to run them in SQL Management Studio, you might notice them failing.  Try updating the single quotes from  around the file names, tempdev and templog.