CentOS: Difference between revisions
(+CentOS 8) |
(Updated LXC) |
||
Line 99: | Line 99: | ||
systemctl restart vnstat | systemctl restart vnstat | ||
=== Installing LXC === | === LXC === | ||
==== Installing LXC ==== | |||
Linux containers can be used when installing these packages: | Linux containers can be used when installing these packages: | ||
Line 113: | Line 115: | ||
There is a [http://e-syslog.blogspot.de/2014/12/lxc-container-libvirt-on-centos-7.html how to] that explains how LXC can be installed on CentOS when using libvirt and friends. | There is a [http://e-syslog.blogspot.de/2014/12/lxc-container-libvirt-on-centos-7.html how to] that explains how LXC can be installed on CentOS when using libvirt and friends. | ||
==== Creating a CentOS container ==== | |||
lxc-create -t download -n centos8c1 -- -d centos -r 8 -a amd64 | |||
=== Installing recent kernel === | === Installing recent kernel === |
Latest revision as of 15:25, 31 May 2020
Introduction
CentOS is a GNU/Linux operating system with long term support (10 years after release). It is a rebuild of Red Hat Enterprise Linux. Some packages in the distribution are already 1 to 2 years old when a new CentOS release is made. That means you don't get the most current software, but the software you get is quite mature. You can assume that most of the bugs in every software in CentOS have been found and fixed already. Anyway, there's sometimes a route to newer software, for example, very new kernels can be installed.
Just one comparison:
- Linux kernel: When CentOS 7 was released on 2014-07-07, it was shipped with Linux 3.10. At this time, this kernel was already one year old (released by the end of June, 2013). Ubuntu 14.04, which was released in April, 2014, already contained Linux 3.13.
Setting up
Setting up network and network tools
If there is no network connectivity, the network might be unconfigured. Get an IP address by issuing
dhclient enp0s3
Adjust enp0s3 to your needs!
If you don't know the names of your network interfaces, this command will tell them to you:
cat /proc/net/dev
The network configuration is saved in /etc/sysconfig/network-scripts: each network interface has got a file ifcfg-name, for example "ifcfg-enp0s3" for an ethernet adapter. In such a file, "ONBOOT=yes" can be set, so the interface will be brought up at boot. See also: Network Configuration Files
CentOS 7
After that, install some basic network utilities:
yum install ntp ntpdate ntp-doc net-tools
The "net-tools" package includes "netstat" and "ifconfig".
These commands enable and start the network time daemon:
systemctl enable ntpd systemctl start ntpd
CentOS 8
timedatectl set-ntp 1
This activates time synchronisation.
Software
CentOS uses the yum
command to manage its packages. The most important commands are:
yum install package yum remove package yum list yum provides command yum search package
Many more options can be seen in its man page.
Comparing to "apt" in Debian/Ubuntu, yum is slightly slower than apt, because at every start it outputs something like
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile base: artfiles.org elrepo: nl.mirror.babylon.network epel: nl.mirror.babylon.network extras: ftp.plusline.de updates: mirror.dataone.nl
However, I would not perceive that as a problem. Until now, yum never made troubles and did a fantastic job.
Install EPEL
To do some advanced things, like vnstat or lxc, install epel-release:
yum install epel-release
Enabling automatic updates
yum -y install yum-cron systemctl enable yum-cron systemctl start yum-cron
It is recommended to review the settings using
nano /etc/yum/yum-cron.conf
Installing and configuring vnstat
yum install vnstat systemctl enable vnstat systemctl start vnstat
Then, for every interface that ifconfig | grep "RUNNING"
reports, create the database by using
sudo -u vnstat vnstat -i -u iface
It is important to run this as user "vnstat" so the database files in /var/lib/vnstat/ have the right permissions (rw-r--r-- or 644) and owner (vnstat.vnstat). The daemon that updates the database files runs as user "vnstat" and if the files are not writeable by this user, the daemon cannot do its job.
After every interface added, the daemon must be restarted so it is notified about that change:
systemctl restart vnstat
LXC
Installing LXC
Linux containers can be used when installing these packages:
yum install lxc lxc-templates debootstrap perl libvirt lxc-extra systemctl enable lxc systemctl start lxc systemctl start libvirtd
debootstrap is for installing Debian and operating systems based on it (like Ubuntu). lxc-extra contains the lxc-ls command (which is actually just a python script).
There is a how to that explains how LXC can be installed on CentOS when using libvirt and friends.
Creating a CentOS container
lxc-create -t download -n centos8c1 -- -d centos -r 8 -a amd64
Installing recent kernel
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm yum --enablerepo=elrepo-kernel install kernel-ml