Friday, 30 July 2010

Linux NFS Communication Common Problems

Today, I've been asked some questions about NFS communication problems, the very first was: RPC: Program Not Registered.
This is caused mainly by the fact that NFS service is not running on the server, you can run the service using: "/etc/init.d/nfs start"
For a comprehensive list of error, have a look at: NFS Troubleshooting Guide
Another common problem is permission and access problems, such as: System Error: No route to host.
The resolve this, simply check whether you can ping the server or not, if you can ping, then the problem is with your servers firewall configuration. For a detailed manual on how to configure firewall, have a look at: How To Configure NFS, appendix A. (If you can not ping the server either, refer to the NFS Troubleshooting Guide to find the cause and a workaround to solve it)
In case of firewall blocking, you can simply turnoff the firewall using "service iptables stop". Although this is the easiest way, but also the worst way! You can go further and disable the iptables firewall service from boot time using "ntsysv" command. (Not recommended at all!)
If you would like to read a comprehensive guide about setting up NSF and better understand things, have a look at this manual.

Thursday, 22 July 2010

SQL SERVER – FIX : ERROR Msg 1803 The CREATE DATABASE statement failed. The primary file must be at least 3 MB to accommodate a copy of the model database

When creating new data base, its size should be at least the size of the model database, otherwise the CREATE DATABASE statement fails with this error:
The CREATE DATABASE statement failed. The primary file must be at least 3 MB to accommodate a copy of the model database. (Microsoft SQL Server, Error: 1803)

If you like, you can increase the initial size of your new db to at least the size of model database. If not, you can shrink the model database to reduce its size.

To check the available space of a database you can use:
SELECT name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
FROM sys.database_files;

About shrinking, have a look at:

DDBC SHRINKDATABASE
DDBC SHRINKFILE

Common Confusing Error with SVN Clients

There is an error message in SVN, which is quite confusing:
OPTIONS of '': 200 OK
This error is mostly caused by mistyping the repository address.

Workaround:
Check you typed the address correctly, you can try the address in your browser and check weather you see correct pages. Some SVN server tools such as Visual SVN Server, provide some HTML pages, so that you can log-in and check the repository tree using your browser. One thing to remember, when specifying paths, you should specify the full path to your files in repository server.

Hope this helps!

Monday, 19 July 2010

How to Select Random Records using Transact-SQL

You may need to select some random records from a table, having done this using T-SQL, seems awesome!
It is very simple, e.g. for selecting ten random records:
SELECT TOP 10 * FROM tablename ORDER BY NEWID()
It just works fine!

Not let's see how it works:

The query except the ORDER BY clause, is a very simple select query, the only thing that makes it different, is the ORDER BY clause. We used NEWID() function as order clause. So let's continue our discussion with this function. What does NEWID() do?
It creates a unique value of type uniqueidentifier. To see it in action, execute the following query:
SELECT NEWID()
Each time you execute the above query, you get a unique value of type uniqueidentifier.
Now we come back to our first query (which was for selecting some random records). It works as follows: It selects some records, and for each record, it generates a new unique value, then it sorts the result based on the values of generated unique identifier values. So it looks like you have some randomly selected records! That's all.

Sunday, 18 July 2010

MS SQL Server Installation Problem

Days ago some of my clients reported an error when installing Microsoft SQL Server 2005. The error was:

SQL Server Setup failed to execute a command for server configuration. The error was [Microsoft][SQL Native Client][SQL Server] Cannot add functional unit 'sp_sqlagent_get_startup_info' to component 'Agent XPs'. This unit has been already registered with the component. Refer to the server error logs and Setup logs for detailed error information.

This error is mainly caused by having an incorrect date and time. To solve this issue, simply check your date and time setting and reconfigure it with correct values. That's all!