Linux overwrites DNS resolver /etc/resolv.conf

Linux will overwrite your /etc/resolv.conf in 3 cases. If you have:

  1. Network Manager enabled.
    Disable the Network Manager by turning it off with the following commands:
    >service NetworkManager stop
    >chkconfig NetworkManager off        

  2. DHCP enabled.
    dhcpd will overwrite your /etc/resolv.conf when it acquires an IP address. Convert to a static IP if you are in control of the network.
  3. DNS1, DNS2 or any other DNS# entries in any of your network interface configurations.
    If you are the administrator of this machine, check every file matching the following pattern:
    >find /etc/sysconfig/network-scripts/ifcfg-*
    and look for any DNS# entries in every matching file. If you find any DNS# lines, and if you are root, remark the lines by inserting a # sign at the beginning of the DNS# line.
    Save the file(s).
    Then run –>
    >service network restart

Once you’ve gone through these 3 items, you should be able to now edit and save your /etc/resolv.conf file. Verify that the file no longer is being overwritten. Just execute >cat /etc/resolv.conf a few times for a few minutes and verify the file is no longer changing. Also >reboot the machine to be extra sure nothing changes in the /etc/resolv.conf file.

Be the first to comment - What do you think?  Posted by David Dietrich - January 14, 2010 at 7:45 pm

Categories: Domain Name Service (DNS), Linux   Tags: ,

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.

Be the first to comment - What do you think?  Posted by David Dietrich - August 10, 2009 at 10:28 am

Categories: Linux, Storage Area Network (SAN)   Tags: ,

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.

Be the first to comment - What do you think?  Posted by David Dietrich - July 22, 2009 at 1:22 pm

Categories: Linux   Tags:

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!

Be the first to comment - What do you think?  Posted by David Dietrich - July 20, 2009 at 1:33 pm

Categories: Linux, Remote Access, Security   Tags: ,

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.

Be the first to comment - What do you think?  Posted by David Dietrich - July 2, 2009 at 2:08 pm

Categories: Linux, MySQL, Windows   Tags: ,

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!

Be the first to comment - What do you think?  Posted by David Dietrich - June 26, 2009 at 10:11 am

Categories: Administration, Linux   Tags:

Changing the host name in IBM WAS

Many times in a virtual environment, it is advantageous to be able to change the host name. But if you have a virtual guest with IBM WAS installed, cloning the guest may result in the new guest being unable to stop the server, run CORBA properly, or gain access to your message queues within WAS. Therefore, you need to reset the host name for WAS.

To do this, go to the wsadmin.sh prompt. If you don’t know where wsadmin.sh is, run >locate wsadmin.sh. The cd into the directory that is returned. To start WAS admin, type the following commands (assuming your server is called server1 and the node is named oldMachineNameNode01):

./wsadmin.sh -profile server1 -lang jacl

Once inside the WAS admin tool, run the following commands:

wsadmin>$AdminTask changeHostName { -nodeName oldMachineNameNode01 -hostName newwasVMmachineName };
wsadmin>$AdminConfig save
wsadmin>exit

Restart WAS, and your new machine name should work fine.

Be the first to comment - What do you think?  Posted by David Dietrich - June 18, 2009 at 3:05 pm

Categories: WebSphere   Tags: ,

Updating a database option in DB2

Sometimes after a database has been created, you may want to move where the default log path is. Or you may want to change  DB2 places the log path in the home directory, and you may want to have the logs stored on another storage device.

Login as the DB2 adminstrative user, then type the following command to change your log path:

> db2 UPDATE DB CFG FOR MyDB USING <OptionName – ex., NEWLOGPATH> <Value – ex., /db2data/AnyDirectory/NODE0000/logdir>

Stop and restart DB2 (db2stop force and db2start). Your new log path is now active.

Be the first to comment - What do you think?  Posted by David Dietrich - May 20, 2009 at 6:58 pm

Categories: DB2   Tags: ,

Updating the log path in DB2

Sometimes after a database has been created, you may want to move where the default log path is. DB2 places the log path in the home directory, and you may want to have the logs stored on another storage device.

Login as the DB2 adminstrative user, then type the following command to change your log path:

> db2 UPDATE DB CFG FOR MyDB USING NEWLOGPATH /db2data/AnyDirectory/NODE0000/logdir

Stop and restart DB2 (db2stop force and db2start) and the your new log path will now be active.

Be the first to comment - What do you think?  Posted by David Dietrich - at 3:25 pm

Categories: DB2   Tags: ,

Restoring all reports to Jasper Server

Sometimes it is necessary to restore an entire copy of Jasper Reports. 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.

Be the first to comment - What do you think?  Posted by David Dietrich - at 9:10 am

Categories: Jasper Reports, Linux   Tags:

« Previous PageNext Page »