Recover SQL Server from ‘Suspect’ Status

Last night, I had a power outage and a SQL Server went down. When I rebooted it, the database was in ‘Suspect’ mode. After some quick googling I found a solution.

[code lang=”sql”]
EXEC sp_resetstatus ‘yourDBname’;
ALTER DATABASE yourDBname SET EMERGENCY;
DBCC checkdb(‘yourDBname’);
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DBCC CheckDB (‘yourDBname’, REPAIR_ALLOW_DATA_LOSS);
ALTER DATABASE yourDBname SET MULTI_USER;
[/code]

Posted in sql | Comments Off on Recover SQL Server from ‘Suspect’ Status

Date Diff in PHP

Thanks to Ryan Means, I have an easy way to find the difference between 2 dates/times in PHP.

[code lang=”php”]
<?PHP
define(‘SecInDay’,86400);
define(‘SecInHour’,3600);
define(‘SecInMin’,60);
$totalsec=XXXXXXX; //Replace the X’s with a int value of seconds
$daysarray = explode(".", ($totalsec/SecInDay));
$days = $daysarray[0];
$partdays = fmod($totalsec, SecInDay);
$hoursarray = explode(".", ($partdays/SecInHour));
$hours = $hoursarray[0];
$parthours = fmod($partdays, SecInHour);
$minarray = explode(".", ($parthours/SecInMin));
$min = $minarray[0];
$sec = fmod($parthours, SecInMin);
echo "days " . $days . " ";
echo "hours " . $hours . " ";
echo "minutes " . $min . " ";
echo "seconds " . $sec . " ";
?>
[/code]

Posted in php | Comments Off on Date Diff in PHP

MSDTC event 53258

I work with windows virtual machines a LOT.

One thing that I have noticed is that if a windows VM that has been copied, NewSided (had NewSid run on it), and has been added to a domain, it can generate a “MSDTC Event 53258” frequently.

EventID: 53258
MS DTC could not correctly process a DC Promotion/Demotion event. MS DTC
will continue to function and will use the existing security settings. Error
Specifics: d:srvrtmcomcomplusdtcdtcadmeuiname.cpp:9280, Pid: 1148
No Callstack,
CmdLine: C:WINDOWSsystem32msdtc.exe

EventID: 53258
MS DTC could not correctly process a DC Promotion/Demotion event. MS DTC
will continue to function and will use the existing security settings. Error
Specifics: %1

After a bunch of time googling, I found a solution that will make this problem go away:

1. Run the Component Services MMC snap-in: Start -> Administrative Tools ->
Component Services.
2. Open Console Root -> Component Services -> Computers.
3. Right-Click on My Computer (in the Component Services window) and click Properties.
4. Open the MSDTC tab and click OK.
5. Close the Component Services window.
6. From a Command Prompt type net stop msdtc && net start msdtc.

Now you won’t get the MSDTC errors in the event log.

I believe that this process resets the computer name that MSDTC tries to connect to. In my case it was trying to connect to the computer named “base-vm”, but that computer no longer exists.

Posted in windows | Comments Off on MSDTC event 53258

Telnet to test SMTP

Since I wrote up testing pop3 with telnet, I thought I would also write about how you can test SMTP with telnet.

From a command line in windows:

telnet

open IPofSmtpServer 25

220 mail.server.domain Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at . . . .

ehlo test.com

(test.com is the FROM domain)

250 OK

mail from:me@myDomain.com

250 2.1.0 me@myDomain.com. . . .Sender OK

rcpt to:you@yourDomain.com

250 OK – you@yourDomain.com

DATA

354 Start mail input; end with <CRLF>.<CRLF>

Subject: The Subject of the message.

Press enter TWICE.

The body of the message goes here.

Press enter.

Enter a single period (.) and press enter once more.

250 2.6.0 <………………….> Queued mail for delivery

Quit

221 2.0.0 mail.yourDomain.com Service closing transmission channel

 

Lots more SMTP info.

Posted in troubleshooting | Comments Off on Telnet to test SMTP

Telnet to test pop3

I found an easy way to test a pop3 connection today. It is a little known tool called telnet (It’s not really little known, but I never thought of using it for pop3, so in my mind it is little known for that purpose 😉 ).

From a command line in windows:

telnet NameOfPop3Server 110

user username

pass password

list

You will see a list of email in your mailbox

retr msgNumber

You will see the email you requested

quit

 

More POP3 commands:

stat – Returns the number of messages in mailbox and size of mailbox

dele msgNumber – Marks message msgNumber for deletion.

noop – Doesn’t do anything, just returns a positive response.

rset – Unmarks any messages that are marked for deletion.

top msgNumber numLines – Returns the header info and numLines of the body of message msgNumber.

uidl msgNumber – Returns the message number and the messages Unique ID Listing.

 

Note: If the telnet session ends for any reason other than using the quit command, messages marked for deletion will not be deleted.

Posted in troubleshooting | Comments Off on Telnet to test pop3

Unblock “unsafe” attachments in Outlook

So I went to open the .exe file that I sent myself yesterday and I found out that Outlook 2007 will not let you download “unsafe” attachments (unsafe meaning “Any file with an executable extension”). This bothered me, so I googled how to disable the feature.

Sadly you cannot completely disable it, you can only add file types that you want to download anyway.

Open the registry editor (Click Start->Run and type regedit)

• Browse to:

Outlook 2007

HKEY_CURRENT_USERSoftwareMicrosoftOffice12.0OutlookSecurity

Outlook 2003

HKEY_CURRENT_USERSoftwareMicrosoftOffice11.0OutlookSecurity

Outlook 2002

HKEY_CURRENT_USERSoftwareMicrosoftOffice10.0OutlookSecurity

Outlook 2000

HKEY_CURRENT_USERSoftwareMicrosoftOffice9.0OutlookSecurity

 

• Add a new String value named: Level1Remove

• Edit the value and add the extension(s) that you would like to allow (use a ‘;’ as a delimeter)

Ex: .exe or .bat;.exe;.mst

 

• Restart Outlook (You don’t need to restart the computer)

Posted in outlook, windows | Comments Off on Unblock “unsafe” attachments in Outlook

Date and Time in .bat

I will skip right to the good stuff.

Here are some easy Date/Time variables for a batch file.

[code lang=”powershell”]
@echo off
::Day
set d=%date:~7,2%
set DD=%date:~0,3%
::Month
set m=%date:~4,2%
::Year
set YY=%date:~10,4%
set y=%date:~12,2%
::Time
set H=%time:~0,2%
set i=%time:~3,2%
set s=%time:~6,2%
set ms=%time:~9,2%
::
echo d: %d%
echo DD: %DD%
echo m: %m%
echo YY: %YY%
echo y: %y%
echo H: %H%
echo i: %i%
echo s: %s%
echo ms: %ms%
[/code]

Will Output

[code lang=”text”]
d: 24
DD: Wed
m: 02
YY: 2010
y: 10
H: 14
i: 36
s: 32
ms: 18
[/code]

Hope it helps.

Posted in bat | Comments Off on Date and Time in .bat

Changing Hostname and IP in Red Hat linux

So I am new to administrating Linux servers so I am going to post about all the simple things that a noob Linux admin would want to know.

I built a base Linux vm in Microsoft Virtual Server 2005. If I copy the vhd file from that base install, what do I need to change before I add it to the production environment?

** Note: I am using a Red Hat Linux OS (CentOS v5.3).

Change the Hostname

First we need to change the computer’s Hostname.

To change the computer’s Hostname, edit these files:

/etc/hosts:

[code lang=”html”]
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
10.10.81.46 server01.theitguyrox.com
[/code]

/etc/sysconfig/network:

[code lang=”html”]
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server01.theitguyrox.com
[/code]

For the Hostname change to take effect, you need to reboot the computer.

Change the IP Address

To change the IP address of a CentOS 5.3 server, edit:

/etc/hosts:

[code lang=”html”]
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
10.10.81.46 server01.theitguyrox.com
[/code]

/etc/sysconfig/network-scripts/ifcfg-eth*:

[code lang=”html”]
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:03:ff:05:46:7f
NETMASK=255.255.0.0
IPADDR=10.10.81.46
GATEWAY=10.10.1.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
[/code]

Add DNS Servers

Finally we need to add some DNS servers since we won’t get them from DHCP any more.

To add the DNS Servers, edit:

/etc/resolv.conf:

[code lang=”html”]
nameserver 10.10.10.10
nameserver 10.10.10.20
[/code]

To make the changes take effect, you need to either reboot, or restart the network service.

To restart the network service:

[code lang=”html”]
/etc/init.d/network restart
[/code]

or:

[code lang=”html”]
service network restart
[/code]

Well that’s it for today.

Posted in linux | Comments Off on Changing Hostname and IP in Red Hat linux

First Time

So, I decided to hop on the wagon and start a blog. I have been a part of the blogging community for years, mostly reading, sometimes commenting, but never posting. Today is the day that I am going to change that.

I am mainly writing this because I am a nerd with a lot of stuff going on in my mind. I am going to use WordPress to get some of my nerdy thoughts out of my mind, and possibly help some of the people of the internet with my nerdy thoughts.

This is my motto for now.

Thanks.

Posted in Uncategorized | Comments Off on First Time