Oracle Linux ASM docker
In this setup we are:
- Installing docker
- Creating Non-root user (ynixon) with sudo and docker privileges
- ASM device: /dev/sdb1
- Enabling sqlnet + ssh to the container
- Default ASM port is 1521
- ssh port 2222
- Passwords for root + grid os users in the container are “ynixon”
- Password for sys ASM user is “ynixon”
- Grid software is 12.2 without any patches
- Container Operating system is Oracle Linux 7.5
- Within the container, there is no use of UDEV / ASMLIB or ASMFD – the asm_diskstring='/dev/asm*' ,'/dev/*'
- All test done on regular Ubuntu 14.04
- There is a crontab job to keep 15 days of trace files + remove audit files.
$ vi /etc/udev/rules.d/100-asm.rules KERNEL=="sdb1", NAME="ASM_DISK", OWNER="54421", GROUP="54421", MODE="0660" udevadm trigger --sysname-match=sdb1 --verboseDISK_GROUP=$( blkid | grep oracleasm | sed 's/.*LABEL=\"\([^\"]*\)\" TYPE=\"oracleasm\"/\1/')
if [ -z "$DISK_GROUP" ]
then
echo "device /dev/sdb1 has not asm metadata"
else
echo "device /dev/sdb1 has diskgroup $DISK_GROUP"
fiAs root
$ curl -fsSL https://get.docker.com/ | shOr
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo
$ apt-key add - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ apt-get update
$ apt-cache policy docker-ce
$ apt-get install -y docker-ce
$ service docker statusAs root Equivalent user ids to the docker to follow (will be identified from outside)
$ groupadd -g 54422 asmadmin
$ useradd -u 54421 -g 54422 gridA dedicated user to manage the docker
$ adduser ynixon -g 54422 $ echo "ynixon:ynixon" | chpasswd
$ usermod -aG docker ynixon
$ usermod -aG sudo ynixon
$ sed -i '/PasswordAuthentication/d' /etc/ssh/sshd_config
$ echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
$ sed -i '/PubkeyAuthentication/d' /etc/ssh/sshd_config
$ echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
$ sed -i '/ChallengeResponseAuthentication/d' /etc/ssh/sshd_config
$ echo "ChallengeResponseAuthentication no" >> /etc/ssh/sshd_config
$ service ssh reloadIf you already have an image file skip to Load image. In this step we will create a new image from scratch, and pack it at the end. You can run /depo/build.sh + /depo/export.sh or run the following manual steps:
As root
$ mkdir /depo/
$ chown -R root:54422 /depo/
$ chmod 775 /depo
$ git clone https://github.com/ynixon/OracleASMdocker.git /depo/Ensure you download the file linuxx64_12201_grid_home.zip and copy it to /depo/ folder
List of the files
| Script | Description |
|---|---|
| adrci_script.sh | A script to that will run for crontab to delete trace files periodically |
| build.sh | A script to build a docker image |
| clean.sh | A script to clean all docker containers and an image |
| crontab.setup | A cronjob script for grid user that will delete trace files periodically |
| disks.sql | An SQL script for listing disks |
| docker_descendants.py | A script to check docker images dependencies |
| docker_folder/Dockerfile | Build instruction for docker image |
| export.sh | Export a docker image and compress it |
| glogin.sql | setting SQL*Plus prettier output |
| grants.sql | grants for the build process |
| init+ASM.ora | The initialization file for ASM instance |
| install_grid.sh | Install script for grid |
| linuxx64_12201_grid_home.zip | Oracle 12.2 Grid software (no patches) download it separately |
| listener.ora | Listener file |
| oracle_asm | Logrotate for oracle logfiles |
| rlwrap-0.42-1.el7.x86_64.rpm | Handy tool to enable history in SQL*Plus, asmcmd |
| run.sh | Start a container |
| status.sh | Images and Container status |
As root/ynixon
$ cd /depo/docker_folder
$ docker build -t ynixon/docker_grid_asm .$ docker run --rm --privileged --detach --name asm_grid_build -h gridserver -p 1521:1521 -p 2222:22 --shm-size 2048m -e TZ=UTC \-v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume /depo:/software --volume /boot:/boot --device=/dev/sdb1 ynixon/docker_grid_asm$ docker exec -it asm_grid_build su - grid -c '/software/install_grid.sh'$ docker commit -m "oracle linux 7.5 standalone grid infrastructure with ASM" -a "Yossi Nixon" \`docker ps -lq\` ynixon/ynixon_asm_server$ docker rm -f asm_grid_buildRun the container at the background
$ docker run --privileged --detach --name asm_grid -h gridserver -p 1521:1521 -p 2222:22 --shm-size 2048m -e TZ=UTC -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume /depo:/software --volume /boot:/boot --device=/dev/sdb1 --restart always ynixon/ynixon_asm_serverConnect to the new container to verify the environment
$ docker exec -it --user grid asm_grid bash -l$ docker save -o /depo/export/docker_ynixon_asm_server.tar ynixon/ynixon_asm_server:latest
$ gzip docker_ynixon_asm_server.tarCopy the file docker_ynixon_asm_server.tar.gz to /tmp
$ gunzip /tmp/docker_ynixon_asm_server.tar.gz$ docker load -i /depo/export/docker_ynixon_asm_server.tar$ docker run --privileged --detach --name asm_grid -h gridserver -p 1521:1521 -p 2222:22 --shm-size 2048m -e TZ=UTC \-v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume /boot:/boot --device=/dev/sdb1 \--restart always ynixon/ynixon_asm_server$ ssh root@ -p 2222$ sqlplus sys/ynixon@:1521/+ASM as sysasm$ docker volume create portainer_data $ docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainerOpen browser at: http://:9000/
