The Multifunctioning DBA


March 1, 2009  4:12 AM

Network Capture

Colin Smith Colin Smith Profile: Colin Smith

I had an issue with some servers communicating and so I put wireshark on both machines and I was able to trak it down to the routing that the network packets were taking. I was able to take this information to our networking team, they analyzed the data and made a change to a firewall and now everything is working. Wireshark is a great tool and I would recommend it to you if you think you have a network related issue. Get it at http://www.wireshark.org/.

February 27, 2009  2:34 PM

Oracle Upgrade

Colin Smith Colin Smith Profile: Colin Smith

I did my Oracle upgraded yesterday and overall I think that it went pretty well. We are still testing but so far so good. The process was not too bad. First you need to create a new $ORACLE_HOME as two Oracle installations can not be in the same $ORACLE_HOME. Then install the media. I did run into one snag here, it did not want to install on the Solaris 10 OS 64 Bit. After some looking we found this to be a bug and we found a resolution. Then I installed items from the companion CD. This is was tricky as well. I selected the companion cd products and I could not install them into the same $ORACLE_HOME. I kept fooling around with it and found that if you choose Oracle 10g products then it installs just fine and does install the items from the companion cd. All I wanted from the companion cd was JAccelerator but it forces you to install all 20 products. LAME. After that I did all my patching and I did not install a new Database. This is because I want to upgrade an existing DB. After that I ran the Database Upgrade Assistant and that is really all there was to it. So if anyone is upgrading and has any questions please let me know by going to http://sysadminsmith.com and clicking the Submit A Question link on the right.


February 27, 2009  2:26 PM

Interview

Colin Smith Colin Smith Profile: Colin Smith

A couple weeks ago I had mentioned that my company was forcing all of us to take unpaid time off work. Well I have an interview today. Sounds like a good place to work and it is in the Medical field so I am very excited about it. I think the Medical field is a great place to be in this type of economy. And it also just goes to show that IT jobs are out there. So wish me luck, as I do you if you are also looking for a job. I have been and am very lucky since I have had a job this entire time. I will keep you posted.


February 25, 2009  4:58 PM

Oracle Upgrade

Colin Smith Colin Smith Profile: Colin Smith

It looks like I might get the chance to upgrade one of our Test oracle systems today. I will be moving from 9.2.0 to 10.2. This should be interesting as I am still pretty new to Unix and to Oracle. I am looking forward to this and it really looks pretty straight forward. Looks like I will have to migrate to a Locally Managed Temp space from Dictionary managed and then do the actual upgrade. I will be using the Oracle upgrade assistant and I do not think that I should have any issues. I am doing this on a Solaris 64 SPARK server. I will keep you updated as I work through this task.


February 24, 2009  6:18 PM

Powershell commands for Active Directory

Colin Smith Colin Smith Profile: Colin Smith

I have been asked how to manage Active Directory with Powershell. The best way is with the Quest Software cmd-lets for Active Directory. They are free and available at http://www.quest.com/powershell/activeroles-server.aspx. Once you download them and install them you will still need to add the snapin to your powershell profile. In order to do this just open powershell and do the following.

This will open your powershell profile in notepad. The Powershell profile is really just a powershell script. You can have it do anything you want. I have mine add a few psdrives that I use often and add the snapins that I need. Just add the following line to your profile script and you will be able to use all the AD cmd-lets that Quest has been so kind to supply for free.

add-pssnapin quest.activeroles.admanagement

You can do this with any set of snapins that you find. I have some for sqlserver as well that come in handy.

Let me know if you have any questions by going to http://sysadminsmith.com and clicking the submit a question link to the right.


February 20, 2009  9:20 PM

Sybase Kill Runaway Process

Colin Smith Colin Smith Profile: Colin Smith

I am working on a stored proc that will be launched by a threshold that I set up on the log segment of my databases. It is a bit of work but I think that it will be nice not to get the page that someone has written some poor SQL and is filling up the log segment. I will not be running this in Production but I will in all other environments. I have started the proc and it is a work in progress at this time. I am pretty new to SQL as in my position I do not write a lot of SQL and this is one way that I am trying to learn. Here are the guts of it so far. It is getting me almost all of what I need. Now I need to figure out how I can get just the top row of the resultset and then kill that spid as that spid is the one with the most IO. Anyway here it is and I will let you know how it is going and when I have it complete.

Just in case you are wondering, The sp_threshold will pass the @dbname variable.

USE sybsystemprocs

go

IF
OBJECT_ID(‘dbo.sp__killrunaway’) IS
NOT
NULL

BEGIN


DROP
PROCEDURE dbo.sp__killrunaway


IF
OBJECT_ID(‘dbo.sp__killrunaway’) IS
NOT
NULL


PRINT
‘<<< FAILED DROPPING PROCEDURE dbo.sp__killrunaway >>>’


ELSE


PRINT
‘<<< DROPPED PROCEDURE dbo.sp__killrunaway >>>’

END

go

create
procedure dbo.sp__killrunaway

(@dbname varchar(30))

as

declare @dbid int

select @dbid = dbid from master..sysdatabases

where name = @dbname

select hostname, a.spid, b.name, physical_io, c.name

from master..sysprocesses a, master..syslogins b, master..sysdatabases c

where c.dbid = @dbid and

a.suid = b.suid and

a.dbid = c.dbid

order
by physical_io desc

go

EXEC dbo.sp_procxmode ‘dbo.sp__killrunaway’,‘unchained’

go

IF
OBJECT_ID(‘dbo.sp__killrunaway’) IS
NOT
NULL


PRINT
‘<<< CREATED PROCEDURE dbo.sp__killrunaway >>>’

ELSE


PRINT
‘<<< FAILED CREATING PROCEDURE dbo.sp__killrunaway >>>’

go

_


February 19, 2009  5:06 PM

Great Powershell Site

Colin Smith Colin Smith Profile: Colin Smith

I ran across this site the other day and signed up. It has some great stuff and I have uploaded a couple of my powershell scripts to the site as well. If you love powershell like I do then you will check it out and sign up for a free account. Enjoy.

http://powershell.com/cs/


February 19, 2009  4:53 PM

AD Migration Script Q and A

Colin Smith Colin Smith Profile: Colin Smith

I received a question from Sandeep as follows:

Hi Colin,

I saw your answer to one of the AD user creation question on IT Knowledge Exchange. You had mentioned that a script can be written using Powershell to migrate a lot of users. I’m completely new to AD and I have a few queries, could you please help?

Queries:

1. I would like to migrate all the users from one Active Directory, Say “X” on MS NT to Active Directory, say “Y” on MS 2000/ MS 2003, is this possible to do without using any tool?

2. Please provide me some details on the scripts that need to be written to accomplish this.

3. What are the steps I need to follow to successfully migrate all the users?

4. If I have to use the ADMT 3 tool, is it reliable? Any other information that I’d need related to this?…

Thanks in advance for your help.

Regards,

Sandeep

This is my reply:

Sandeep,

First I will give you straight answers and then some detail to follow.

1. I would like to migrate all the users from one Active Directory, Say “X” on MS NT to Active Directory, say “Y” on MS 2000/ MS 2003, is this possible to do without using any tool? Migrate might be tough. Copy all users from X to Y for sure. In this though all users will lose password and SID and possibly other attributes.

2. Please provide me some details on the scripts that need to be written to accomplish this.
The script would use the Quest AD cmd-lets to get all the users and all the attributes that you would like to copy over. We would then use that data and create the new users with all the attributes in the new domain.

3. What are the steps I need to follow to successfully migrate all the users?
If you just want to migrate users and not groups or any other objects then you can script this as I said above. If you want passwords and all attributes to migrate the the ADMT is a good tool.

4. If I have to use the ADMT 3 tool, is it reliable? Any other information that I’d need related to this?…
ADMT is a good tool, however, I have not used it very much. Like I said above, if you need all the data then this is a better way to go.

You could write a powershell script or even a batch script if all you want to do is get user information from the old domain and create new users in the new domain. If you want to keep all the users passwords and other object information then the ADMT tool is probably going to be a better option, unless you want to write a lot of code and really dig into AD Objects. If you do not care about any of that and you want to start from scratch then you can certainly write a script to get all the AD User accounts and all attributes that you want to carry over to the new AD  (Y). If you decide that you would like to use scripts for this task then I am more then willing to help you with some basic scripts for this. Have you used Powershell much? Are you familiar with the syntax? If so then you should go download the Quest AD cmd-lets as they will be useful to us in this task. Please let me know how you would like to proceed on this.

In summary I would say that Powershell is an Awesome tool, but in this case, depending on what Sandeep needs, I am not sure that it is the best tool for the task. Powershell is great and comes in handy when your boss says I need to add 30 accounts to AD or I need to modify these 30 accounts or something of that nature. For a Domain Migration I think that Microsoft Utilities may be best.

If you have any other questions please visit http://sysadminsmith.com and click the submit a question link on the right.



February 17, 2009  10:42 PM

File Copy with Powershell

Colin Smith Colin Smith Profile: Colin Smith

I have a friend that I work with that has to copy files out to the same 10 servers anytime our developers create a new report. To do this manually he has to log into the UNC of each server, verify that the server does not already have a report with the same name, if it does he needs to rename it, and then copy the file to the server. He thought that he would be able to script this in powershell and asked me for some help along the way. I think that he has a solution but I decided that this is something that may be handy for many of us Admins. So I went ahead and wrote a script that will do what he needs. I decided to add a few extras in as well. Here is what I ended up with.

#Get list of servers to push new files to#

$servers
=
Get-Content
“d:\test2\servers\servers.txt”

#Set where the new files are located and read them in as a variable#

$newfilepath
=
“d:\test2″

$newfiles
=
Get-ChildItem
$newfilepath
|
where {$_.name
-like
“*.txt*”}

#Get Date and Time Information#

$date
=
Get-Date
-format
MM_dd_yyyy

$time
=
get-date
-format
HH:mm:ss

#Test to see if OUT directory and Log file Exist. If not create them#

if (!(test-path
“d:\OUT”))

{

New-Item
-type
directory
“d:\OUT\”

}

if (!(Test-Path
“d:\OUT\rptmove.log”))

{

New-Item
-type
file
“d:\OUT\rptmove.log”

}

$log
=
“d:\OUT\rptmove.log”

#Start Checking each server to see if it has a file with the same name in the destination path#

foreach ($server
in
$servers)

{

Echo
“########################################################################################” >> $log

Echo
“`n########################################################################################” >> $log

Echo
“Working with Server $server” >> $log

# Ping server to make sure it is available for this task#

$pingresult
=
Get-WmiObject
win32_pingstatus
-f
“address=’$Server’”

if($pingresult.statuscode
-eq 0)

{


write-host
$server
is
available
-background
“green”
-foreground
“black”

Echo
“$server is available” >> $log

$prodfolderpath
=
“\\$server\d$\Reports”

$oldfiles
=
Get-ChildItem
$prodfolderpath
|
where{$_.name
-like
“*.txt*”}

foreach ($newfile
in
$newfiles)

{

$found
= 1

$newrpt
=
$newfile.Name

foreach ($oldfile
in
$oldfiles)

{

$oldrpt
=
$oldfile.name

# If the server has a file with the same name, Rename file with datestamp, copy new file to destination#

if ($newrpt
-eq
$oldrpt)

{

Echo
“`nMatch found for $newrpt” >> $log

Echo
“Renaming $oldrpt to $oldrpt.$date” >> $log

Rename-Item
-path
“$prodfolderpath\$oldrpt”
-newName
“$oldrpt.$date”

Echo
“copy $newrpt to $prodfolderpath\newrpt” >> $log

copy-Item
-path
“$newfilepath\$newrpt”
-destination
“$prodfolderpath”

echo
“moving of file $newrpt is complete on $date at $time” >> $log

$found
= 0



}

}

# if server does not have a file with the same name then move the new file to the server. #

if ($found
-eq 1)

{

echo
“`n$newrpt not found in $prodfolderpath” >> $log

copy-Item
-path
“$newfilepath\$newrpt”
-destination
“$prodfolderpath”

echo
“moving of file $newrpt is complete on $date at $time” >> $log

$found
= 0


}

}

}

else

{


write-host
$server
is
NOT
available. Please
check
server
and
try
again
-background
“red”
-foreground
“black”

Echo
“$server is not available for this operation. Please check server and try again!” >> $log

}

Echo
“`nCompleted Working with $server” >> $log

}

Echo
“########################################################################################” >> $log\

So this script fist gets a list of all the servers that it needs to copy the files to. Lucky for me that all the servers keep the reports in the same location. I then get a list of all the file names that I need to upload to the servers. Then I get Date and Time info so that I can use that in renaming files as well as logging actions. Then I start my loop. First I ping the server that I want to work with. If the server is down I echo a notification of this as well as log it. I then move to the next server in the list. If the server is up then I get a listing of all the files that the server has on it in that folder so I can compare them to the files that I need to copy to the server. Then I compare the files. If I find that the server has a file with the same name as a new file then I rename the file on the server using the datestamp so I will know when the file was last used. I also log that action. Then I copy out the new file to the server. If the server does not have a file with the same name as one that I need to upload I upload that file to the server and log that action as well. This will loop thru as many servers as you want with as many files as you want. In this example I am searching only for .txt files but you do not have to do that. Please let me know if you have any questions about this by leaving a comment or by heading over to http://sysadminsmith.com and clicking on Submit a Question to the right.


February 5, 2009  5:06 PM

Sybase 15 Driver Q and A

Colin Smith Colin Smith Profile: Colin Smith

From my post http://itknowledgeexchange.techtarget.com/dba/sybase-15-upgrade-project/ about my company migrating one instance to ASE 15 I had the following Question as a comment.

hey i need to know about the driver and provider required for Sybase 15.
Have to migrate from sybase12.5.3 to sybase 15.
and what are the corressponding compatibility issues?

The answer to this is that I am still using the Sybase 12.5.x drivers on my machine and have not noticed any issues connecting or while performing any task up to this point. I also suggest, if you want, to install the new drivers that should be included on the client install media. This is where you would go to install Sybase Central and any other client tools. I recommend installing Sybase Central as it can be a good tool to quickly look at a database, its devices, and other properties very quickly.

Thanks for the question and I hope that this helps.


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: