Free Domain Sign up for PayPal and start accepting credit card payments instantly.

Saturday, August 13, 2011

SysLogD

Features:
1. Handles logging
2. Unix Domain Sockets (/dev/log)
3. Internet Sockets (UDP:514)
4. Ability to log to local and remote targets

Implented as 'sysklogd' package


Primary configuration file: /etc/syslog.conf

Standard syslog.conf file contains:
1. Rules
a.facilities -> applications/daemons/network device/etc.
b. levels -> Importance of message
Range: 0-7
7 = emergency (less information)
6 = alert
5 = critical
4 = error
3 = warning
2 = notice
1 = info
0 = debug (more information)

2. Targets
a. file - /var/log/messages
b. tty - /dev/console
c. remote hosts - @IP_ADDR_of_REMOTE_HOST

'*' = catchall/wildcard to mean any facility or level
'.none' = exclusion rule


'man syslog.conf' to learn about the support facilities.levels

Task:
1. Enable UDP logging for remote Cisco gateway (192.168.75.1)
a. netstat -nul | grep 514 - reveals UDP:514 listener
b. nano /etc/sysconfig/syslog
b1. 'SYSLOGD_OPTIONS="-r"'
c. restart syslog and confirm UDP:514 listener
c1. confirm using 'netstat -nul | grep 514'
d. Configure the router using facility 'local0' and level 'info'
e. configure /etc/syslog.conf to accept 'local0.info'
f. restart or reload 'syslog'

CRON

Features:
1. Scheduler
2. Rules (Cron entries) are based on times:
a. minute (0-59)
b. hour (0-23)
c. day of the month (1-31)
d. month (1-12)
e. day of the week (Sun,Mon,Tue, etc. OR 0-7)
f. command to execute (shell, perl, php, etc.)
3. Wakes up every minute in search of programs to execute
4. Reads cron entries from multiple files
5. Maintains per-user and system-wide (/etc/crontab) schedules

/etc:
cron.d/
cron.deny - denies cron execution by user
cron.monthly/ - runs jobs monthly
cron.weekly/ - runs jobs weekly
cron.daily/ - runs jobs daily
cron.hourly/ - runs jobs hourly
crontab - contains system-wide schedules

Note: '*' wildcard in a time column means to run for all values

Per-user Crontabs:
Stored in: /var/spool/cron

Task:
1. Create a cron entry for the user 'student1'
a. su student1
b. crontab -e
c. create an entry, minus the name of the user

Note: 'crontab -l' - enumerates per-user cron entries


System-wide Crontab:
Stored in: /etc/crontab

Task:
1. Create a cron entry in: /etc/crontab

Note: 'crontab -l -u username' - enumerates per-user cron entries

Sunday, December 19, 2010

YUM Configuration

Features:
1. The ability to centralize packages (updates)

Installation & Setup:
1. Install 'createrepo*rpm'
2. Setup directory structure
a. /srv/www/Linuxtutorial.com/RH5/yum

3. Run 'createrepo /srv/www/Linuxtutorial.com/RH5/yum'

4. Publish the yum repository using HTTP

5. Configure yum client to use HTTP to fetch the RPMs
a. /etc/yum.conf
a1. ###Included as our first repository on the SUSE box###
[0001]
name=Linuxtutorialsuse1
baseurl=http://192.168.75.100/RH5/yum

Note: Ensure that about 3GBs are available for the yum respository


tar -cjvf yum_metadata.bz2 repodata

Yum Usage:
1. Search for packages
a. 'yum search gftp'

2. Install packages - Requires RedHat GPG Key for RPMs
rpm --import http://192.168.75.100/RH5/i386/RPM-GPG-KEY-redhat-release
a. 'yum -y install gftp'
b. 'yum -y install gftp dhcp' installs 2 packages

3. Remove Package
a. 'yum -y remove gftp'

RPM

Features:
1. Provides package management
a. Query
b. Install
c. Uninstall
d. Upgrade
e. Verify
2. Auto-verifies packages using GPG, MD5, SHA1SUMs
3. Automatically reports on unresolved dependencies

'rpm'

Query:
1. rpm -qa - dumps all installed packages
2. rpm -qa | wc -l - this dumps all packages and provides a count
3. rpm -qa | grep -i nano
4. rpm -qi nano - dumps info. about the 'nano' package as it's recorded in the local RPM database
5. rpm -qf /usr/bin/nano - dumps package membership info. for the 'nano' file
6. rpm -qpi http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm - dumps info. about the uninstalled 'dhcp' package, which resides on the repository
7. rpm -ql package_name - returns all included files


Verify:
1. rpm -Va - verifies ALL packages on the system, returning info. only if there are discrepancies from the original installation

2. rpm -Vf /usr/bin/nano

Task: Change '/usr/bin/nano' then verify

SM5....T /usr/bin/nano

S(file size), M(mode or permissions), 5(MD5), T(mod time)
3. rpm -Vp nano


Install (Does NOT overwrite previous package):
Note: Use this method to install a new version of the kernel
1. rpm -ivh *.rpm
2. rpm -ivh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm



Upgrade (Installs or overwrites existing package):
1. rpm -Uvh *.rpm
2. rpm -Uvh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm

Freshen (Updates an existing package):
Note: Will NOT install the package, if it doesn't exist locally

1. rpm -Fvh *.rpm - freshens the current version of a package


Removal:
1. rpm -ev *.rpm - removes a pacakge
Note: removal process considers dependencies and will complain if the removal will break 1 or more packages. To get around this, use '--nodeps' option with 'rpm -ev --nodeps *.rpm'

2. rpm -ev gftp


Package Management GUI:
1. Add/Remove Software
2. system-config-packages

RAID

Features:
1. The ability to increase availability and reliability of data


Tasks:
1. Create a RAID-1 Device (/dev/md0..n)
a. fdisk /dev/sdb - to create usable raw partitions
b. partprobe /dev/sdb - to force a kernel update of the partition layout of the disk: /dev/sdb
b. mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb5 /dev/sdb6
c. cat /proc/mdstat - lists active RAID (md) information
d. mke2fs -j /dev/md0 - overlays a file system on the RAID device
e. mount /dev/md0 /raid1
f. update: /etc/fstab

Note: use 'mdadm --query /dev/md0' to get information about a RAID device


Note: You may create RAID volumes/devices on a single or on multiple disks
Ideally, your RAID volumes should span multiple physical disks to improve:
a. reliability
b. performance
c. availability

2. Remove the RAID-1 device
a. umount /dev/md0
b. mdadm --manage --stop /dev/md0

3. Create a RAID-5 Volume
a. fdisk /dev/sdb - to create a partition number 7
b. partprobe /dev/sdb - to update the kernel's view of the partition table
c. mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb5 /dev/sdb6 /dev/sdb7
d. watch cat /proc/mdstat - refreshes every 2 seconds
e. Overlay a file system: mke2fs -j /dev/md0
f. mount /dev/md0 /raid5
g. Test I/O to RAID-5 device
h. Update: /etc/fstab

Logical Volume Management (LVM)

Features:
1. Ability to create volume sets and stripe sets
2. LVM masks the underlying physical technology (ATA,ATAPI,IDE,SCSI,SATA,PATA,etc.)
3. LVM represents storage using a hierarchy:
a. Volume groups
a1. Physical volumes (/dev/sda2, /dev/sdb2, etc.)
b. Logical Volumes
b1. File systems
3. LVM physical volumes can be of various sizes
4. Ability to resize volumes on the fly

Note: Volume groups join: physical volumes (PVs) and Logical Volumes (LVs)


6 Steps to setup LVM:
1. Create LVM partitions via fdisk or parted
a. fdisk /dev/sda, /dev/sdb, /dev/sdc
b. n
c. p
d. +10G
e. t - change to type '8e' (LVM)
f. w
g. partprobe /dev/sda

2. Create Physical Volumes using 'pvcreate'
a. pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3

3. Create Volume Groups using 'vgcreate'
a. vgcreate volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3
Note: Volume groups can be segmented into multiple logical volumes

4. Create one or more Logical Volumes
a. lvcreate -L 10GB -n logvolvar1 volgroup001
b. lvcreate -L 10GB -n logvolusr1 volgroup001

5. Create File system on logical volume(s)
a. mke2fs -j /dev/volgroup001/logvolvar1
b. mke2fs -j /dev/volgroup001/logvolusr1

6. Mount logical volume
a. mkdir /var1
b. mount /dev/volgroup001/logvolvar1 /var1
c. mkdir /usr1
d. mount /dev/volgroup001/logvolusr1 /usr1


Note: Be certain to update: /etc/fstab so that volumes are mounted when the system reboots

3-tiers of LVM display commands include:
a. pvdisplay - physical volumes - represent raw LVM partitions
b. vgdisplay - volume groups - aggregate physical volumes
c. lvdisplay - logical volumes - file systems - mount here


Rename of Logical Volume:
1. lvrename volume_group_name old new - used to rename volumes

Task: Rename 'logvolvar1' to 'logvolopt1'
a. lvrename volgroup001 logvolvar1 logvolopt1
Note: LVM is updated immediately, even while volume is mounted
However, you must remount the logical volume to see the changes
b. umount /var1 && mount /dev/mapper/volgroup001-logvolopt1 /opt1
c. Update /etc/fstab


Remove Logical Volume:
Task: Remove 'logvolusr1' from the logical volume pool
a. umount /usr1
b. lvremove /dev/mapper/volgroup001-logvolusr1
c. use 'lvdisplay' to confirm removal


Resize Logical Volume:
Task: Grow (resize) 'logvolopt1' to 20GB
a. lvresize -L 20GB /dev/volgroup001/logvolopt1
b. lvdisplay - to confirm new size of logical volume
c. df -h - will still reveal the current size
d. Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
'resize2fs -f -p /dev/volgroup001/logvolopt1'

Note: You may resize file systems online if the following are met:
1. 2.6x kernel series
2. MUST be formatted with ext3

Task: Shrink (resize) 'logvolopt1' to 15GB
a. lvresize -L 15GB /dev/volgroup001/logvolopt1
b. lvdisplay
c. df -h
d. resize2fs -f -p /dev/volgroup001/logvolopt1
Note: online shrinking is not supported
e. df -h

Note: Check disk utilization prior to shrinking to reduce the risk of losing data

LVM GUI Utility:
system-config-lvm

Create Swap based on File

Features:
1. The ability to provision swap space based on a file, similar to pagefile.sys in Windows NT, etc., if you have no available disk space to partition.

2. Doesn't waste partitions


Task:
1. Create 512MB swap file
a. dd if=/dev/zero of=/home1/swapfile1 bs=1024 count=524288
b. mkswap /home1/swapfile1 - overlays swap file system
c. swapon /home1/swapfile1 - makes swap space avaialable to the kernel

2. Ensure that when the system reboots, the swapfile is made avialable to the kernel
a. nano /etc/fstab - /home1/swapfile1 swap swap defaults 0 0


3. Create 2GB swap file
a. dd if=/dev/zero of=/home1/swapfile2 count=2G