Wednesday 6 August 2014


RHCSA 7 Exam Notes #5: Deploy, configure, and maintain systems


Word version available here:
https://drive.google.com/file/d/0B9WPh0iDN4KwMS0wTzhlbS1yYlE/edit?usp=sharing

Configure networking and hostname resolution statically or dynamically
With the GUI you can click on the Network icon beside the top right hand day/clock. Look for the tiny settings button in the bottom right of the Settings/Network window that opens. There you can set static/automatic IP & Name resolution. You can learn the command line equivalents but seriously, which is going to be quicker? As long as they give you a GUI that is?!!

Schedule tasks using at and cron
So, “at” is used for one time, one off, never to be repeated task scheduling. Examples of use are as follows:
at 10am    at 21:30   at 15:00 tomorrow   at now + 10 minutes  at 03:00 8/14/14

When you execute this you will prompted to enter the command(s) you want to execute, type CTRL+D to finish and submit the job. Note the job number. As root you can check on it using “at -c <job number>” or just list all “at -l” or “atq”. “at -d <job number” to remove job.
Or use -f to specify a filename to execute:
at -f ~/myball.sh at 02:00 5/18/14

Now, cron is for repeated executions if you don’t screw up the /etc/crontab file!
The format for entries in the crontab file is:
20 1,12 1-15 * * find / -name core
{20=minute of the hour} {1,12=Hour of the Day} {1-15=Dates of the Month} {*/2=Every second Month of the Year} {*=Day of the Week} Find / -name core

crontab -e -u student              (Run as Root to create cron for user student)
vi /etc/cron.allow                   (Run as root to permit student to execute cron jobs)
Now as the user student run “crontab -l” to show the job and “crontab -r” to remove it.

Start and stop services and configure services to start automatically at boot
Great, they changed this considerably in RHEL7!! HaHa!
systemctl start crond.service              (Start crond service the RHEL7 way!)
systemctl stop crond.service              (Guess what this does)
systemctl status crond.service            (For those with short term memory)
systemctl list-units --type service       (List all active services, add --all for others)
systemctl {enable/disable} crond.service       (Enables/Disabled service automatic startup)

Configure systems to boot into a specific target automatically
This is about booting into specific runlevels but they’ve rebranded it “systemd targets” represented by target units.

Runlevel          Target Units                          Description
0          runlevel0.target, poweroff.target      Shut down and power off the system.
1          runlevel1.target, rescue.target          Set up a rescue shell.
2          runlevel2.target, multi-user.target    Set up a non-graphical multi-user system.
3          runlevel3.target, multi-user.target    Set up a non-graphical multi-user system.
4          runlevel4.target, multi-user.target    Set up a non-graphical multi-user system.
5          runlevel5.target, graphical.target      Set up a graphical multi-user system.
6          runlevel6.target, reboot.target          Shut down and reboot the system.

systemctl get-default                                      (what is the current default?)
systemctl set-default multi-user.target          (Sets default to non-graphical multi-user system. Run “startx” to load graphical interface at run level 3!)
systemctl isolate multi-user.target                (Changes the current target)
By the way, systemctl can be used as follows:
systemctl {halt/poweroff/reboot}      
 

Install Red Hat Enterprise Linux automatically using Kickstart
Check the root users home folder for anaconda-ks.cfg. This is a good Kickstart primer generated using the installation of that RHEL system.
Web Server where RHEL7 DVD is copied
/var/www/html/anaconda-ks.cfg       edit permissions to allow public access to file chmod 777 etc and test download from workstation

Not getting a DHCP Address on the virtual adapter when booting the VM

Configure a physical machine to host virtual guests
A few tools to be aware of:
virsh                (Command line tool, watch out for the virsh # prompt, if you fire this up with options! Exit will return you to normal bash shell)
virt-manager               (Graphical Tool)
virt-install                    (Provisions new VMs)

grep -E ‘svm|vmx’ /proc/cpuinfo       (checks for AMD extension - svm and Intel extensions - vmx required for full virtulization)
yum -y install qemu-kvm qemu-img              (Main two Virtualization packages)

yum -y install virt-manager                            (Appears under system tools. Opening it complains about package libvirt-daemon-config-network missing. Install but you’ll need to enter root password several times. Groupinstall doesn’t appear to work with local yum repository)

Use virt-manager and right click localhost (QEMU) and Click Details to create a virtual network for VMs. (This worked fine in one environment using Workstation 10 but Failed on Workstation 9?!).  I was unable to get a remote ISO to work so I ended up using mount to connect to the extracted RHEL7 DVD on the NFS share as detailed further down this document. Then I just pointed it at /nfs and it worked fine and installed the VM.

Install Red Hat Enterprise Linux systems as virtual guests

Not Completed

Configure systems to launch virtual machines at boot

Bring up the VM Details and under Boot Options you can choose Autostart – Start virtual machine on host boot up.
Configure network services to start automatically at boot

See service section above, many of the older graphical tools are defunct unfortunately.

Configure a system to use time services

timedatectl     (command to configure current time, date & timezone)
timedatectl set-ntp yes

chrony best for mobile/virtual systems, ntpd best for servers left permanently on.
chrony configuration file is /etc/chrony.conf and is populated with remarked examples.

systemctl {status/start/enable} chronyd        (Kick off chronyd service)
chronyc {tracking/sources/sourcestats}         (Various checks you can perform)

Note: There was no /etc/ntp.conf file on my build by default and you need to disable chrony first. I think learn chrony and leave it at that.

Install and update software packages from Red Hat Network, a remote repository, or from the local file system

To configure YUM have a look at /etc/yum.conf. At the end of this file it lists the folder where the .repo files should reside (/etc/yum.repos.d). Now I’m not sure if you’ll have to create the repositories themselves but let’s see how to configure the client piece of each of these requirements above.

Yum has a few useful switches (use “man yum” also):
yum -y install <package>        (standard install and don’t prompt me one)
yum search tigervnc               (searches for packages with the string tigervnc in it)
yum update tigervnc-server   (updates package - needs RHN)                    
yum remove/erase <package>           (Removes selected package)
yum info tigervnc-server        (displays package header information)

So let’s start by creating a local Yum Repository:
yum -y install createrepo
mount /dev/cdrom /mnt        (mounts the RHEL7 DVD to /mnt)
mkdir -p /var/yum/repos.d/local       (Creates folder to store Repository)
cp -a /dev/cdrom/.  /var/yum/repos.d/local (Copies DVD contents locally, watch out for the .period or you’ll get a slightly different subfolder DVD appearing where you don’t want it)
createrepo -v /var/yum/repos.d/local           (Reads all the packages in)
vi /etc/yum.repos.d/local.repo           (Create new definition file with contents below. Note: the name in [] can’t have spaces)

[local]
name=local yum repository
baseurl=file:///var/yum/repos.d/local/
enabled=1
gpgcheck=0

The remote repository could be http/nfs/ftp so let’s cover out bases:
vi /etc/yum.repos.d/http.repo

[http]
name=remote http repository
baseurl=http://10.0.0.129/rhel7/
gpgcheck=0

The IIS7 Engine needs a custom mime map to define .bz2 files (File name extension = “.bz2” MIME type = “application/x-bzip2” without the quotes). This will allow you to download them instead of giving an annoying error. You will need to enable directory browsing to the virtual directory where you copied the RHEL7 DVD contents to the windows server. I configured CIFS/NFS/FTP/HTTP to the same folder.

vi /etc/yum/repos.d/ftp.repo

[ftp]
name=remote ftp repository
baseurl=ftp://10.0.0.129/
gpgcheck=0

Turn off the Windows Server 2012 R2 Firewall to permit FTP on port 21 or create a rule to avoid pulling your hair out! Running a “yum repolist” should pull in the FTP contents,

vi /etc/yum/repos.d/nfs.repo

[nfs]
name=remote nfs repository
baseurl=file:///nfs
gpgcheck=0

mount 10.0.0.129:/rhel7 /nfs            (This will use a mount point to provide a path to the NFS share)
yum clean all              (This can be run after each of the sections above)
yum repolist                (This will validate the repodata xml files from each repository)

For the official RHN, find the GUI under Applications, System Tools, Red Hat Subscription Manager

FYI - You can use the GUI “gpk-update-viewer” to look for available updates and “gpk-prefs” to set update check frequency and source.

Update the kernel package appropriately to ensure a bootable system
uname -r                                 (This shows current version of running kernel)
yum -y install kmod                (is installed by default)
lsmod                                      (Lists all kernel modules loaded in memory)
modinfo e1000e                      (Displays detailed information about a particular kernel module)
modprobe -v wacom               (Loads wacom module and dependencies)
modprobe -r wacom               (removes wacom module from kernel)
yum -y update kernel              (Required RHN subscription)
rpm -ivh /tmp/kernel-*.rpm   (Installs new Kernel Files)
rpm -qa | grep ^kernel           (Checks installed packages. Note: shift + 6 = ^)

Modify the system bootloader

When you boot from the DVD there’s a Troubleshooting option. You can choose “Rescue a Red Hat Enterprise Linux system” from the next menu. Choose continue and ok and it will mount the system and show you the command below.

chroot /mnt/sysimage
/sbin/grub2-install /dev/sda   (Reinstall Grub2 bootloader)
rpm -e xorg-x11-drv-wacom  (Remove failed driver, or use rpm to install one with -ivh)
Reboot                                     (System restarts twice)