Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

Tuesday, December 6, 2011

Simple log/file rotation

I wanted a nice way to do an hourly backup of a mysql database and only keep a days worth.

In the past I have written scripts that would check how many files were there or used find to delete
old only.

I wondered if I could use logrotate to handle this since it is installed on most systems and is simple to use.
Unfortunately it doesn't understand the term hourly and only does daily and monthly.

I wrote my backup script and created a simple logrotate.conf file but left out the section that said
how often to run.

[root@server1 bin]# cat backup-www-db.logrotate
/var/database_backup/mysql_dump.sql {
# hourly
rotate 24
compress
delaycompress
missingok
create 640 root adm
}

Then I just told the backup script to run logrotate as the first thing it does giving it that config file:
/usr/sbin/logrotate /usr/adm/bin/backup-www-db.logrotate

It rotates the previous database dump and compresses them.

It only runs when the script runs so I set cron to run every hour and we have a nice simple solution.

Cloning Redhat Servers in Vmware and networking

After cloning a Redhat/Centos box in vmware and booting it, the network refused to come up.

I found that udev had the MAC's for the old server hard coded and did not clean them up on the reboot.

Commenting out the old lines and rebooting forced udev to recreate new entries and away we went.

{ krkardlnxapp2 } [ /etc/udev/rules.d ]$ cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:00:c9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:08:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:b5:08:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Tuesday, July 7, 2009

How to add a disk to a vmware linux guest without rebooting

I have a whole series of linux guests running on some ESX hosts off NFS shares.

Today I wanted to add another disk to a running guest and couldn't reboot it.
ESX let me add the disk but the CentOS 5.3 guests didn't see it automatically.

I ran this command:
echo - - - > /sys/class/scsi_host/host0/scan

"That is echo dash space dash space dash /sys/class/scsi_host/host zero /scan"

and then the disk showed up under fdisk -l

Put a new LVM on it, added a filesystem, and mounted it.

Thursday, June 18, 2009

NFS Locking Problem

I had a few users complain about not being able to start Firefox and other apps from their NFS mounted home directory. I started looking on the server and saw that nlockmgr didn't show up in rpcinfo -p and there were "kernel: lockd: cannot monitor" entries in the logs.

Restarting the nfslock service didn't help.
After digging through with strace, etc and a little searching I figured out that we were hit with this bug:

https://bugzilla.redhat.com/show_bug.cgi?id=453094

The only fix is a reboot.

After the reboot things are back to normal.

Off to patch.

Thursday, May 21, 2009

Ruby on Rails Application

I am looking at the PowerDns on Rails front end for a Power DNS backend. The PowerDNS on Rails requires Ruby on Rails so I started looking into how to get it running on CentOS 5.3.

After downloading and installing the app, I tested it via running:

ruby script/server

which starts up a small web browser on port 3000.

I also had to delete the index.html file so the application was accessible from the root of the webserver and all the links worked.

Once it was tested, I wanted to make the installation more robust and permanent. I found this great tutorial to help wrap Mongrel Cluster and Apache around the app.

Ads by AdGenta.com