Difference between pages "KVM" and "Installing a Cron Daemon"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
(Changed qemu-kvm to qemu (http://forums.funtoo.org/viewtopic.php?id=1657))
 
(fill out page)
 
Line 1: Line 1:
== Introduction ==
== Introduction ==
Cron daemons allow you to configure certain tasks to be run at specific times. Installing a cron daemon is a good idea because some packages may assume that you have a cron daemon installed and create jobs to update their databases with a cron daemon. There are several different loggers available to Funtoo users:
* '''Fcron'''
* '''Cronie'''
* '''Vixie-Cron'''


KVM is a hardware-accelerated full-machine hypervisor and virtualization solution included as part of kernel 2.6.20 and later. It allows you to create and start hardware-accelerated virtual machines under Linux using the QEMU tools.
== Installation ==
 
To install the cron daemon, run the following command:  
== Kernel Setup ==
 
To enable KVM, the following kernel config parameters should be enabled (this is based on a 3.x kernel):
 
Under <tt>Processor type and features</tt>, enable <tt>Paravirtualized Guest Support</tt>. Under the <tt>Paravirtualized Guest Support</tt> menu, enable any options related to KVM, such as <tt>KVM paravirtualized clock</tt> and in particular <tt>KVM Guest Support</tt>.
 
Under the <tt>Virtualization</tt> category from the main kernel config menu, enable <tt>Kernel-based Virtual Machine (KVM) support</tt>, and enable at least one type of KVM, either for Intel or AMD processors. It is also recommended to enable <tt>Host kernel acceleration for virtio net</tt>.
 
You can use modules or build these parts directly into the kernel. Build your new kernel and modules, and reboot.
 
== User-space tools ==
 
KVM is essentially a kernel-accelerated version of QEMU. To enable KVM support in the user-space tools, add the following lines to <tt>/etc/make.conf</tt>:
 
<pre>
QEMU_SOFTMMU_TARGETS="i386 x86_64"
QEMU_USER_TARGETS="i386 x86_64"
</pre>
 
Once the <tt>make.conf</tt> variables above are set, emerge qemu:
 
<console>
<console>
# ##i## emerge qemu
# ##i## emerge --ask fcron
</console>


==Initial Setup==
These are the packages that would be merged, in order:


Prior to using KVM, modprobe the appropriate accelerated driver for Intel or AMD:
Calculating dependencies... done!
[ebuild  N    ] sys-process/cronbase-0.3.2-r1
[ebuild  N    ] sys-process/fcron-3.1.2-r2  USE="mta pam readline system-crontab -debug (-selinux)" LINGUAS="-fr"


<console>
##b## Would you like to merge these packages? [Yes/No]##i## yes
# ##i##modprobe kvm_intel
</console>
</console>


== Starting your first KVM virtual machine ==
Now enable the cron init script so that is starts when your system boots, and enable the cron daemon:
 
To start your first KVM virtual machine, first download SysRescueCD and save it to systemrescuecd.iso. Then use the following commands, which will create a 10GB qcow disk image to use for the first disk, and then the next command will start your virtual machine, booting from the CD:


<console>
<console>
# ##i##qemu-img create -f qcow2 vdisk.qcow2 10
# ##i##rc-update add fcron default
# ##i##qemu-system-x86_64 vdisk.qcow2 -m 1024 -cdrom systemrescuecd.iso -vnc 127.0.0.1:1 -cpu host -net nic -net user
* service fcron added to runlevel default
VNC server running on `127.0.0.1:5900'
# ##i##rc
  * Caching service dependencies ...             [ ok ]
* Starting fcron ...                           [ ok ]
</console>
</console>


Now you should be able to use a VNC client to connect to 127.0.0.1:5901 (VNC session 1) and access your virtual machine.
=== System Cron Jobs ===
 
== Networking Options ==


Above, networking will be enabled but will be on its own private LAN, and ping will not work. If you have a local bridge that you use for networking, the following steps will allow you use your existing bridge to provide higher-performance and full-featured network access to your virtual machine.  
After the cron daemon has been emerged, you may see a message to run <tt>emerge --config</tt> to configure your cron daemon to process system cron jobs. System cron jobs are scripts that are installed by various packages into the following directories:


First, create <tt>/etc/qemu-ifup</tt> and add the following to it. Replace <tt>brlan</tt> with the name of your bridge:
* <tt>/etc/cron.hourly</tt>
* <tt>/etc/cron.daily</tt>
* <tt>/etc/cron.weekly</tt>
* <tt>/etc/cron.monthly</tt>


<syntaxhighlight lang="bash">
For example, you should find a <tt>/etc/cron.daily/man-db</tt> script that is installed by the <tt>man-db</tt> ebuild. This system cron job updates the man cache every day.
#!/bin/bash
ifconfig $1 0.0.0.0 promisc up
brctl addif brlan $1
sleep 2
</syntaxhighlight>


Make it executable:
You may choose to enable your cron daemon so that it runs system cron jobs, or choose not to. Enabling a cron daemon to run system cron jobs will result in a bit more activity on your system, but should ensure that the system runs more optimally most of the time (caching of man pages, etc.)


<console>
If you would like to have your system run system cron jobs, use <tt>emerge --config</tt> as specified in the emerge output:
# ##i##chmod +x /etc/qemu-ifup
</console>
 
Start the virtual machine as follows:


<console>
<console>
# ##i##qemu-system-x86_64 vdisk.qcow2 -m 1024 -cdrom systemrescuecd-x86-2.8.0.iso -cpu host -vnc 127.0.0.1:1 -net nic -net tap,id=foo
# ##i##emerge --config sys-process/fcron
</console>
Configuring pkg... * This is going to set up fcron to execute check_system_crontabs. * In this configuration, you're no longer free to edit the systab * at your leisure, at it'll be rewritten the moment the crontabs * are modified.Rebuilding fcron systab.2013-10-19 21:20:38  INFO installing file /tmp/fcrontab.84pova for user systabModifications will be taken into account right now.</console>
 
== Tweaking KVM ==
 
=== VNC Output ===
 
If you wanted to have VNC listen on a different IP address or port, you can use the format <tt>-vnc IP:vncnum</tt> which will cause VNC to listen on the IP specified, and the TCP port 5900+vncnum.
 
=== CPU Settings ===


By default, the KVM guest will have one CPU with one core. To change this, use <tt>-cpu host</tt> (to export all of the host's CPU features) and <tt>-smp cores=X,threads=Y</tt>, where X is the number of cores, and Y is the number of threads on each core. You can emulate more CPUs and cores than you actually have.
Your cron daemon is now configured to automatically run system cron jobs.


[[Category:Virtualization]]
[[Category:System]]
[[Category:OpenStack]]
[[Category:Featured]]

Revision as of 21:27, October 19, 2013

Introduction

Cron daemons allow you to configure certain tasks to be run at specific times. Installing a cron daemon is a good idea because some packages may assume that you have a cron daemon installed and create jobs to update their databases with a cron daemon. There are several different loggers available to Funtoo users:

  • Fcron
  • Cronie
  • Vixie-Cron

Installation

To install the cron daemon, run the following command:

root #  emerge --ask fcron

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] sys-process/cronbase-0.3.2-r1
[ebuild  N     ] sys-process/fcron-3.1.2-r2  USE="mta pam readline system-crontab -debug (-selinux)" LINGUAS="-fr" 

root ##b## Would you like to merge these packages? [Yes/No] yes

Now enable the cron init script so that is starts when your system boots, and enable the cron daemon:

root # rc-update add fcron default
* service fcron added to runlevel default
root # rc
 * Caching service dependencies ...              [ ok ]
 * Starting fcron ...                            [ ok ]

System Cron Jobs

After the cron daemon has been emerged, you may see a message to run emerge --config to configure your cron daemon to process system cron jobs. System cron jobs are scripts that are installed by various packages into the following directories:

  • /etc/cron.hourly
  • /etc/cron.daily
  • /etc/cron.weekly
  • /etc/cron.monthly

For example, you should find a /etc/cron.daily/man-db script that is installed by the man-db ebuild. This system cron job updates the man cache every day.

You may choose to enable your cron daemon so that it runs system cron jobs, or choose not to. Enabling a cron daemon to run system cron jobs will result in a bit more activity on your system, but should ensure that the system runs more optimally most of the time (caching of man pages, etc.)

If you would like to have your system run system cron jobs, use emerge --config as specified in the emerge output:

root # emerge --config sys-process/fcron
Configuring pkg... * This is going to set up fcron to execute check_system_crontabs. * In this configuration, you're no longer free to edit the systab * at your leisure, at it'll be rewritten the moment the crontabs * are modified.Rebuilding fcron systab.2013-10-19 21:20:38  INFO installing file /tmp/fcrontab.84pova for user systabModifications will be taken into account right now.

Your cron daemon is now configured to automatically run system cron jobs.