神刀安全网

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Operating Red Hat  Enterprise Server 7 – An introduction

This is the continuation part of RHCSA exam guide, this module will include all of the tools, services, commands required for operating Red Hat Enterprise Linux 7. To handle a Red Hat Linux server a skills is required to monitor various processes, to handle various software and to schedule backups to that catastrophic situations can be avoided. It is possible that you can get out of storage disk storage therefore you must learn how to handle these storage device, and add or remove extra disk space if required.

Have a look on recently published articles in RHCSA series

http://www.unixmen.com/everything-know-rhcsa-certification/

http://www.unixmen.com/basics-must-know-rhcsa-exam-preparation/

http://www.unixmen.com/learn-man-vim-editor-file-globbing-rhcsa/

http://www.unixmen.com/learn-file-management-commnad-line-required-rhcsa/

http://www.unixmen.com/hard-soft-links-user-group-management-rhcsa/

What you will learn in this module of RHCSA curriculum?

After finish this module candidate will be able to monitor processes, prioritise any process, manage, install uninstall or update software with resolving the dependencies. Further a candidate will schedule tasks with the help of cron and at commands, run virtual machines with kvm virtualisation utility, mange logs and will be handle to manage hard disk partitioning, disk formatting, adding or removing of any new hard disk with the help of Logical Volume Manager or LVM utility.

What topics are covered in module-2 of RHCSA curriculum?

  1. Process management in RHEL 7.
  2. software managing using yum in RHEL 7.
  3. Virtualization using KVM in RHEL 7.
  4. Job scheduling with cron and at in RHEL 7.
  5. Log management in RHEL 7.
  6. Disk management with disk partitioning utilities in RHEL 7.
  7. LVM management in RHEL 7.

    1. Process management in RHEL 7

Hundred of processes start when system is booted on.  You can monitor currently running processes with following command

# ps aux

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Start some process on terminal

# firefox

Now terminal will engaged till the process is on, to send this process to background press ‘control+z’. See background process with following command.

# bg

RHCSA module 2 – Operating Red Hat Enterprise Server 7 To see child parent process relationship in running processes use

# ps fax

RHCSA module 2 – Operating Red Hat Enterprise Server 7

To see memory status of the system (-m option will display output in megabyte)

# free -m

Output

total used free shared buff/cache available Mem: 1119 410 289 7 419 540 Swap: 819 0 819

Get the uptime of cpu alongwith average cpu load

RHCSA module 2 – Operating Red Hat Enterprise Server 7

To list busy most process which are consuming maximum resources use top

# top

RHCSA module 2 – Operating Red Hat Enterprise Server 7

You can watch cpu, memory and swap usages status as live.

Assume we wants to kill a process firefox, use killall command

 # killall firefox

Kill a process by pid.

Let us wants to kill a process with process id 11, as shown with top command.

# kill -9 11

Generally processes are initiated with a same level of priority which is by default set to a value of 20, have a look in top command.

RHCSA module 2 – Operating Red Hat Enterprise Server 7

You may need to change the priority of some process to make it more preferred or you may need to make it to be some lesser priority process, this can be achieved by nicing a process, these values can be between -20 to 20, more negative value means more prior process.

use top command, and press r to renice a process.

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Let us renice sshd process with pid 2689

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Make that value to 0

RHCSA module 2 – Operating Red Hat Enterprise Server 7

See the nice value of sshd now, it is a preferred process now

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Define process renicing from terminal command line. Change value of sshd service which has a PID value of 2689 in our example.

# renice -n 20 -p 2689

Use nice to set value for some new process, define nice value after -n option, for more detail use

nice –help

# nice -n 10 dd if=/dev/zero of=/dev/null &

Have a look with top that nice value is set to 10.

# top

RHCSA module 2 – Operating Red Hat Enterprise Server 7 2. managing software in RHEL 7 using yum.

A good article to manage yum in Red Hat Linux is already published with unixmen.com, link of the article is provided below, that article is sufficient to make you understand yum in RHEL 7.

3. Virtualization using KVM in RHEL 7

KVM is a fully open source and complete virtualisation software, it consists of kvm.ko the loadable kernel module, it can run multiple virtual machines without modifying the host configurations.

Install kvm package

# yum install kvm libvirt virt-manager qemu-kvm

Verify whether, kvm is active or not

# systemctl status libvirtd

RHCSA module 2 – Operating Red Hat Enterprise Server 7 Get virtualisation shell

# virsh

A new console for kvm virtualisation will get open, use help for more options.

List existing virtaul machines running on server

# virsh list

RHCSA module 2 – Operating Red Hat Enterprise Server 7

All of the configuration file of kvm virtualisation are stored in /etc/libvirt/, each virtual machines get its configuration file generated automatically.

To create a new virtual machine

#virt-manager

Create a new machine

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Browse for Image OS image, define ram size

RHCSA module 2 – Operating Red Hat Enterprise Server 7

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Define disk space

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Configure and boot

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Use following command to show installed vm

# virsh list --all Id Name State ---------------------------------------------------- - centos7.0 shut off

To shut down running virtual machine

# virsh destroy centos7.0

Manage Hardware configuration of virtual machine in virt-manager

RHCSA module 2 – Operating Red Hat Enterprise Server 7

For more details you can access official kvm link

http://www.linux-kvm.org/page/Main_Page

4. Job scheduling with cron and at in RHEL 7

i. Using cron to handle job scheduling in Red Hat Linux 7

To automate administrative tasks,a task scheduler is required, cron and at utilities are available with Linux to schedule automated scripts or commands, cron is used when need to perform certain automation tasks on daily/hourly/weekly or on some regular time period, but at command is used when you need to perform some task once at a defined time.

Cron configuration files is /etc/crontab

# vim /etc/crontab

Sample output

SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed

You never put your scheduling in this file, avoiding editing that file.

Schedule cronjob for a user

time format is like [ minute] [hour] [day of the month] [month] [day of the week]  

Add a job in cron

# crantab -e

Get backup of /home directory daily at 5 pm daily using crontab -e

0 17  * * *  tar cfz /root/home.tgz /home

List what cron jobs are scheduled on system

# crontab -l

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Schedule back on specific month

* * * march,april,may * cp /etc/named.* /root/backup

Schedule task after every 30 minutes

*/30 * * * *  rm  -rf /tmp/*

Another method of managing cron jobs is to use /etc/cron.d/ directory

# cd /etc/cron.d

In this file you can put files with any name you desire and define your cron job in defined format.

RHCSA module 2 – Operating Red Hat Enterprise Server 7

Have a look in some sample file

# vim sa-update

RHCSA module 2 – Operating Red Hat Enterprise Server 7

You can define your own job schedules using /etc/cron.d/ directory. Use man or help toolsto get more details on cronjob.

ii. Using at to handle job scheduling in Red Hat Linux 7

Have a look on current time

# date Fri Jun 10 13:03:44 EDT 2016

Log hello world suppose at 13:10 using at command, define time with at command, press enter, give command, press Ctrl+D to save and quit.

# at 13:10 at> logger hellow world  at> <EOT> job 2 at Fri Jun 10 13:10:00 2016

Check logs

# tail -f /var/log/messages

RHCSA module 2 – Operating Red Hat Enterprise Server 7

With at you can manage various time specific tasks with at.

Conclusion

Three chapters of module 2 of RHCSA we will cover in next topic, in which we we will discuss disk management with various command line tools available, creating and managing LVM based disk partitions. Log management is another important aspect of Linux administration therefore we will discuss that part too in detail in next and last article of module-2 of RHCSA curriculum.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » RHCSA module 2 – Operating Red Hat Enterprise Server 7

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址