Thursday, January 21, 2010

SQL Server - show list of all database files

select database_id, type_desc, name, physical_name, state_desc, size from sys.master_files;

You can play with this query to display more or less columns, of course. This will give you a list of all files including LOG files, which may not be your cup o' tea. (where type_desc <> 'LOGS')

Cheers

Wednesday, January 20, 2010

SQL Server Shrinkage

Sometimes you run into log files (and sometimes data files) that run away with you in size. To shrink or reduce the size of a SQL server file, especially logs, you need to trick the system into thinking you've written this data elsewhere. Here's how I do it.

use {database name}
go
backup log {database name} with truncate_only;
checkpoint;
dbcc shrinkfile ('{database filename}',{new file size}) ;
USE [master]
GO
ALTER DATABASE [{database name}] MODIFY FILE ( NAME = N'{database filename}', MAXSIZE = {new max size}KB )
GO

Oracle 10G startup problems - dbstart

When oracle doesn't want to start or simply doesn't start at all, here are some things that work for me:

Check $ORACLE_HOME/bin/dbstart -- can you start it manually and everything go smoothly?
Check $ORACLE_HOME/startup.log -- did something bomb?
Check /etc/oratab -- are your desired databases flagged with Y to indicate your interest in starting them?

There is a bug/QA opportunity in Oracle 10.2g Linux in $ORACLE_HOME/bin/dbstart. Evidentally a developer left a hardcoded path for the LISTNER (also spelled wrong) variable around line 78. The path in place is /ade/vikrkuma or something to that effect. Make sure this is replaced with $ORACLE_HOME for the entire path.

Out of the box, Oracle does not provide an auto startup script to automatically bring Oracle up. There are several examples on the internet to create an init.d script. The goal is to make sure you build an ability to run $ORACLE_HOME/bin/dbstart for your database. If you have multiple instanaces, your script has to be smart enough to declare its environment variables as user ORACLE prior to running the dbstart script. I generally wrote a single shell script for each startup process and an init.d script to call each one individually. Made for alot cleaner init.d script.

Also check running processes for your oracle instance. Run cd $ORACLE_HOME and then type "pwd" to see what directory you're in. Your directory should have a unique name at some point (some structures are like /oracle/product/10.2.0/db10gR2). In this case, I would use db10gR2 as my unique name. Take this name and grep it from the running process output to see if anything at all ran. ( ps ax | grep db10gR2 ) If you have any processes running but do not have tnslsnr, you likely cannot connect to your database. I would recommend running a $ORACLE_HOME/bin/dbshut and closing everything out. Check your oratab file to make sure you have the necessary databases flagged to start, and try again. Also, your oratab should list ASM instances prior to databases since the databases rely on ASM!

Upgrading Dell 6850 to Xeon Tulsa 7130M (Req 800T)

This blog is for my own notes. If you run into it from Google and get an answer or have a question, well that's cool too.

The Dell PowerEdge 6850 server comes in many variants, but only two primary variants actually matter. There are two series designations; original and Series II. The main and only difference is support for 800MHz bus. Systems that support 800MHz bus systems are Series II, are referred to as 800T systems, and use separate motherboards, memory risers, voltage regulators, and of course CPUs. Various BIOS revisions also dictate CPU support based on the date of release. A fully updated system should support any CPU designed for the Socket including Paxville and Tulsa. The trick for 800T based systems is to have the right VRMs in place for multiple processors. If you only intend to have 2 CPUs, you need nothing more than an 800T motherboard and 2 667/800 Memory risers to accomplish your goal. If you want 4 CPUs, you'll need SPECIFIC YC902 A01 CPU VRMs and 1 PD838 Cache VRM. Your system WILL NOT post without these 3 VRMs in place when Tulsa CPUs are used. If you have a Paxville 7041, the cache VRM is not required! Beware of K5331 VRMs for sale masked as PD838. The PD838 has a heatsink on only one side -- I purchased one from Dell directly to confirm. Purchasing from Dell is almost as cheap as third party for brand new, I might even recommend it.

Below are some known part numbers to make life easier (and searchable!)

Dell PowerEdge 6850 Motherboard Planar 800T - RD318
Dell PowerEdge 6850 Memory Riser 667/800 - ND891
Dell PowerEdge 6850 CPU VRM 800T - YC902 (version 10.2, important)
Dell PowerEdge 6850 Cache VRM 800T - PD838 (Tulsa Support for big cache)

Awesome CPUs supported: 7041 7120M 7130M 7140M 7150M
I have NOT tested 667 support for rock and roll CPUs except for 7040.
However, they are: 7040 7110N 7120N 7130N 7140N 7150N.

That's pretty much everything I know about the 6850. A note: there are TWO firmwares for this system - one for the motherboard and a second auxiliary system firmware. Be sure to keep both updated for proper CPU support. When in doubt, buy two low-mHZ pre-dual core Xeon MPs for Socket 602 for a couple bucks and you should be able to boot no problem for BIOS fixes and the like.