Using udev rules with OL / RH7 on VMware Fusion

Preparing to use udev rules on VMware Fusion

Before you can use udev rules with your new VMware Hard Drives you need to update the Virtual Machines .vmx file and set the following.

disk.EnableUUID = “TRUE”

Without this setting the ‘/usr/lib/udev/scsci_id’ command will no values.

As with all configuration files it’s best practice to create a backup before editing, however this is especially true for the VMware Fusion .vmx file as any mistake can result in a Virtual Machine which will no longer boot.

Shutdown your Virtual Machine before you attempt any edits of the .vmx file.

Creating the udev rules

Once your edit is complete you can reboot your VM and confirm is working ok with ‘usr/lib/udev/scsci_id -g -u -d /dev/’ e.g.

[root@ol72 ~]# /usr/lib/udev/scsi_id –verbose -g -u -d /dev/sdc
36000c298d0c4d6c7ace0c7b990069f48
[root@ol72 ~]# /usr/lib/udev/scsi_id –verbose -g -u -d /dev/sdd
36000c290045c8d9e8660057e191ec523
[root@ol72 ~]# /usr/lib/udev/scsi_id –verbose -g -u -d /dev/sde
36000c29b6dc77c32663c5b8354fffd37
[root@ol72 ~]# /usr/lib/udev/scsi_id -g -u -d /dev/sde
36000c29b6dc77c32663c5b8354fffd37

Now you know the Disks unique ID’s you can add them to a new udev rule. e.g.

/etc/udev/rules.d/99-oracle-asmdevices.rules

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c298d0c4d6c7ace0c7b990069f48″, SYMLINK+=”dg_prod_oradata1″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c290045c8d9e8660057e191ec523″, SYMLINK+=”dg_prod_oraredo1″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

KERNEL==”sd?1″, SUBSYSTEM==”block”, PROGRAM==”/usr/lib/udev/scsi_id -g -u -d /dev/$parent”, RESULT==”36000c29b6dc77c32663c5b8354fffd37″, SYMLINK+=”dg_prod_orafra1″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

Unlike RedHat 5 & 6 there is no need to restart the udev service on RedHat 7

Testing the udev rules

You can now test the udev rules using udevadm test e.g.

udevadm test /block/sdb/sdb1

And check the results with ls -l /dev/

[root@ol72 dev]# ls -l /dev/sd*
brw-rw—- 1 root disk 8, 32 Oct 18 11:29 sdc
brw-rw—- 1 grid asmadmin 8, 33 Oct 18 11:49 sdc1
brw-rw—- 1 root disk 8, 48 Oct 18 11:29 sdd
brw-rw—- 1 grid asmadmin 8, 49 Oct 18 11:55 sdd1
brw-rw—- 1 root disk 8, 64 Oct 18 11:29 sde
brw-rw—- 1 grid asmadmin 8, 65 Oct 18 11:55 sde1

[root@ol72 dev]# ls -l /dev/dg*
lrwxrwxrwx 1 root root 4 Oct 18 11:49 /dev/dg_prod_oradata1 -> sdc1
lrwxrwxrwx 1 root root 4 Oct 18 11:55 /dev/dg_prod_orafra1 -> sde1
lrwxrwxrwx 1 root root 4 Oct 18 11:55 /dev/dg_prod_oraredo1 -> sdd1

Advertisements

Docker installation on Oracle Linux 7.2

Oracle Linux 7.2 Installation

To get ready for this Blog I performed a standard Linux 7.2 installation, during the ‘Software Selection’ part of the wizard selected ‘Base Environent’ of ‘Server with GUI’ and the following ‘Add-Ons for Selected Evironment’

  • Compatibility Libraries
  • Development Tools

If you need further install details, I have a seperate Blog posting on performing an Oracle Linux 7.2 installation.

Kernel Upgrade

The Oracle Linux R7 Update 2 ships with a 3.8.13 Kernel however Docker requires a Kernel of 4.1.12 or higher on Oracle Linux, this kernel supports the Docker btrfs storage engine on both Oracle Linux 6 and 7.

Oracle Linux Docker Prerequisites

With yum this is easliy fixed,  by telling yum to use the release 4 Kernel repository.

[root@oel7 ~]# uname -r
3.8.13-98.7.1.el7uek.x86_64

[root@oel7 ~]# yum list kernel-uek*
Loaded plugins: langpacks, ulninfo
Installed Packages
kernel-uek.x86_64                            3.8.13-98.7.1.el7uek        @anaconda/7.2
kernel-uek-devel.x86_64                3.8.13-98.7.1.el7uek       @anaconda/7.2
kernel-uek-firmware.noarch         3.8.13-98.7.1.el7uek       @anaconda/7.2
Available Packages
kernel-uek.x86_64                             3.8.13-118.10.2.el7uek   ol7_UEKR3
kernel-uek-debug.x86_64               3.8.13-118.10.2.el7uek   ol7_UEKR3
kernel-uek-debug-devel.x86_64  3.8.13-118.10.2.el7uek   ol7_UEKR3
kernel-uek-devel.x86_64                3.8.13-118.10.2.el7uek   ol7_UEKR3
kernel-uek-doc.noarch                     3.8.13-118.10.2.el7uek   ol7_UEKR3
kernel-uek-firmware.noarch          3.8.13-118.10.2.el7uek   ol7_UEKR3

OK, lets tell yum to use our new repository

[root@oel7 ~]# vi /etc/yum.repos.d/public-yum-ol7.repo

[ol7_UEKR3]
name=Latest Unbreakable Enterprise Kernel Release 3 for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR3/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=0

[ol7_UEKR4]
name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR4/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

[ol7_addons]
name=Oracle Linux $releasever Add ons ($basearch)
baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

As you can see from above I have disabled ol7_UEKR3, enabled the ol7_addons and added a new section form ol7_UEKR4, we can now use yum to pick up the new 4.1.12 Kernel.

[root@oel7 ~]# yum list kernel-uek*
Loaded plugins: langpacks, ulninfo
Installed Packages
kernel-uek.x86_64                             3.8.13-98.7.1.el7uek  @anaconda/7.2
kernel-uek-devel.x86_64                3.8.13-98.7.1.el7uek  @anaconda/7.2
kernel-uek-firmware.noarch         3.8.13-98.7.1.el7uek  @anaconda/7.2
Available Packages
kernel-uek.x86_64                             4.1.12-37.6.3.el7uek  ol7_UEKR4
kernel-uek-debug.x86_64               4.1.12-37.6.3.el7uek  ol7_UEKR4
kernel-uek-debug-devel.x86_64  4.1.12-37.6.3.el7uek  ol7_UEKR4
kernel-uek-devel.x86_64                4.1.12-37.6.3.el7uek  ol7_UEKR4
kernel-uek-doc.noarch                    4.1.12-37.6.3.el7uek  ol7_UEKR4
kernel-uek-firmware.noarch         4.1.12-37.6.3.el7uek  ol7_UEKR4

Ok lets let yum do it’s thing.
[root@oel7 ~]# yum update

Time for a coffee…

SELinux support on Oracle Linux 7

Docker requires SElinux to be set to Permissive or Disabled in /etc/sysconfig/selinux to use the btrfs storage engine on Oracle Linux 7, so lets change it now if not already set before we reboot.

[root@oel7 ~]# vi /etc/sysconfig/selinux

SELINUX=permissive

[root@oel7 ~]# setenforce Permissive

Reboot to pick up the new 4.1.12 Kernel

[root@oel7 ~]# uname -r
4.1.12-37.6.3.el7uek.x86_64

Docker 1.10

As we have updated the yum repository to use ol7_addons we can now install the docker engine.

[root@oel7 ~]# yum list docker-engine
Loaded plugins: langpacks, ulninfo
Available Packages
docker-engine.x86_64             1.10.3-1.0.3.el7   ol7_addons

[root@oel7 ~]# yum install docker-engine
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
–> Running transaction check
—> Package docker-engine.x86_64 0:1.10.3-1.0.3.el7 will be installed
–> Processing Dependency: docker-engine-selinux >= %{epoch}:1.10.3-1.0.3.el7 for package: docker-engine-1.10.3-1.0.3.el7.x86_64
–> Running transaction check
—> Package docker-engine-selinux.noarch 0:1.10.3-1.0.3.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
docker-engine x86_64 1.10.3-1.0.3.el7 ol7_addons 9.6 M
Installing for dependencies:
docker-engine-selinux noarch 1.10.3-1.0.3.el7 ol7_addons 28 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 9.6 M
Installed size: 41 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): docker-engine-selinux-1.10.3-1.0.3.el7.noarch.rpm | 28 kB 00:00:05
(2/2): docker-engine-1.10.3-1.0.3.el7.x86_64.rpm | 9.6 MB 00:00:13
————————————————————————————————————————————————
Total 710 kB/s | 9.6 MB 00:00:13
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-engine-selinux-1.10.3-1.0.3.el7.noarch 1/2
Installing : docker-engine-1.10.3-1.0.3.el7.x86_64 2/2
Verifying : docker-engine-1.10.3-1.0.3.el7.x86_64 1/2
Verifying : docker-engine-selinux-1.10.3-1.0.3.el7.noarch 2/2

Installed:
docker-engine.x86_64 0:1.10.3-1.0.3.el7

Dependency Installed:
docker-engine-selinux.noarch 0:1.10.3-1.0.3.el7

Complete!

[root@oel7 ~]# docker –version
Docker version 1.10.3, build 57bf6fd

Docker Installation Check

First let’s start the service

[root@oel7 ~]# systemctl start docker.service

Now we can check the docker with the ‘Hello World’ container.
[root@oel7 ~]# docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

Docker 1.12

If you want to use a slighty new version of docker you can go directly to the docker projects own yum repository, the Docker install check step is the same.

[root@oel7 ~]# cd /etc/yum.repos.d/
[root@oel7 yum.repos.d]# vi docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/oraclelinux/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

[root@oel7 yum.repos.d]# yum list docker-engine
Loaded plugins: langpacks, ulninfo
Available Packages
docker-engine.x86_64             1.12.0-1.el7       dockerrepo

[root@oel7 ~]# yum install docker-engine
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
–> Running transaction check
—> Package docker-engine.x86_64 0:1.12.0-1.el7 will be installed
–> Processing Dependency: docker-engine-selinux >= 1.12.0-1.el7 for package: docker-engine-1.12.0-1.el7.x86_64
–> Running transaction check
—> Package docker-engine-selinux.noarch 0:1.12.0-1.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================
Installing:
docker-engine x86_64 1.12.0-1.el7 dockerrepo 19 M
Installing for dependencies:
docker-engine-selinux noarch 1.12.0-1.el7 dockerrepo 28 k

Transaction Summary
=============================================================================================================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 19 M
Installed size: 79 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/dockerrepo/packages/docker-engine-selinux-1.12.0-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY00:00:34 ETA
Public key for docker-engine-selinux-1.12.0-1.el7.noarch.rpm is not installed
(1/2): docker-engine-selinux-1.12.0-1.el7.noarch.rpm | 28 kB 00:00:06
(2/2): docker-engine-1.12.0-1.el7.x86_64.rpm | 19 MB 00:00:22
—————————————————————————————————————————————————————————–
Total 851 kB/s | 19 MB 00:00:22
Retrieving key from https://yum.dockerproject.org/gpg
Importing GPG key 0x2C52609D:
Userid : “Docker Release Tool (releasedocker) <docker@docker.com>”
Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d
From : https://yum.dockerproject.org/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-engine-selinux-1.12.0-1.el7.noarch 1/2
restorecon: lstat(/var/lib/docker) failed: No such file or directory
warning: %post(docker-engine-selinux-1.12.0-1.el7.noarch) scriptlet failed, exit status 255
Non-fatal POSTIN scriptlet failure in rpm package docker-engine-selinux-1.12.0-1.el7.noarch
Installing : docker-engine-1.12.0-1.el7.x86_64 2/2
Verifying : docker-engine-selinux-1.12.0-1.el7.noarch 1/2
Verifying : docker-engine-1.12.0-1.el7.x86_64 2/2

Installed:
docker-engine.x86_64 0:1.12.0-1.el7

Dependency Installed:
docker-engine-selinux.noarch 0:1.12.0-1.el7

Complete!

[root@oel7 ~]# docker –version
Docker version 1.12.0, build 8eab29e