Remote Access to the CentOS Desktop

When you purchase a remote VPS or Cloud Server, it is likely that they will come with a command line interface only. If you want to use a graphical desktop to manage your server and do different tasks, you can follow this guide.

In this guide you will learn to install a different lightweight graphical desktop environment for your CentOS 7 system. You will also learn to install XRDP on your remote VPS so that you can use the graphical based interface from your computer.

Requirements

To follow this tutorial, you will need a VPS or Cloud Server running CentOS 7.x. Additionally you will also need access to the root user. If you are logged in as a non root user, run sudo -i to switch to rootaccount. Running a Desktop Environment requires additional RAM compared to a command line interface, so make sure you have at least 512 MB, recommended is 1GB.

Installing the Desktop Environment

In this tutorial we will be installing GNOME, MATE and XFCE desktop environments. All of these environments are open source and come with different features. You can install any of these desktop environments depending on your choice. Please note that you should install only one desktop environment from the choices below. Installing more than one desktop environment will break your machine.

Before installing any package, it is recommended to upgrade your system and installed packages using the following command.

    yum -y update

Once the system is updated, you can proceed further to install any of these desktop environments.

Installing GNOME

GNOME is a desktop environment which is built using open source and free software only. GNOME is supported on almost all linux platforms. GNOME is in active development for past 17 years and being developed by The GNOME Project. Latest version of this software is GNOME 3, which is packed with many different features.

To install GNOME, run the following command.

    yum -y groupinstall "GNOME Desktop"

The above command will install many packages in your system, hence it will take some time according to your network and hardware speed. Now run the following command to start GNOME at boot time.

    ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

Now reboot your system using init 6 command and proceed to Installation of XRDP on your system.

Installing MATE

MATE originated from unmaintained code of GNOME 2. It is also very popular desktop environment and it has been default desktop for Mint and Fedora.

MATE is not available in the default YUM repository hence you will also need to add EPEL repository in your system. To add EPEL repository run the following command.

    yum -y install epel-release
    yum -y update
    yum clean all

The above command will install the EPEL repository in your system and then, it will update the repository. Finally the last command will clear YUM cache from your system.

Now run the following command to install minimal X windows system in your system.

    yum -y groupinstall "X Window system"

Now run the following command to install MATE graphical desktop system.

    yum -y groupinstall "MATE Desktop"

MATE desktop installs less packages in your system as compared to GNOME desktop, hence it will take less time compared to GNOME. Additionally we can say it is more lightweight than GNOME desktop.

Now run the following command to start GUI or MATE desktop at boot time.

    systemctl set-default graphical.target

You should see following output:

    [[email protected] ~]# sudo systemctl set-default graphical.target
    Removed symlink /etc/systemd/system/default.target.
    Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

Now reboot your system using init 6 command and proceed to Installation of XRDP on your system.

Installing XFCE

XFCE is another open source graphical desktop environment, it is written in C. XFCE is recommended desktop environment for remote servers as it is lightweight and fast hence does not uses much amount of hardware resources.

XFCE is not available in default YUM repository hence you will also need to add EPEL repository in your system. To add EPEL repository run the following command.

    yum -y install epel-release
    yum -y update
    yum clean all

The above command will install EPEL repository in your system and then, it will update the repository. Finally the last command will clear YUM cache from your system.

Now run the following command to install minimal X windows system in your system.

    yum -y groupinstall "X Window system"

Now run the following command to install XFCE desktop in your system.

    yum -y groupinstall xfce

Now run the following command to start GUI or XFCE desktop at boot time.

    systemctl set-default graphical.target

You should see following output:

    [[email protected] ~]# sudo systemctl set-default graphical.target
    Removed symlink /etc/systemd/system/default.target.
    Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

Now reboot your system using init 6 command and proceed to Installation of XRDP on your system.

Installing XRDP

Hopefully you have successfully installed any of the abov graphical desktop environments. Now as we have our desktop ready, we will need to install XRDP into our machine so that we can access the remote machine in graphical mode. XRDP supports windows remote desktop client as well as VNC viewer.

To install XRDP on your system, you will need to add EPEL repository in your system. If you have it installed previously, you can skip, or you can install EPEL using following commands.

    yum -y install epel-release
    yum -y update
    yum clean all

Now run the following commands to install XRDP into your machine.

    yum -y install xrdp tigervnc-server

Now you will need to make changes to your SELINUX. You can either adjust your SELINUX using the following commands.

    chcon --type=bin_t /usr/sbin/xrdp
    chcon --type=bin_t /usr/sbin/xrdp-sesman

You will also need to adjust your firewall rules to allow port number 3389, on which RDP service will listen to. Run the following commands for same.

    firewall-cmd --permanent --zone=public --add-port=3389/tcp
    firewall-cmd --reload

Now you can start XRDP on your system using following command.

    systemctl start xrdp

To automatically start XRDP on boot time run the following command.

    systemctl enable xrdp

To check if XRDP service is running, use the following command.

    netstat -antup | grep xrdp

You will get following output.

    [[email protected] ~]# netstat -antup | grep xrdp
    tcp        0      0 127.0.0.1:3350          0.0.0.0:*               LISTEN      23532/xrdp-sesman
    tcp        0      0 0.0.0.0:3389            0.0.0.0:*               LISTEN      23533/xrdp

You can also use the following command to check the status of XRDP service.

    systemctl status xrdp

You should see following output.

    [[email protected] ~]# systemctl status xrdp
    ● xrdp.service - xrdp daemon
       Loaded: loaded (/usr/lib/systemd/system/xrdp.service; disabled; vendor preset: disabled)
       Active: active (running) since Wed 2016-09-07 03:27:39 UTC; 2s ago
     Main PID: 23579 (xrdp)
       CGroup: /system.slice/xrdp.service
               └─23579 /usr/sbin/xrdp --nodaemon

Sep 07 03:27:39 ip-172-31-24-179 systemd[1]: Started xrdp daemon. Sep 07 03:27:39 ip-172-31-24-179 systemd[1]: Starting xrdp daemon...

Connecting to CentOS Machine

If you are on windows machine you can use the inbuilt Remote Desktop Client to connect to the CentOS machine running your favorite graphical desktop environment.

Start remote desktop client from search or you can also run mstsc command at run prompt.

Enter the IP address of your remote machine Computer field.

Then click on Show Options, and click on Display tab. Select True Colour (24 bit) from the dropdown menu of Colours.

Finally click Connect button and you will see a warning saying that the identity of remote machine is not verified, click OK to proceed and you will see the prompt to enter the username and password of your remote machine.

Once you are logged in, you will see the following screen.

Conclusion

In this tutorial we have learned to install different graphical environments. We also learned to install XRDP to enable RDP server on your system. We also learnt to connect to your remote machine using windows Remote Desktop Client.

openvz quick installation (legacy for centos 6)

This article is for legacy installation of openvz on centos 6.

This document briefly describes the steps needed to install legacy OpenVZ on your RHEL 6 (CentOS 6, Scientific Linux 6) machine.

Requirements

This guide assumes you are running RHEL (CentOS, Scientific Linux) 6 on your system. Currently, this is a recommended platform to run OpenVZ on.

/vz file system

It is recommended to use a separate partition for containers (by default /vz) and format it to ext4.

yum pre-setup

Download openvz.repo file and put it to your /etc/yum.repos.d/ repository:

wget -P /etc/yum.repos.d/ https://download.openvz.org/openvz.repo

Import OpenVZ GPG key used for signing RPM packages:

rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

To make sure that you are downloading tamper free versions of the signed packages you should verify the fingerprint of the key you imported into the rpm key database as described on the Package signatures page.

Kernel installation

Limited OpenVZ functionality is supported when you run a recent 3.x kernel (check vzctl for upstream kernel, so OpenVZ kernel installation is optional but still recommended.

# yum install vzkernel

System configuration

Please make sure the following steps are performed before rebooting into OpenVZ kernel.

sysctl

There are a number of kernel parameters that should be set for OpenVZ to work correctly. These parameters are stored in /etc/sysctl.conf file. Here are the relevant portions of the file; please edit accordingly.

# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

# Enables source route verification
net.ipv4.conf.all.rp_filter = 1

# Enables the magic-sysrq key
kernel.sysrq = 1

# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

SELinux

SELinux should be disabled. Put SELINUX=disabled to /etc/sysconfig/selinux:

echo "SELINUX=disabled" > /etc/sysconfig/selinux

Tools installation

Before installing tools, please read about vzstats and opt-out if you don’t want to help the project.

OpenVZ needs some user-level tools installed:

# yum install vzctl vzquota ploop

Reboot into OpenVZ

Now reboot the machine and choose “OpenVZ” on the boot loader menu (it should be default choice).

Download OS templates

An OS template is a Linux distribution installed into a container and then packed into a gzipped tarball. Using such a cache, a new container can be created in a minute.

Download precreated template caches from Downloads » Templates » Precreated, or directly from download.openvz.org/template/precreated, or from one of the mirrors. Put those tarballs as-is (no unpacking needed) to the /vz/template/cache/ directory.

How to format disk on linux

Introduction
Preparing a new disk for use on a Linux system can be quick and easy. There are many tools, filesystem formats, and partitioning schemes that may complicate the process if you have specialized needs, but if you want to get up and running quickly, it’s fairly straightforward.

This guide will cover the following process:

Identifying the new disk on the system.
Creating a single partition that spans the entire drive (most operating systems expect a partition layout, even if only one filesystem is present)
Formatting the partition with the Ext4 filesystem (the default in most modern Linux distributions)
Mounting and setting up Auto-mounting of the filesystem at boot
Install the Tools
To partition the drive, we’ll use the parted utility. In most cases, this will already be installed on the server.

If you are on an Ubuntu or Debian server and do not have parted yet, you can install it by typing:

sudo apt-get update
sudo apt-get install parted
If you are on a CentOS or Fedora server, you can install it by typing:

sudo yum install parted
Identify the New Disk on the System
Before we set up the drive, we need to be able to properly identify it on the server.

If this is a completely new drive, the easiest way to find it on your server may be to look for the absence of a partitioning scheme. If we ask parted to list the partition layout of our disks, it will give us an error for any disks that don’t have a valid partition scheme. This can be used to help us identify the new disk:

sudo parted -l | grep Error
You should see an unrecognized disk label error for the new, unpartitioned disk:

Output
Error: /dev/sda: unrecognised disk label
You can also use the lsblk command and look for a disk of the correct size that has no associated partitions:

lsblk
Output
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
vda 253:0 0 20G 0 disk
└─vda1 253:1 0 20G 0 part /
Warning
Remember to check lsblk in every session before making changes. The /dev/sd* and /dev/hd* disk identifiers will not necessarily be consistent between boots, which means there is some danger of partitioning or formatting the wrong disk if you do not verify the disk identifier correctly.

Consider using more persistent disk identifiers like /dev/disk/by-uuid, /dev/disk/by-label, or /dev/disk/by-id. See our introduction to storage concepts and terminology in Linux article for more information.

When you know the name the kernel has assigned your disk, you can partition your drive.

Partition the New Drive
As mentioned in the introduction, we’ll create a single partition spanning the entire disk in this guide.

Choose a Partitioning Standard
To do this, we first need to specify the partitioning standard we wish to use. GPT is the more modern partitioning standard, while the MBR standard offers wider support among operating systems. If you do not have any special requirements, it is probably better to use GPT at this point.

To choose the GPT standard, pass in the disk you identified like this:

sudo parted /dev/sda mklabel gpt
If you wish to use the MBR format, type this instead:

sudo parted /dev/sda mklabel msdos
Create the New Partition
Once the format is selected, you can create a partition spanning the entire drive by typing:

sudo parted -a opt /dev/sda mkpart primary ext4 0% 100%
If we check lsblk, we should see the new partition available:

lsblk
Output
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
└─sda1 8:1 0 100G 0 part
vda 253:0 0 20G 0 disk
└─vda1 253:1 0 20G 0 part /
Create a Filesystem on the New Partition
Now that we have a partition available, we can format it as an Ext4 filesystem. To do this, pass the partition to the mkfs.ext4 utility.

We can add a partition label by passing the -L flag. Select a name that will help you identify this particular drive:

note
Make sure you pass in the partition and not the entire disk. In Linux, disks have names like sda, sdb, hda, etc. The partitions on these disks have a number appended to the end. So we would want to use something like sda1 and not sda.
sudo mkfs.ext4 -L datapartition /dev/sda1
If you want to change the partition label at a later date, you can use the e2label command:

sudo e2label /dev/sda1 newlabel
You can see all of the different ways to identify your partition with lsblk. We want to find the name, label, and UUID of the partition.

Some versions of lsblk will print all of this information if we type:

sudo lsblk –fs
If your version does not show all of the appropriate fields, you can request them manually:

sudo lsblk -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT
You should see something like this. The highlighted output indicate different methods you can use to refer to the new filesystem:

Output
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
└─sda1 ext4 datapartition 4b313333-a7b5-48c1-a957-d77d637e4fda
vda
└─vda1 ext4 DOROOT 050e1e34-39e6-4072-a03e-ae0bf90ba13a /
Mount the New Filesystem
Now, we can mount the filesystem for use.

The Filesystem Hierarchy Standard recommends using /mnt or a subdirectory under it for temporarily mounted filesystems. It makes no recommendations on where to mount more permanent storage, so you can choose whichever scheme you’d like. For this tutorial, we’ll mount the drive under /mnt/data.

Create the directory by typing:

sudo mkdir -p /mnt/data
Mounting the Filesystem Temporarily
You can mount the filesystem temporarily by typing:

sudo mount -o defaults /dev/sda1 /mnt/data
Mounting the Filesystem Automatically at Boot
If you wish to mount the filesystem automatically each time the server boots, adjust the /etc/fstab file:

sudo nano /etc/fstab
Earlier, we issued a sudo lsblk –fs command to display three filesystem identifiers for our filesystem. We can use any of these in this file. We’ve used the partition label below, but you can see what the lines would look like using the other two identifiers in the commented out lines:

/etc/fstab
. . .
## Use one of the identifiers you found to reference the correct partition
# /dev/sda1 /mnt/data ext4 defaults 0 2
# UUID=4b313333-a7b5-48c1-a957-d77d637e4fda /mnt/data ext4 defaults 0 2
LABEL=datapartition /mnt/data ext4 defaults 0 2
Note
You can learn about the various fields in the /etc/fstab file by typing man fstab. For information about the mount options available for a specific filesystem type, check man [filesystem] (like man ext4). For now, the mount lines above should get you started.

For SSDs, the discard option is sometimes appended to enable continuous TRIM. There is debate over the performance and integrity impacts of performing continuous TRIM in this manner, and most distributions include method of performing periodic TRIM as an alternative.

Save and close the file when you are finished.

If you did not mount the filesystem previously, you can now mount it by typing:

sudo mount -a
Testing the Mount
After we’ve mounted the volume, we should check to make sure that the filesystem is accessible.

We can check if the the disk is available in the output from the df command:

df -h -x tmpfs -x devtmpfs
Output
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 1.3G 18G 7% /
/dev/sda1 99G 60M 94G 1% /mnt/data
You should also be able to see a lost+found directory within the /mnt/data directory, which typically indicates the root of an Ext* filesystem:

ls -l /mnt/data
Output
total 16
drwx—— 2 root root 16384 Jun 6 11:10 lost+found
We can also check that the file mounted with read and write capabilities by writing to a test file:

echo “success” | sudo tee /mnt/data/test_file
Read the file back just to make sure the write executed correctly:

cat /mnt/data/test_file
Output
success
You can remove the file after you have verified that the new filesystem is functioning correctly:

sudo rm /mnt/data/test_file
Conclusion
Your new drive should now be partitioned, formatted, mounted, and ready for use. This is the general process you can use turn a raw disk into a filesystem that Linux can use for storage. There are more complex methods of partitioning, formatting, and mounting which may be more appropriate in some cases, but the above is a good starting point for general use.

How to setup BIND nameserver on centos

Introduction
An important part of managing server configuration and infrastructure includes maintaining an easy way to look up network interfaces and IP addresses by name, by setting up a proper Domain Name System (DNS). Using fully qualified domain names (FQDNs), instead of IP addresses, to specify network addresses eases the configuration of services and applications, and increases the maintainability of configuration files. Setting up your own DNS for your private network is a great way to improve the management of your servers.

In this tutorial, we will go over how to set up an internal DNS server, using the BIND name server software (BIND9) on CentOS 7, that can be used by your Virtual Private Servers (VPS) to resolve private host names and private IP addresses. This provides a central way to manage your internal hostnames and private IP addresses, which is indispensable when your environment expands to more than a few hosts.

The Ubuntu version of this tutorial can be found here.

Prerequisites
To complete this tutorial, you will need the following:

Some servers that are running in the same datacenter and have private networking enabled
A new VPS to serve as the Primary DNS server, ns1
Optional: A new VPS to serve as a Secondary DNS server, ns2
Root access to all of the above (steps 1-4 here)
If you are unfamiliar with DNS concepts, it is recommended that you read at least the first three parts of our Introduction to Managing DNS.

Example Hosts
For example purposes, we will assume the following:

We have two existing VPS called “host1” and “host2”
Both VPS exist in the nyc3 datacenter
Both VPS have private networking enabled (and are on the 10.128.0.0/16 subnet)
Both VPS are somehow related to our web application that runs on “example.com”
With these assumptions, we decide that it makes sense to use a naming scheme that uses “nyc3.example.com” to refer to our private subnet or zone. Therefore, host1’s private Fully-Qualified Domain Name (FQDN) will be “host1.nyc3.example.com”. Refer to the following table the relevant details:

Host Role Private FQDN Private IP Address
host1 Generic Host 1 host1.nyc3.example.com 10.128.100.101
host2 Generic Host 2 host2.nyc3.example.com 10.128.200.102
Note: Your existing setup will be different, but the example names and IP addresses will be used to demonstrate how to configure a DNS server to provide a functioning internal DNS. You should be able to easily adapt this setup to your own environment by replacing the host names and private IP addresses with your own. It is not necessary to use the region name of the datacenter in your naming scheme, but we use it here to denote that these hosts belong to a particular datacenter’s private network. If you utilize multiple datacenters, you can set up an internal DNS within each respective datacenter.

Our Goal
By the end of this tutorial, we will have a primary DNS server, ns1, and optionally a secondary DNS server, ns2, which will serve as a backup.

Here is a table with example names and IP addresses:

Host Role Private FQDN Private IP Address
ns1 Primary DNS Server ns1.nyc3.example.com 10.128.10.11
ns2 Secondary DNS Server ns2.nyc3.example.com 10.128.20.12
Let’s get started by installing our Primary DNS server, ns1.

Install BIND on DNS Servers
Note: Text that is highlighted in red is important! It will often be used to denote something that needs to be replaced with your own settings or that it should be modified or added to a configuration file. For example, if you see something like host1.nyc3.example.com, replace it with the FQDN of your own server. Likewise, if you see host1_private_IP, replace it with the private IP address of your own server.

On both DNS servers, ns1 and ns2, install BIND with yum:

sudo yum install bind bind-utils
Confirm the prompt by entering y.

Now that BIND is installed, let’s configure the primary DNS server.

Configure Primary DNS Server
BIND’s configuration consists of multiple files, which are included from the main configuration file, named.conf. These filenames begin with “named” because that is the name of the process that BIND runs. We will start with configuring the options file.

Configure Bind
BIND’s process is known as named. As such, many of the files refer to “named” instead of “BIND”.

On ns1, open the named.conf file for editing:

sudo vi /etc/named.conf
Above the existing options block, create a new ACL block called “trusted”. This is where we will define list of clients that we will allow recursive DNS queries from (i.e. your servers that are in the same datacenter as ns1). Using our example private IP addresses, we will add ns1, ns2, host1, and host2 to our list of trusted clients:

/etc/named.conf — 1 of 4
acl “trusted” {
10.128.10.11; # ns1 – can be set to localhost
10.128.20.12; # ns2
10.128.100.101; # host1
10.128.200.102; # host2
};
Now that we have our list of trusted DNS clients, we will want to edit the options block. Add the private IP address of ns1 to the listen-on port 53 directive, and comment out the listen-on-v6 line:

/etc/named.conf — 2 of 4
options {
listen-on port 53 { 127.0.0.1; 10.128.10.11; };
# listen-on-v6 port 53 { ::1; };

Below those entries, change the allow-transfer directive to from “none” to ns2’s private IP address. Also, change allow-query directive from “localhost” to “trusted”:

/etc/named.conf — 3 of 4

options {

allow-transfer { 10.128.20.12; }; # disable zone transfers by default

allow-query { trusted; }; # allows queries from “trusted” clients

At the end of the file, add the following line:

/etc/named.conf — 4 of 4
include “/etc/named/named.conf.local”;
Now save and exit named.conf. The above configuration specifies that only your own servers (the “trusted” ones) will be able to query your DNS server.

Next, we will configure the local file, to specify our DNS zones.

Configure Local File
On ns1, open the named.conf.local file for editing:

sudo vi /etc/named/named.conf.local
The file should be empty. Here, we will specify our forward and reverse zones.

Add the forward zone with the following lines (substitute the zone name with your own):

/etc/named/named.conf.local — 1 of 2
zone “nyc3.example.com” {
type master;
file “/etc/named/zones/db.nyc3.example.com”; # zone file path
};
Assuming that our private subnet is 10.128.0.0/16, add the reverse zone by with the following lines (note that our reverse zone name starts with “128.10” which is the octet reversal of “10.128”):

/etc/named/named.conf.local — 2 of 2
zone “128.10.in-addr.arpa” {
type master;
file “/etc/named/zones/db.10.128”; # 10.128.0.0/16 subnet
};
If your servers span multiple private subnets but are in the same datacenter, be sure to specify an additional zone and zone file for each distinct subnet. When you are finished adding all of your desired zones, save and exit the named.conf.local file.

Now that our zones are specified in BIND, we need to create the corresponding forward and reverse zone files.

Create Forward Zone File
The forward zone file is where we define DNS records for forward DNS lookups. That is, when the DNS receives a name query, “host1.nyc3.example.com” for example, it will look in the forward zone file to resolve host1’s corresponding private IP address.

Let’s create the directory where our zone files will reside. According to our named.conf.local configuration, that location should be /etc/named/zones:

sudo chmod 755 /etc/named
sudo mkdir /etc/named/zones
Now let’s edit our forward zone file:

sudo vi /etc/named/zones/db.nyc3.example.com
First, you will want to add the SOA record. Replace the highlighted ns1 FQDN with your own FQDN, then replace the second “nyc3.example.com” with your own domain. Every time you edit a zone file, you should increment the serial value before you restart the named process–we will increment it to “3”. It should look something like this:

/etc/named/zones/db.nyc3.example.com — 1 of 3
@ IN SOA ns1.nyc3.example.com. admin.nyc3.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
After that, add your nameserver records with the following lines (replace the names with your own). Note that the second column specifies that these are “NS” records:

/etc/named/zones/db.nyc3.example.com — 2 of 3
; name servers – NS records
IN NS ns1.nyc3.example.com.
IN NS ns2.nyc3.example.com.
Then add the A records for your hosts that belong in this zone. This includes any server whose name we want to end with “.nyc3.example.com” (substitute the names and private IP addresses). Using our example names and private IP addresses, we will add A records for ns1, ns2, host1, and host2 like so:

/etc/named/zones/db.nyc3.example.com — 3 of 3
; name servers – A records
ns1.nyc3.example.com. IN A 10.128.10.11
ns2.nyc3.example.com. IN A 10.128.20.12

; 10.128.0.0/16 – A records
host1.nyc3.example.com. IN A 10.128.100.101
host2.nyc3.example.com. IN A 10.128.200.102
Save and exit the db.nyc3.example.com file.

Our final example forward zone file looks like the following:

/etc/named/zones/db.nyc3.example.com — complete
$TTL 604800
@ IN SOA ns1.nyc3.example.com. admin.nyc3.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
; name servers – NS records
IN NS ns1.nyc3.example.com.
IN NS ns2.nyc3.example.com.

; name servers – A records
ns1.nyc3.example.com. IN A 10.128.10.11
ns2.nyc3.example.com. IN A 10.128.20.12

; 10.128.0.0/16 – A records
host1.nyc3.example.com. IN A 10.128.100.101
host2.nyc3.example.com. IN A 10.128.200.102
Now let’s move onto the reverse zone file(s).

Create Reverse Zone File(s)
Reverse zone file are where we define DNS PTR records for reverse DNS lookups. That is, when the DNS receives a query by IP address, “10.128.100.101” for example, it will look in the reverse zone file(s) to resolve the corresponding FQDN, “host1.nyc3.example.com” in this case.

On ns1, for each reverse zone specified in the named.conf.local file, create a reverse zone file.

Edit the reverse zone file that corresponds to the reverse zone(s) defined in named.conf.local:

sudo vi /etc/named/zones/db.10.128
In the same manner as the forward zone file, replace the highlighted ns1 FQDN with your own FQDN, then replace the second “nyc3.example.com” with your own domain. Every time you edit a zone file, you should increment the serial value before you restart the named process–we will increment it to “3”. It should look something like this:

/etc/named/zones/db.10.128 — 1 of 3
@ IN SOA ns1.nyc3.example.com. admin.nyc3.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
After that, add your nameserver records with the following lines (replace the names with your own). Note that the second column specifies that these are “NS” records:

/etc/named/zones/db.10.128 — 2 of 3
; name servers – NS records
IN NS ns1.nyc3.example.com.
IN NS ns2.nyc3.example.com.
Then add PTR records for all of your servers whose IP addresses are on the subnet of the zone file that you are editing. In our example, this includes all of our hosts because they are all on the 10.128.0.0/16 subnet. Note that the first column consists of the last two octets of your servers’ private IP addresses in reversed order. Be sure to substitute names and private IP addresses to match your servers:

/etc/named/zones/db.10.128 — 3 of 3
; PTR Records
11.10 IN PTR ns1.nyc3.example.com. ; 10.128.10.11
12.20 IN PTR ns2.nyc3.example.com. ; 10.128.20.12
101.100 IN PTR host1.nyc3.example.com. ; 10.128.100.101
102.200 IN PTR host2.nyc3.example.com. ; 10.128.200.102
Save and exit the reverse zone file (repeat this section if you need to add more reverse zone files).

Our final example reverse zone file looks like the following:

/etc/named/zones/db.10.128 — complete
$TTL 604800
@ IN SOA nyc3.example.com. admin.nyc3.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
; name servers
IN NS ns1.nyc3.example.com.
IN NS ns2.nyc3.example.com.

; PTR Records
11.10 IN PTR ns1.nyc3.example.com. ; 10.128.10.11
12.20 IN PTR ns2.nyc3.example.com. ; 10.128.20.12
101.100 IN PTR host1.nyc3.example.com. ; 10.128.100.101
102.200 IN PTR host2.nyc3.example.com. ; 10.128.200.102
Check BIND Configuration Syntax
Run the following command to check the syntax of the named.conf* files:

sudo named-checkconf
If your named configuration files have no syntax errors, you will return to your shell prompt and see no error messages. If there are problems with your configuration files, review the error message and the Configure Primary DNS Server section, then try named-checkconf again.

The named-checkzone command can be used to check the correctness of your zone files. Its first argument specifies a zone name, and the second argument specifies the corresponding zone file, which are both defined in named.conf.local.

For example, to check the “nyc3.example.com” forward zone configuration, run the following command (change the names to match your forward zone and file):

sudo named-checkzone nyc3.example.com /etc/named/zones/db.nyc3.example.com
And to check the “128.10.in-addr.arpa” reverse zone configuration, run the following command (change the numbers to match your reverse zone and file):

sudo named-checkzone 128.10.in-addr.arpa /etc/named/zones/db.10.128
When all of your configuration and zone files have no errors in them, you should be ready to restart the BIND service.

Start BIND
Start BIND:

sudo systemctl start named
Now you will want to enable it, so it will start on boot:

sudo systemctl enable named
Your primary DNS server is now setup and ready to respond to DNS queries. Let’s move on to creating the secondary DNS server.

Configure Secondary DNS Server
In most environments, it is a good idea to set up a secondary DNS server that will respond to requests if the primary becomes unavailable. Luckily, the secondary DNS server is much easier to configure.

On ns2, edit the named.conf file:

sudo vi /etc/named.conf
Note: If you prefer to skip these instructions, you can copy ns1’s named.conf file and modify it to listen on ns2’s private IP address, and not allow transfers.

Above the existing options block, create a new ACL block called “trusted”. This is where we will define list of clients that we will allow recursive DNS queries from (i.e. your servers that are in the same datacenter as ns1). Using our example private IP addresses, we will add ns1, ns2, host1, and host2 to our list of trusted clients:

/etc/named.conf — 1 of 4
acl “trusted” {
10.128.10.11; # ns1 – can be set to localhost
10.128.20.12; # ns2
10.128.100.101; # host1
10.128.200.102; # host2
};
Now that we have our list of trusted DNS clients, we will want to edit the options block. Add the private IP address of ns1 to the listen-on port 53 directive, and comment out the listen-on-v6 line:

/etc/named.conf — 2 of 4
options {
listen-on port 53 { 127.0.0.1; 10.128.20.12; };
# listen-on-v6 port 53 { ::1; };

Change allow-query directive from “localhost” to “trusted”:

/etc/named.conf — 3 of 4

options {

allow-query { trusted; }; # allows queries from “trusted” clients

At the end of the file, add the following line:

/etc/named.conf — 4 of 4
include “/etc/named/named.conf.local”;
Now save and exit named.conf. The above configuration specifies that only your own servers (the “trusted” ones) will be able to query your DNS server.

Next, we will configure the local file, to specify our DNS zones.

Save and exit named.conf.

Now edit the named.conf.local file:

sudo chmod 755 /etc/named
sudo vi /etc/named/named.conf.local
Define slave zones that correspond to the master zones on the primary DNS server. Note that the type is “slave”, the file does not contain a path, and there is a masters directive which should be set to the primary DNS server’s private IP. If you defined multiple reverse zones in the primary DNS server, make sure to add them all here:

/etc/named/named.conf.local
zone “nyc3.example.com” {
type slave;
file “slaves/db.nyc3.example.com”;
masters { 10.128.10.11; }; # ns1 private IP
};

zone “128.10.in-addr.arpa” {
type slave;
file “slaves/db.10.128”;
masters { 10.128.10.11; }; # ns1 private IP
};
Now save and exit named.conf.local.

Run the following command to check the validity of your configuration files:

sudo named-checkconf
Once that checks out, start BIND:

sudo systemctl start named
Enable BIND to start on boot:

sudo systemctl enable named
Now you have primary and secondary DNS servers for private network name and IP address resolution. Now you must configure your servers to use your private DNS servers.

Configure DNS Clients
Before all of your servers in the “trusted” ACL can query your DNS servers, you must configure each of them to use ns1 and ns2 as nameservers. This process varies depending on OS, but for most Linux distributions it involves adding your name servers to the /etc/resolv.conf file.

CentOS Clients
On CentOS, RedHat, and Fedora Linux VPS, simply edit the resolv.conf file:

sudo vi /etc/resolv.conf
Then add the following lines to the TOP of the file (substitute your private domain, and ns1 and ns2 private IP addresses):

/etc/resolv.conf
search nyc3.example.com # your private domain
nameserver 10.128.10.11 # ns1 private IP address
nameserver 10.128.20.12 # ns2 private IP address
Now save and exit. Your client is now configured to use your DNS servers.

Ubuntu Clients
On Ubuntu and Debian Linux VPS, you can edit the head file, which is prepended to resolv.conf on boot:

sudo vi /etc/resolvconf/resolv.conf.d/head
Add the following lines to the file (substitute your private domain, and ns1 and ns2 private IP addresses):

/etc/resolvconf/resolv.conf.d/head
search nyc3.example.com # your private domain
nameserver 10.128.10.11 # ns1 private IP address
nameserver 10.128.20.12 # ns2 private IP address
Now run resolvconf to generate a new resolv.conf file:

sudo resolvconf -u
Your client is now configured to use your DNS servers.

Test Clients
Use nslookup—included in the “bind-utils” package—to test if your clients can query your name servers. You should be able to do this on all of the clients that you have configured and are in the “trusted” ACL.

Forward Lookup
For example, we can perform a forward lookup to retrieve the IP address of host1.nyc3.example.com by running the following command:

nslookup host1
Querying “host1” expands to “host1.nyc3.example.com because of the search option is set to your private subdomain, and DNS queries will attempt to look on that subdomain before looking for the host elsewhere. The output of the command above would look like the following:

Output:
Server: 10.128.10.11
Address: 10.128.10.11#53

Name: host1.nyc3.example.com
Address: 10.128.100.101
Reverse Lookup
To test the reverse lookup, query the DNS server with host1’s private IP address:

nslookup 10.128.100.101
You should see output that looks like the following:

Output:
Server: 10.128.10.11
Address: 10.128.10.11#53

11.10.128.10.in-addr.arpa name = host1.nyc3.example.com.
If all of the names and IP addresses resolve to the correct values, that means that your zone files are configured properly. If you receive unexpected values, be sure to review the zone files on your primary DNS server (e.g. db.nyc3.example.com and db.10.128).

Congratulations! Your internal DNS servers are now set up properly! Now we will cover maintaining your zone records.

Maintaining DNS Records
Now that you have a working internal DNS, you need to maintain your DNS records so they accurately reflect your server environment.

Adding Host to DNS
Whenever you add a host to your environment (in the same datacenter), you will want to add it to DNS. Here is a list of steps that you need to take:

Primary Nameserver
Forward zone file: Add an “A” record for the new host, increment the value of “Serial”
Reverse zone file: Add a “PTR” record for the new host, increment the value of “Serial”
Add your new host’s private IP address to the “trusted” ACL (named.conf.options)
Then reload BIND:

sudo systemctl reload named
Secondary Nameserver
Add your new host’s private IP address to the “trusted” ACL (named.conf.options)
Then reload BIND:

sudo systemctl reload named
Configure New Host to Use Your DNS
Configure resolv.conf to use your DNS servers
Test using nslookup
Removing Host from DNS
If you remove a host from your environment or want to just take it out of DNS, just remove all the things that were added when you added the server to DNS (i.e. the reverse of the steps above).

Conclusion
Now you may refer to your servers’ private network interfaces by name, rather than by IP address. This makes configuration of services and applications easier because you no longer have to remember the private IP addresses, and the files will be easier to read and understand. Also, now you can change your configurations to point to a new servers in a single place, your primary DNS server, instead of having to edit a variety of distributed configuration files, which eases maintenance.

Once you have your internal DNS set up, and your configuration files are using private FQDNs to specify network connections, it is critical that your DNS servers are properly maintained. If they both become unavailable, your services and applications that rely on them will cease to function properly. This is why it is recommended to set up your DNS with at least one secondary server, and to maintain working backups of all of them.

how to create network bridge on centos 7

during configuring KVM, you’ll need to configure a network bridge sometimes if you want your container to be accessed directly from outside world.

Install Module
centos 7 comes with bridging module loaded on the system boot by default. use the following command to verify whether the module is loaded or not

[[email protected] ~]# modinfo bridge
filename: /lib/modules/3.10.0-693.el7.x86_64/kernel/net/bridge/bridge.ko.xz
alias: rtnl-link-bridge
version: 2.3
license: GPL
rhelversion: 7.4
srcversion: 188FE82E919189D8DCBCF21
depends: stp,llc
intree: Y
vermagic: 3.10.0-693.el7.x86_64 SMP mod_unload modversions
signer: CentOS Linux kernel signing key
sig_key: DA:18:7D:CA:7D:BE:53:AB:05:BD:13:BD:0C:4E:21:F4:22:B6:A4:9C
sig_hashalgo: sha256

if the module is not loaded, you can load with this command
modprobe –first-time bridge

install bridge-utls for controlling network adapators
yum install bridge-utils -y

Create a Network Bridge on CentOS 7

To create a network bridge, create a file called “ifcfg-virbrN” replacing “N” with a number, such as “0” in the “/etc/sysconfig/network-scripts/“.

# vi /etc/sysconfig/network-scripts/ifcfg-virbr0

If you would like to use the different name for network bridge, then create a file like ifcfg-. Also, update the DEVICE=”” line in the configuration file.

Place the following content into that file, modify it according to your environment.

DEVICE=”virbr0″
BOOTPROTO=”static”
IPADDR=”192.168.12.10″
NETMASK=”255.255.255.0″
GATEWAY=”192.168.12.2″
DNS1=192.168.12.2
ONBOOT=”yes”
TYPE=”Bridge”
NM_CONTROLLED=”no”

Now, it’s the time to modify the network configuration of the existing adaptor in such a way that it points to a bridge interface.

In this guide, I will use my existing adaptor “eno16777736” for bridging.

# vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

Place the content like below.

DEVICE=eno16777736
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
NM_CONTROLLED=no
BRIDGE=virbr0

Restart the network using the following command.

# systemctl restart network

Use ifconfig command to see interface details.

# ifconfig
eno16777736: flags=4163 mtu 1500
inet6 fe80::20c:29ff:fe6a:692 prefixlen 64 scopeid 0x20
ether 00:0c:29:6a:06:92 txqueuelen 1000 (Ethernet)
RX packets 3822 bytes 302382 (295.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 192 bytes 42924 (41.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4163 mtu 1500
inet 192.168.12.10 netmask 255.255.255.0 broadcast 192.168.12.255
inet6 fe80::20c:29ff:fe6a:692 prefixlen 64 scopeid 0x20
ether 00:0c:29:6a:06:92 txqueuelen 0 (Ethernet)
RX packets 1454 bytes 109258 (106.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 179 bytes 34372 (33.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

how to fix nginx php-fpm 404 error

Ok, you installed nginx and php-fpm, and happily to open your browser and entered the url, waiting for the page to load, suddenly you saw this nginx 404 error.

So you went to check your nginx configure file and made sure the webroot is correct and file permission is correct, which means they’re readable by nginx and php-fpm user.

You thought you fix the error and went back to the browser and try again, still, the 404 error.

Then you went to google and found a lot of threads from stackoverflow and serverfault, everybody is talking about file/folder permission as that’s really what 404’s root cause.

It took me quite some time to figure out the real reason for my situation. I launched a droplet from digital ocean with latest centos 7 and encountered this error.

The real cause is actually the linux is by default have linux security featured on, you have to disable it
After I ran this command, then everything is ok
setenforce 0

Hope this will help somebody later on.

migrate nextcloud to docker after failing upgrade from 12 to 13

I tried to move nextcloud to a new machine with more disk space and upgrade from 12 to 13.

I followed the steps from here to manually upgrade the package from here docs.nextcloud.com/server/13/admin_manual/maintenance/manual_upgrade.html

I downloaded the zip file and unzip it, then move the old config and data files to the new installed folder

and run the command to upgrade
sudo -u php-fpm php occ upgrade

then it complains about utf8mb4 unique key over 767 bytes, it turned out that my mariadb 10.3 is causing the issue.
Then installed MariaDB of 10.2
add mariadb.repo to /etc/yum.repos.d

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Then yum install mariadb mariadb-server

with 10.2 the utf8mb4 short unique key error is gone.

Go back to upgrade nextcloud and it was successful.

However now got another error when tried to access from browser, a lot of missing file errors like the following
2018/03/10 01:00:59 [error] 21678#0: *3145 open() “/var/www/nextcloud/index.php/js/core/merged-template-prepend.js” failed (20: Not a directory), client: xx.xx.xx.xx, server: xxxxx, request: “GET /index.php/js/core/merged-template-prepend.js?v=262b927e01e9d6c4148bbbba7b151ff3-0 HTTP/1.1”,

I googled and found this ticket github.com/nextcloud/server/issues/6540 and it said the error was fixed, i applied the fix from github.com/nextcloud/server/pull/8250 by changing the file of lib/private/Files/ObjectStore/Swift.php
Still got no luck, the missing file errors still exist.

At this stage, I turned my solution to docker containers so I don’t have to maintain all these upgrades and setup myself

Trying follow the steps here github.com/nextcloud/docker

1) yum install docker and docker-compose
make sure you have epel-release is installed before running this command by yum install epel-release

2) create docker-composer.yml
with the following, make sure set MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD
cd /data/docker
vi docker-compose.yml


services:
db:
image: mariadb
restart: always
volumes:
- /data/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_PASSWORD=
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud

app:
image: nextcloud
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html
- /var/www/html/data:/var/www/html/data
- /var/www/html/config:/var/www/html/config
- /var/www/html/apps:/var/www/html/apps
restart: always

3) systemctl start docker
4) docker-compose up -d
5) setup the proxy server
the frontend nginx config

server {
listen 443;
server_name cloud.mydomain.com;
access_log /var/log/nginx/cloud.sslaccess.log ;
error_log /var/log/nginx/cloud.error.log;
ssl_certificate /etc/nginx/ssl/admin.crt;
ssl_certificate_key /etc/nginx/ssl/admin.key;
include /etc/nginx/nginx_proxy.conf;
}
### Default VH
server {
listen 80;
server_name cloud.mydomain.com;
access_log /var/log/nginx/cloud.access.log ;
error_log /var/log/nginx/cloud.error.log;
include /etc/nginx/nginx_proxy.conf;
}

the nginx_proxy.conf

location / {
proxy_pass http://backendip:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}

6) now go to browser cloud.mydomain.com, i can see this screen, good sign, this tells me the proxy is working well

nextcloud-frontend

7) migrate data
I had a dump of mysql from old machine, nextcloud.sql
docker cp ./nextcloud.sql docker_db_1:/dmp

8) cd to the folder where docker-compose.yml exists, then run
docker-compose exec db sh -c “mysql -u USER -pPASSWORD nextcloud < /dmp" 9) then delete the temp file docker-compose exec db rm /dmp 10) cp the previous config/config.php to /var/www/html/config folder on host and edit it set database host 'dbhost' => ‘db:3306’,
change datadirectory, ‘datadirectory’ => ‘/var/www/html/data’,

11) copy the data from previous machine to /var/www/html/data

12) change folder permission
cd to the folder where docker-compose.yml exists
docker-compose exec app chown -R www-data:www-data /var/www/html/data

13) docker cp ./apps/ nextcloud_data:/var/www/html/custom_apps
docker-compose exec app chown -R www-data:www-data /var/www/html/custom_apps
docker-compose exec app chown -R www-data:www-data /var/www/html/apps

14) go to frontend, the website is loaded correctly

setup openshift origin cluster on your own machine

RedHat provided a doc for installing openshift origin on your own cluster, however the docs are not that comprehensive
https://docs.openshift.org/latest/welcome/index.html

1) prerequisites
first of all, try to follow the instructions here for the prerequisites
https://docs.openshift.org/latest/install_config/install/prerequisites.html
The first very import thing is that you have to setup your own dns server first, it is not clear in the doc that it is required
basically use one of your hosts to configure as local dns server, e.g. you can use bind9
here is a good reference to configure bind9
https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-a-private-network-dns-server-on-centos-7
You can setup the local dns as something like project.openshift.local
configure each every host/node to use your local dns server
e.g.
[[email protected] log]# cat /etc/resolv.conf
# Generated by NetworkManager
search sy.openshift.local
nameserver 10.128.10.10
nameserver 10.128.10.20
nameserver 8.8.8.8

[[email protected] log]# ifconfig
eth0: flags=4163 mtu 1500
inet 10.128.10.11 netmask 255.255.255.0 broadcast 10.128.10.255
inet6 fe80::5054:ff:fe76:e806 prefixlen 64 scopeid 0x20 ether 52:54:00:76:e8:06 txqueuelen 1000 (Ethernet)
RX packets 27520 bytes 2589871 (2.4 MiB)
RX errors 0 dropped 41 overruns 0 frame 0
TX packets 2908 bytes 229605 (224.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

2) Host preparation

Here is the reference from the doc https://docs.openshift.org/latest/install_config/install/host_preparation.html
Yum install all the necessary packages and do a yum update after installation
Here is my current setup
master
node1
node2
ns1
have to install all the packages on all the nodes
make sure you can ssh as root from master to the other nodes, you can setup key authentication

on your master server, download the openshift client and server package, available from here
https://github.com/openshift/origin/releases
I put them all under one folder
[[email protected] openshift]# pwd
/data/openshift
[[email protected] openshift]# ls -al
total 39444
drwxr-xr-x. 5 root root 252 Feb 5 13:20 .
drwxr-xr-x. 4 root root 34 Feb 5 13:20 ..
lrwxrwxrwx. 1 root root 56 Feb 5 13:20 client -> openshift-origin-client-tools-v3.7.1-ab0f056-linux-64bit
drwxr-xr-x. 16 root root 4096 Feb 4 12:39 openshift-ansible
drwxr-xr-x. 2 root root 48 Feb 5 13:21 openshift-origin-client-tools-v3.7.1-ab0f056-linux-64bit
-rw-r–r–. 1 root root 40380234 Jan 16 12:48 openshift-origin-client-tools-v3.7.1-ab0f056-linux-64bit.tar.gz
drwxr-xr-x. 4 root root 4096 Feb 3 09:37 openshift-origin-server-v3.7.1-ab0f056-linux-64bit
lrwxrwxrwx. 1 root root 50 Feb 5 13:20 server -> openshift-origin-server-v3.7.1-ab0f056-linux-64bit

go to client and server folder to add the PATH
cd client
export PATH=$(pwd):$PATH
cd ../server
export PATH=$(pwd):$PATH

This will add the openshift related binaries to the PATH, so you can call the oc command

git clone https://github.com/openshift/openshift-ansible to /data/openshift folder also, you need this for RPM install later on

docker setup
Make sure you install docker 1.12.6
on my centos 7, i just used yum install docker, and it is the right docker version.

For docker-storage-setup, you better use the option A as in the doc, since actually I have all my hosts/nodes running on KVM, I just attached a device to each node as /dev/vdb, and use it for the docker-storage-setup
a good reference here for setting up kvm
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/virtualization_deployment_and_administration_guide

3) Install atomic and openshift stuff
yum install atomic
yum install atomic-openshift-utils

common virsh commands

As a rule, do not run any virsh commands as a background process as timeouts and errors can occur at unpredictable times.
Table 1. Common virsh command options: storage
Command option Description
virsh find-storage-pool-sources Creates an XML definition file for all storage pools of a specific type.
virsh pool-define-as pool_name path mountpoint Create a storage pool. Provide the name, the path to the storage, and a mount point on the local system.
virsh pool-list Lists all storage pools. To include inactive storage pools, add –all.
virsh pool-build pool_name Creates a mount point for the storage pool.
virsh pool-start pool_name Starts the storage pool
virsh pool-autostart pool_name Causes the pool to be started every time that libvirt is started. To disable this option, run virsh pool-autostart pool_name –disable.
virsh pool-info pool_name Displays information about the pool.
virsh vol-create-as pool_namevol_name size –format format_type Creates a volume. Specify the pool where the volume is located, the name of the volume, size of the image (in K, M, G, T), and the format of the volume.
virsh vol-list pool_name Lists the volumes in a pool. To include inactive volumes, add –details.
virsh vol-clone existing_vol_name new_vol_name –pool pool_name Copies and creates a volume in a storage pool.
virsh vol-delete –pool pool_name vol_name Deletes a volume from a storage pool.
virsh pool-destroy pool_name Stops a pool.
virsh pool-delete pool_name Deletes a pool directory from the host.
virsh pool-undefine pool_name Removes the pool definition.