jueves, 27 de mayo de 2010

Create a Loopback filesystem from a file. Linux

If you need to have a new filesystem to test some operations on the server or you want a more flexible way of performing snapshots other than volume management, you can use loopback filesystems.

First Step. Create the Loopback file
dd if=/dev/zero of=/apps/test/loop db=1024 count=30720
This will create a 30 Mb file.

Second Step. Create a Loopback device.
First of all we will type
losetup -a
to list the current used devices.
losetup /dev/loop0 /apps/test/loop

Third Step. Create and mount a device.
mkfs -t ext3 -m 1 -v /dev/loop0
mkdir /virt_drive
mount /dev/loop0 /virt_drive



miércoles, 26 de mayo de 2010

Using NTP for time sync

What is NTP?
It's a time sync protocol that allows IT infrastructures to be one in time.
Why i need it?
When time sync it's a critical factor for the services to work. One clear example is Kerberos and Active Directory. SSO Web infrastructures like Oracle Access Manager require exact time sync in all components, all over the servers.
How does it work?
There are two actors in every ntp scenario:
- Client: is the final consumer of the service, which adecuates it's internal clock to the time set on the server
- Server: It's the reference for the time corrections and synchronization. But also it can act as a client for other servers which are authoritative sources for time sync, like NASA atomic time servers, etc

First of all: Let's configure it.
Configuration is quite simple:
- Server side:
+ Authoritative source: the server will be the main NTP server. No other servers will be requested for time sync.
+ Slave model : server will act as server for the client infrastructure, but also will contact
other time servers in order to have a more accurate referal.

Files for a basic configuration on a Linux NTP server:
+ ntp.conf:
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0
# local clock
#fudge
127.127.1.0 stratum 10

# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift

After that we will start the daemon server.

On a Windows 2003 Server with AD acting as NTP server:
Please check the following registry key setting:
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/
TimeProviders/NTPserver/Enabled=1


Next step with Linux

To test the service we will use
ntpdate -d 132.236.56.250
After that we will need to perform an initial sync , with the command:  
ntpdate 192.168.56.101
Once we have both machines synchronized we will start a new task on cron with the command
crontab -e
* * * * * /usr/sbin/ntpdate -s -b -p 8 -u 192.168.56.101


Next step with Windows
Please follow this procedure
Some final words.
This tip is an entry point for NTP configuration, if you need further info, please consider reading other
resources like the following ones:
- http://www.akadia.com/services/ntp_synchronize.html
- http://tldp.org/LDP/sag/html/index.html
- http://www.meinberg.de/english/sw/ntp.htm