You are on page 1of 50

Chapter 13: System And Kernel Management

The Complete Guide to Linux System Administration

Objectives
Establish a Linux backup strategy Configure and review system log files Understand the use of kernel modules and the features of a high-end kernel Upgrade and recompile the Linux kernel

The Complete Guide to Linux System Administration

Backing Up a Linux System


Backup
Copy of data on computer system Form of insurance

The Complete Guide to Linux System Administration

Designing a Backup Strategy


Backup plan
Written document that outlines:
When and how files are backed up How files are stored How files are restored

Backup media
Item that holds backed-up data

Restore data
Copy from backup media to file system
The Complete Guide to Linux System Administration 4

Designing a Backup Strategy (continued)


Backup plan questions
What files should be backed up? Who will back up files? Where are files located? How should backups be performed? Must you be able to restore data within a specific period of time?

The Complete Guide to Linux System Administration

Designing a Backup Strategy (continued)


Determining value of data
Spend more to protect integrity of expensive data

Opportunity cost Determine when to back up data


Data changes frequently in most organizations
User data Log files E-mail archives Constitutes daily work of users within organization
6

The Complete Guide to Linux System Administration

A Linux Backup Strategy


Backup level
Defines how much data is backed up Backup operation at given backup level stores all data that has changed since last backup of previous level Levels
Level 0, full backup Level 1, weekly differential backup Level 2, daily differential backup
The Complete Guide to Linux System Administration 7

A Linux Backup Strategy (continued)


Full backup
Also called epoch backup Everything on system is backed up

Differential backup stores only files that changed since full backup Incremental backup stores files that changed since most recent incremental backup or differential backup

The Complete Guide to Linux System Administration

A Linux Backup Strategy (continued)

The Complete Guide to Linux System Administration

A Linux Backup Strategy (continued)


Restoring file from three-level backup
Check most recent level 2 backup, level 1backup, and level 0 backup

Entire system restore from three-level backup


Restore most recent level 0 backup, level 1 backup, and level 2 backup

The Complete Guide to Linux System Administration

10

A Linux Backup Strategy (continued)


Managing and storing backup media
Determine how many backup media needed for each level Carefully label media Most organizations store one set of monthly backup media off-site
Possibly weekly as well

Can reuse same set of level 1 weekly tape cartridges each month starting with oldest one
The Complete Guide to Linux System Administration 11

A Linux Backup Strategy (continued)

The Complete Guide to Linux System Administration

12

A Linux Backup Strategy (continued)


Backing up root file system
Requires special attention in backup plan Contains tools normally used to restore damaged data Think about how to respond if root file system is damaged

The Complete Guide to Linux System Administration

13

Hardware and Software Issues


Determine best tools to get job done Linux includes all necessary software utilities for many backup tasks Backup media such as tape cartridges cost much less than hard disk Verify backups regularly Check backup log each morning

The Complete Guide to Linux System Administration

14

Hardware and Software Issues (continued)


Know exactly what information is backed up
Backup utilities normally include options to maintain or ignore file ownership and permissions

Choose whether to use compression feature


When data compressed, redundancy removed

The Complete Guide to Linux System Administration

15

Using Linux Backup Utilities


tar cpio dump restore dd (Data dump)

The Complete Guide to Linux System Administration

16

Using Linux Backup Utilities (continued)


Graphical utilities rely on tar, cpio, or dump and restore in background Common to use Linux backup utilities across network Most full-featured backup utilities create own network connections ark
Graphical tool for managing data backup operations
The Complete Guide to Linux System Administration 17

Using Linux Backup Utilities (continued)


Specialized software for maintaining large numbers of backup media for large volumes of data
BRU (backup and restore utility) Arkeia Storix Hypertape Amanda Legato
18

The Complete Guide to Linux System Administration

Understanding Redundant Disk Systems and RAID


Redundant arrays of inexpensive disks
Called RAID subsystems or RAID arrays Group or array of inexpensive hard disks If one disk fails, others can take over until failed disk replaced Can be implemented by Linux kernel
As device called /dev/md0 Composed of several actual hard disk partitions

The Complete Guide to Linux System Administration

19

Understanding Redundant Disk Systems and RAID (continued)


Defining RAID levels
Levels differ in:
Amount of fault tolerance provided Speed of reading or writing data Cost of implementation

RAID-Linear
Combine multiple physical devices into single logical device Not truly RAID level

The Complete Guide to Linux System Administration

20

Understanding Redundant Disk Systems and RAID (continued)


RAID-0
Data storage technique called striping Single block of data divided into pieces Stored on more than one hard disk

RAID-1
Mirrors data across multiple hard disks

RAID-3
Stripes data across multiple hard disks Provides additional protection against failure by using parity
The Complete Guide to Linux System Administration 21

Understanding Redundant Disk Systems and RAID (continued)

The Complete Guide to Linux System Administration

22

Understanding Redundant Disk Systems and RAID (continued)


Mirroring
Two or more hard disks contain identical information

Duplexing
Mirrored hard disks on separate controller cards

Parity
Technique that allows corrupted data to be reconstructed using extra information created as data stored
The Complete Guide to Linux System Administration 23

Understanding Redundant Disk Systems and RAID (continued)


RAID-5
Similar to RAID-3 Parity information and stored data striped across multiple hard disks

Write caching stores information in memory until it can be written to multiple hard disks without degrading performance overall

The Complete Guide to Linux System Administration

24

Understanding Redundant Disk Systems and RAID (continued)

The Complete Guide to Linux System Administration

25

Understanding Redundant Disk Systems and RAID (continued)

The Complete Guide to Linux System Administration

26

Understanding Redundant Disk Systems and RAID (continued)


Hardware-based RAID
Control and management of disk array depends on separate hardware system All special technology contained in RAID device Often allow hot-swapping disks Main disadvantage: cost

The Complete Guide to Linux System Administration

27

Understanding Logical Volume Management


Logical volume manager (LVM) used to manage large hard disks Physical volumes
Use Disk Druid to set up real partitions on multiple hard disks Grouped together into logical volume group Treated as regular hard disk Boot loader not able to work directly with LVM

The Complete Guide to Linux System Administration

28

Log files

System Logs

Detailed records of events within system Created by many programs

/var/log/messages
Many different programs write messages

Message
Description of what is happening within program Uses standard format

whatis command
Looks at database of program descriptions Prints one-line description of program
The Complete Guide to Linux System Administration 29

The syslogd and klogd Daemons


syslogd
System logging daemon Watches for messages submitted by programs

klogd
Kernel log daemon Watches for messages submitted by kernel Logs kernel messages to /var/log/messages

The Complete Guide to Linux System Administration

30

syslogd and klogd Work Together to Process Log Messages

The Complete Guide to Linux System Administration

31

Configuring the System Log


/etc/syslog.conf
Configure syslogd and klogd Each line in syslog.conf file contains two parts:
Selector Action

The Complete Guide to Linux System Administration

32

Configuring the System Log (continued)

The Complete Guide to Linux System Administration

33

Configuration File Syntax


Comment lines
Begin with # character Precede and explain purpose of each line

Some aspects of configuration file syntax not obvious even after reading about facilities and actions After changing syslog.conf configuration file, service syslog restart

The Complete Guide to Linux System Administration

34

Configuration File Syntax (continued)


SIGHUP signal
Send with kill command Tells daemon to reread configuration files kill -HUP cat /var/run/syslogd.pid

The Complete Guide to Linux System Administration

35

Using the Logger Utility


Logger utility sends message to syslog function Example: logger compression utility started Logged wherever syslog.conf file has configured messages matching selector

The Complete Guide to Linux System Administration

36

Analyzing Log Files


System administrator should regularly check log files for indications of trouble
Become accustomed to what is normal and what is unexpected Use standard Linux tools to search for information in log files Use special log management utilities that watch log files for specified conditions
Notify via e-mail about problems

The Complete Guide to Linux System Administration

37

Rotating Log Files


Erase old log files to free up disk space for new log information Compress log files and store them on archive medium Rename and compress log files Common log rotation system stores log files for a month logrotate utility

The Complete Guide to Linux System Administration

38

Exploring Kernel Components


Learn how Linux keeps track of time Learn about /proc file system Work with kernel modules and several high-end features of Linux kernel

The Complete Guide to Linux System Administration

39

Timekeeping in Linux
Hardware clock
Electronic clock with small battery Maintains correct time even when computer is off

System clock
Internal clock in kernel Maintained internally as single number
Number of seconds since January 1, 1970

The Complete Guide to Linux System Administration

40

Timekeeping in Linux (continued)


date command
See current date and time from system clock

hwclock command
See current date and time from hardware clock

Network time server


Computer that maintains highly accurate time based on atomic or radio clocks Network Time Protocol (NTP)
/etc/ntp.conf file
The Complete Guide to Linux System Administration 41

Kernel Management Using the /proc File System


/proc file system
Interact with system resources as if they were files Query to learn about system hardware Can also write information to some file names in /proc

sysctl command
Preferred method of viewing and updating many kernel parameters Operates on values stored in /proc/sys
The Complete Guide to Linux System Administration 42

Using Kernel Modules


Linux kernel modules
Files containing computer code Can be loaded into kernel or removed from kernel as needed

lsmod command lists modules that are installed modinfo command


Learn about modules

The Complete Guide to Linux System Administration

43

Using Kernel Modules (continued)


Adding and removing modules
modprobe command loads module with any required supporting modules rmmod command removes module from kernel Module parameters provides information needed by module to locate system resources

The Complete Guide to Linux System Administration

44

Configuring and Upgrading Kernel Components


Add features to kernel by inserting kernel modules
Some kernel features not available as modules

Recompile Linux kernel from source code


File vmlinuz-26.5-1.358 contains Linux kernel Usually located in / or /boot directory

The Complete Guide to Linux System Administration

45

Installing Kernel Source Code


Source code in single rpm
Named kernel-source Use rpm command to install

Explore source code files in directory /usr/src/linux-26.5-1.358 Patch file Patch command
Insert and change lines based on patch file

The Complete Guide to Linux System Administration

46

Configuring Kernel Features


Select which kernel options to include or activate for system Configuration utilities
config menuconfig xconfig

make command
Programming utility uses instructions in configuration file to execute series of instructions
The Complete Guide to Linux System Administration 47

Compiling a New Kernel


Execute series of make commands
Prepare all source code files Compile them into kernel image

Requires between 30 minutes and 3 hours Example: make dep; make bzimage; make modules; make modules_install

The Complete Guide to Linux System Administration

48

Summary
Backup plan creates orderly system for backing up data on regular basis and restoring lost data as needed Log files record activities of Linux programs System clock in Linux kernel maintains time and date for system events RAID systems improve speed and fault tolerance

The Complete Guide to Linux System Administration

49

Summary (continued)
/proc file system
View details about
Kernel Running processes Other system information

Linux kernel sometimes updated by Linux vendors via new rpm file

The Complete Guide to Linux System Administration

50