Determining a devices WWID in Linux

For multipath drivers connecting to storage area networks (SAN), it is useful in your /etc/multipath.conf to blacklist devices. This prevents the multipath driver from attempting to use the device(s).

To find out a drive’s WWID, run the following command:

>scsi_id -g -u -s /block/sda

This will return a WWID. On my system it was returned as 36001e4f034bf55000f98fe8606dc88df.

Now you can put this in the blacklist section of /etc/multipath.conf as:

blacklist {
devnode “^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*”
devnode “^hd[a-z]”
devnode “^sda”
devnode “^sda[0-9]”
devnode “^sdb”
devnode “^sdb[0-9]”
wwid    “36001e4f034bf55000f98fe8606dc88df”
device {
vendor DELL
product “PERC|Universal|Virtual”
}
}

This will now prevent the multipath driver from attempting to manage /dev/sdc.

Finding a count of files in a directory

In Linux, you can count all of the files in a directory, of a given type.

To do this run:

>find . -maxdepth 1 -type f -name “*.gz” | wc -l

If you want to count all of the gzipped files in all directories below your current directory. Run the same command without the -maxdepth:

>find . -type f -name “*.gz” | wc -l

Everything relies on the wc command, which is short for word count. We are counting the line by line output from the find command.

If you want to count the number of directories, try this:

>find . -type d | wc -l

Just remember to subtract 1 from the output. Linux will include the current directory (.) as a directory.

Starting a user’s VNC server automatically on Linux

On some Linux systems, it can be advantageous for users to have a way to login to a console. Unfortunately, if they do not have physical access to the machine, there needs to be a way to do it remotely. Fortunately on Linux, there is Virtual Network Computing (VNC). VNC can be set up as a server and I will outline the steps necessary to complete this task.

First, ensure that vncserver is installed on your system. For Red Hat systems type:

>yum list vnc-server

If you see the following message:

Loaded plugins: rhnplugin
Error: No matching Packages to list

You will  need to install vncserver. Using Yum again:

>yum -y install vnc-server

We can now begin configuring VNC. We are going to do this for two users, root and myuser. Each user will access their virtual desktop from separate Internet Protocol ports. Vtxinst will use port 5801 and root will use port 5802.

We first need to edit /etc/sysconfig/vncservers. On line that has

# VNCSERVERS=”2:myusername”

Change it to

VNCSERVERS=”1:myuser 2:root”

Save the file. Now we need to prime VNC to setup its supporting files correctly. Login first as root, then myuser and issue the following command:

>vncserver

You will be prompted for a password if this is the first time this user has started VNC. Then run the following command to stop vncserver:

>vncserver -kill :1

Next let’s edit the user’s ~/.vnc/xstartup so that we use the gnome desktop instead of X windows. In the user’s directory, edit the file ~/.vnc/xstartup and uncomment the following 2 lines by removing the # so that the two lines look like the following:

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

Finally, enable vncserver on startup with the following command:

>chkconfig –levels 35 vncserver on

Now, next time you reboot, VNC server will start automatically. If you don’t want to reboot, then run:

>service vncserver start

And VNC server will now be running!

Auto commit for MySQL databases

In corporate database systems, it is generally preferred to build transaction stacks. This allows for having multiple database statements run and be finally committed if everything is ok. In MySQL, auto commit is on by default; which means that every statement is instantly committed. To check the value of auto commit, run the following MySQL command:

mysql>select @@autocommit;

So in order to turn off auto commit, run the following command in MySQL:

mysql>SET autocommit=0

If you want auto commit turned off permanently, we need to edit your my.cnf file. In the [mysqld], add the following line:

init_connect='SET autocommit=0'

Restart MySQL and you are now ready to do full transaction processing.

Error in /etc/fstab stopping Linux boot

In Linux, there are times when you need to edit your /etc/fstab file to add a new disk. Sometimes, you may accidentally edit the wrong information which will cause Linux to not boot. Usually though, Linux plays nice and boots to a command prompt. Unfortunately, you are now booted into a read-only filesystem so you are unable to save your /etc/fstab.

What you need to do is first set the operating system to read/write (r/w). To do this run the following command:

>mount -o remount,rw /

If /etc is on a different volume, then run this command (replace /dev/sda1 with your /etc volume):

>mount -t ext3 /dev/sda1 / -o remount,rw

Some people have complained about kernels that are not compiled to support the reldiratime option. If you are still having trouble editing and saving /etc/fstab, try this:

>mount -o remount,defaults /

You should now be able to edit and save your /etc/fstab file and reboot and have Linux back again!

Restoring all reports to Jasper Server

Sometimes it is necessary to restore an entire copy of Jasper Reports generic lipitor. This can only be done by first removing all of the existing entries in the Jasper Reports server to be restored to.

First, on the source machine, backup the entire Jasper Reports server by running the following commands:

> cd /home/jasper/jasperserver-3.5/scripts
> /home/jasper/jasperserver-pro-3.5/scripts/js-export.sh –everything –output-dir /home/jasper/jasperserver-pro-3.5/scripts/js-export.$HOSTNAME.`date +\%y\%m\%d`

Then copy the backup directory to the destination machine:

> scp -pr /home/jasper/jasperserver-pro-3.5/scripts/js-export.$HOSTNAME.`date +\%y\%m\%d` destinationMachine:/home/jasper/jasperserver-pro-3.5/scripts

Now, on the destination Jasper Server, run the following commands:

> cd ~/jasperserver-3.5/scripts/mysql
> ./jasper_init.sh
> cd ..

Finally, do the restore by running the following command:

> ./js-import.sh –input-dir js-export.<TheHostNameOfTheSourceMachine>.`date +\%y\%m\%d`

Now just be sure to update your Data Sources in the Jasper web site on the destination machine.

Enabling Apache support for pretty permalinks in WordPress

In WordPress, there is a feature called PermaLinks. These create URL’s that are better searched by Google. So instead of getting a URL like http://example.com?id=454, you get something like http://example.com/enabling-apache-support-for-pretty-permalinks-in-wordpress. Now the search engines will see a URL that they can parse for information, rather than an arbitrary number.

Enabling Apache support for what is known as address rewriting is accomplished by modifying your httpd.conf file. Open the file and look for the line that says:

<Directory “/var/www/html”>

In this section there will be a line:

AllowOverride None

Change this line to:

AllowOverride All

Save the httpd.conf file. Then restart Apache.

Now when you click, Enable Permalinks in WordPress, you will have a search engine friendly blog.

Linux log error – Could not receive trustdoms : xxx Time(s)

When using Samba with Linux, Red Hat Enterprise Linux attempts to connect to a Windows server that acts as the domain controller. This is called a trustdom; as Linux is attempting to build a trust relationship with a Windows Domain Controller. You will see the following message in your log:

——————— samba Begin ————————

**Unmatched Entries**

nsswitch/winbindd_util.c:trustdom_recv(243) Could not receive trustdoms : 288 Time(s)

———————- samba End ————————-

To stop this error message, you need to stop the winbind service. To do this, run the following commands:

chkconfig winbind off
service winbind stop

This will ensure that upon reboot, the service does not start. And the second command ensures that the service is stopped immediately.

Check your log tomorrow to ensure that you are no longer receiving this message.

QEMU seems to make Windows read-only

The Problem:

The server is acting all weird, thought i might raise a flag to you:
– after you said you attached the larger drive/partition, nothing changed
– when i logged on as administrator tonight, it acted like ive never logged on before
– the profile is fucked up somehow; i dont have any icons, no quick launch, none of the items i installed, etc.
– for some weird reason, i can’t download any files using a web browser when on the server.  i also cannot ftp any files to the server.  when i use ie to download an attachment from gmail for example, it can’t do it.  when i tried to download firefox, i also got an error about contacting the server.  very weird.  also, with full permissions, and full write access, i am unable to write any files to the server via ftp either.  me = confused.

Did you refresh the instance or something like that?

The Solution:

In this instance, a new virtual drive was added to a Windows 2003 Server running under a QEMU virtual machine on Linux. QEMU most likely has the virtual instance locked read-only because the new virtual drive has not been allowed to initialize itself under Windows. This stops Windows from being able to write to any file.

In this case the problem was resolved by forcing a power down on the instance. Then under the setting for the virtual machine on the Hardware tab, check that the new drive is in the list of hardware. If so, then start the instance. Log in as Administrator in Windows. Go to Control Panel – Administrative Tools – Computer Management. Once it opens, select Disk Management, and initialize and format the new drive.

If from above the new hardware is not in the list of Hardware Devices. Try reconnecting to the virtual disk you created, or just create a new virtual disk and attach it to the Windows instance.

Windows service failure while running in a QEMU virtual instance

If you are running Windows under QEMU and see Event ID 7000’s like these below–

If you get this Description:

“The Parallel port driver service failed to start due to the following error:
The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.”

Then you have the ParPort service not starting. This happens if you upgrade your W2K3, W2K, or NT server from hardware (motherboard) that HAD a Parallel Port, but are now on a new motherboard that has no Parallel Port.

The fix is simple:
1. Open Regedit and go to–
HKLM\System|CurrentControlSet\Services\Parport
2. Edit the Start key and change the value to 4. Changing the value to 4 will “disable” the service.
3. Reboot the server

You should no longer get that annoying popup dialog when Windows starts.