Skip to content

Instantly share code, notes, and snippets.

@rponte
Last active June 24, 2021 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rponte/9de866defd848f488e59faeaa4ca5eb8 to your computer and use it in GitHub Desktop.
Save rponte/9de866defd848f488e59faeaa4ca5eb8 to your computer and use it in GitHub Desktop.
Docker: list of useful commands
# executing htop in host machine
docker run --name "htop" --rm -it --pid host jess/htop
##
# Oracle 11G XE NON-Official
# All instructions are here: https://hub.docker.com/r/epiclabs/docker-oracle-xe-11g
##
# running Oracle 11G XE container (some examples)
docker run --name oracle-xe -d -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true -e ORACLE_PASSWORD=manager epiclabs/docker-oracle-xe-11g
docker run --name oracle-xe -d -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true -e ORACLE_PASSWORD=manager -e RELAX_SECURITY=1 epiclabs/docker-oracle-xe-11g
docker run --name oracle-xe -d -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true -e ORACLE_PASSWORD=manager -e RELAX_SECURITY=1 -v "$PWD/oracle-data":/u01/app/oracle epiclabs/docker-oracle-xe-11g
# ...with memory constraints
docker run --name oracle-xe -d --memory=1g -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true -e ORACLE_PASSWORD=manager -e RELAX_SECURITY=1 epiclabs/docker-oracle-xe-11g
# tuning database
docker exec -it oracle-xe /bin/bash
echo "ALTER SYSTEM SET processes=200 scope=spfile;" | sqlplus -s SYSTEM/manager
echo "ALTER SYSTEM SET FILESYSTEMIO_OPTIONS=ASYNCH SCOPE=SPFILE;" | sqlplus -s SYSTEM/manager
echo "ALTER SYSTEM SET disk_asynch_io=TRUE SCOPE=SPFILE;" | sqlplus -s SYSTEM/manager
service oracle-xe restart
# installing htop
docker exec -it oracle-xe /bin/bash
apt-get -y install htop
# executing htop
docker exec -it oracle-xe htop
# stopping container
docker stop oracle-xe
# destroying container
docker container rm oracle-xe
# ...with SIGKILL
docker container rm -f oracle-xe
# ...with SIGKILL and removes volumes associated with the container
docker container rm -fv oracle-xe
##
# Oracle 11G XE Official
# All instructions are here: https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance
##
# building Oracle 11G XE image
git clone https://github.com/oracle/docker-images.git
cd docker-images/OracleDatabase/SingleInstance/dockerfiles
cp ~/workspace/databases/oracle/oracle-xe-11.2.0-1.0.x86_64.rpm.zip 11.2.0.2/
./buildDockerImage.sh -v 11.2.0.2 -x
# running Oracle 11G XE container (some examples)
docker run --name oracle-xe-official -d --shm-size=1g -p 1521:1521 -e ORACLE_PWD=manager oracle/database:11.2.0.2-xe
docker run --name oracle-xe-official -d --shm-size=1g -p 1521:1521 -p 8086:8080 -e ORACLE_PWD=manager oracle/database:11.2.0.2-xe
docker run --name oracle-xe-official -d --shm-size=1g -p 1521:1521 -p 8086:8080 -e ORACLE_PWD=manager -v "$PWD/oracle-data":/u01/app/oracle/oradata oracle/database:11.2.0.2-xe
# ...with memory constraints
docker run --name oracle-xe-official -d --memory=1g --shm-size=1g -p 1521:1521 -p 8086:8080 -e ORACLE_PWD=manager oracle/database:11.2.0.2-xe
# ...with memory constraints and timezone
docker run --name oracle-xe-official -d --memory=1g -e TZ="America/Fortaleza" --shm-size=1g -p 1521:1521 -p 8086:8080 -e ORACLE_PWD=manager oracle/database:11.2.0.2-xe
# tuning database
docker exec -it oracle-xe-official /bin/bash
echo "ALTER SYSTEM SET processes=200 scope=spfile;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
echo "ALTER SYSTEM SET FILESYSTEMIO_OPTIONS=ASYNCH SCOPE=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
echo "ALTER SYSTEM SET disk_asynch_io=TRUE SCOPE=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
service oracle-xe restart
# installing htop
docker exec -it oracle-xe-official /bin/bash
yum -y install htop
# executing htop
docker exec -it oracle-xe-official htop
# stopping container
docker stop oracle-xe-official
# destroying container
docker container rm oracle-xe-official
# ...with SIGKILL
docker container rm -f oracle-xe-official
# ...with SIGKILL and removes volumes associated with the container
docker container rm -fv oracle-xe-official
# showing logs
docker logs oracle-xe-official
# ...and following it
docker logs --follow oracle-xe-official
# showing statistics
docker stats --no-stream
docker stats --no-stream oracle-xe-official
# ...interactively
docker stats
docker stats oracle-xe-official
# cleaning a volume
docker volume rm -f my_volume
# clearing ALL volume
docker volume prune
# ...without prompting for confirmation
docker volume prune -f
@rponte
Copy link
Author

rponte commented May 2, 2019

@rponte
Copy link
Author

rponte commented May 2, 2019

@rponte
Copy link
Author

rponte commented May 8, 2019

ASYNC I/O and Windows 7

If you're mounting a volume on Windows 7 and you still want to use ASYNC I/O, be careful because the filesytem may not support ASYNC I/O. Even though you can set it up, the Oracle instance will NOT start up!

So you must use emulated ASYNC settings (which in turn uses slave threads to emulate async I/O) instead:

docker exec -it oracle-xe-official /bin/bash
echo "ALTER SYSTEM SET processes=200 scope=spfile;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
echo "ALTER SYSTEM SET filesystemio_options=ASYNCH scope=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE

# disk_asynch_io must be false and DBWR_IO_SLAVES must be different than zero
echo "ALTER SYSTEM SET disk_asynch_io=FALSE scope=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
echo "ALTER SYSTEM SET dbwr_io_slaves=2 scope=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
service oracle-xe restart

@rponte
Copy link
Author

rponte commented May 9, 2019

Performance Tips

I got a better performance using DIRECTIO instead of ASYNC:

docker exec -it oracle-xe-official /bin/bash
echo "ALTER SYSTEM SET processes=200 scope=spfile;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
echo "ALTER SYSTEM SET filesystemio_options=DIRECTIO scope=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
# disk_asynch_io must be false
echo "ALTER SYSTEM SET disk_asynch_io=FALSE scope=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
service oracle-xe restart

Surprisingly , I also got a better performance using emulated ASYNC (which in turn also works when mouting volumes on Windows 7):

docker exec -it oracle-xe-official /bin/bash
echo "ALTER SYSTEM SET processes=200 scope=spfile;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
echo "ALTER SYSTEM SET filesystemio_options=ASYNCH SCOPE=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE

# disk_asynch_io must be false and DBWR_IO_SLAVES must be different than zero
echo "ALTER SYSTEM SET disk_asynch_io=FALSE scope=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
echo "ALTER SYSTEM SET dbwr_io_slaves=2 scope=SPFILE;" | sqlplus -s SYSTEM/manager@//localhost:1521/XE
service oracle-xe restart

So, using DIRECTIO or even emulated ASYNC is way better than using the native ASYNC. By the way, all tests were made with Docker Engine v18.09.5 on Windows 7.

@rponte
Copy link
Author

rponte commented Feb 12, 2021

Podemos usar o serviço composerize para ajudar a gerar docker-compose.yml a partir do comando docker run ...

@rponte
Copy link
Author

rponte commented Jun 24, 2021

Blog do Vlad Mihalcea: 9 High-Performance Tips when using Oracle with JPA and Hibernate

Since Unix-based operation systems have their own page cache, it’s important to mound the data and index partitions using Direct I/O (e.g., O_DIRECT) to avoid storing the same page in both the OS cache and the Buffer Pool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment