Friday 8 April 2011

Moving MS SQL TEMPDB

If you need to move the location of the tempdb data or log files you can use the following:

This tells you where everything is now:

USE TempDB
GO
EXEC sp_helpfile
GO

This sets the new location for the data and log file. If you want you can move just one or both files.

USE master
GO
ALTER DATABASE TempDB MODIFY FILE
(NAME = tempdev, FILENAME = 'd:\newlocation\tempdb.mdf')
GO
ALTER DATABASE TempDB MODIFY FILE
(NAME = templog, FILENAME = 'e:\newlocation\templog.ldf')
GO

You must restart MS SQL service after this. This will automatically create the files in the correct location for you.

If you got the wrong path and the service is not starting then you need to follow the below steps:

Restart SQL Server with only the master database.
NET START MSSQLSERVER /f /T3608

Using SSMS or SQLCMD, execute the ALTER DATABASE commands to move the tempdb files.
ALTER DATABASE tempdb MODIFY FILE (NAME=tempdev, FILENAME='new path\file')
ALTER DATABASE tempdb MODIFY FILE (NAME=templog, FILENAME='new path\file')
(Repeat for all tempdb files if you have multiple data files)

Stop SQL Server and restart it normally.

Wednesday 6 April 2011

Restricted SSH connection

If you want to allow a user to only execute certain commands on a server which they have autologin ssh access to, you can acheive by using the following.

The below shows how to only allow user to run svn specific commands via their ssh autologin access.

insert the following in the relevant users authorized_keys file ni the users home/.ssh

command="svnserve -t -r / --tunnel-user=username",no-port-forwarding,no-agent-forwarding,no-X11-forwarding ssh-dss AAAAB3....rp9vp9Q== username@hostname