Customize your AlloyDB Omni installation

AlloyDB Omni is deployed through a container image, which allows different forms of customization. This page shows some common customizations.

Mount an external data directory

By default, the command in Quickstart: Install AlloyDB Omni stores the database data in an area managed by Docker and Podman. This is convenient for getting started but makes it difficult to find and use the data directory. Instead, you can set up a bind mount to map the data directory to a known location on your disk.

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v DATA_DIR:/var/lib/postgresql/data \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v DATA_DIR:/var/lib/postgresql/data \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v DATA_DIR:/var/lib/postgresql/data \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v DATA_DIR:/var/lib/postgresql/data \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Replace the following variables:

  • CONTAINER_NAME: Name you used for your container. For example, my-omni-1.
  • NEW_PASSWORD: Password assigned to the new container's postgres user after its creation.
  • DATA_DIR: Host directory path that your data is stored in.
  • HOST_PORT: TCP port on the host machine that the container should publish its own port 5432 to. To use the PostgreSQL default port on the host machine as well, specify 5432.

Enable ulimits

The ulimit parameters specify process limits that the Docker or Podman container can use. For optimal performance, we recommend that you set the following ulimits:

  • nice=-20:-20: AlloyDB Omni adjusts process priorities to allow critical PostgreSQL processes to run with higher priority. The higher priority gives the processes a bigger allocation of available CPUs. To adjust process priorities, specify --ulimit=nice=-20:-20, which removes limitations for the AlloyDB Omni container.

  • memlock=-1:-1: AlloyDB Omni performs automatic memory management. Setting --ulimit=memlock=-1:-1 allows the database to better control how memory pages are swapped in and out, which can result in better performance.

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--ulimit=nice=-20:-20 --ulimit=memlock=-1:-1 \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--ulimit=nice=-20:-20 --ulimit=memlock=-1:-1 \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--ulimit=nice=-20:-20 --ulimit=memlock=-1:-1 \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--ulimit=nice=-20:-20 --ulimit=memlock=-1:-1 \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Replace the following variables:

  • CONTAINER_NAME: Name you used for your container. For example, my-omni-1.
  • NEW_PASSWORD: Password assigned to the new container's postgres user after its creation.
  • HOST_PORT: TCP port on the host machine that the container should publish its own port 5432 to. To use the PostgreSQL default port on the host machine as well, specify 5432.

Specify a logging driver

By default, Docker and Podman don't perform log rotations. This can use up a lot of disk space, and eventually lead to disk space exhaustion. To use a different logging driver, you can specify the --log-driver field. For example, to log to journald:

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--log-driver=journald \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--log-driver=journald \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--log-driver=journald \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--log-driver=journald \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Replace the following variables:

  • CONTAINER_NAME: Name you used for your container. For example, my-omni-1.
  • NEW_PASSWORD: Password assigned to the new container's postgres user after its creation.
  • HOST_PORT: TCP port on the host machine that the container should publish its own port 5432 to. To use the PostgreSQL default port on the host machine as well, specify 5432.

For more information about logging drivers, refer to Docker's Configure logging drivers and Podman's podman-run documentation.

Also, you can configure logging using PostgreSQL. For more information, see Configure AlloyDB Omni log rotation.

Mount a shared memory volume

If you plan to use the AlloyDB columnar engine with AlloyDB Omni, we recommend making shared memory available to the AlloyDB Omni container. The method for doing this differs depending upon your host operating system, as shown in the following examples.

Linux

To make shared memory available to the container, mount /dev/shm:

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v /dev/shm:/dev/shm \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v /dev/shm:/dev/shm \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v /dev/shm:/dev/shm \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
-v /dev/shm:/dev/shm \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Replace the following variables:

  • CONTAINER_NAME: Name you used for your container. For example, my-omni-1.
  • NEW_PASSWORD: Password assigned to the new container's postgres user after its creation.
  • HOST_PORT: TCP port on the host machine that the container should publish its own port 5432 to. To use the PostgreSQL default port on the host machine as well, specify 5432.

macOS

To make shared memory available to the container, include the --shm-size flag:

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--shm-size=SHARED_MEMORY_SIZE \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Docker

docker run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--shm-size=SHARED_MEMORY_SIZE \
-p HOST_PORT:5432 \
--restart=always \
google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--shm-size=SHARED_MEMORY_SIZE \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Podman

podman run -d --name CONTAINER_NAME \
-e POSTGRES_PASSWORD=NEW_PASSWORD \
--shm-size=SHARED_MEMORY_SIZE \
-p HOST_PORT:5432 \
--restart=always \
docker.io/google/alloydbomni:latest

Replace the following variables:

  • CONTAINER_NAME: Name you used for your container. For example, my-omni-1.
  • NEW_PASSWORD: Password assigned to the new container's postgres user after its creation.
  • SHARED_MEMORY_SIZE: Size to set for /dev/shm on the container, in the format described on Running containers. For example, to specify one gigabyte, use the value 1g.
  • HOST_PORT: TCP port on the host machine that the container should publish its own port 5432 to. To use the PostgreSQL default port on the host machine as well, specify 5432.

We recommend setting the shared memory size to a number of megabytes equal to at least your database's value of the google_job_scheduler.max_parallel_workers_per_job flag, times 250. For more information about the columnar engine, see Configure the columnar engine in AlloyDB Omni.

For example, if the google_job_scheduler.max_parallel_workers_per_job database flag is set to its default value of 2, consider adding a flag of --shm-size=500m or greater when starting your database server.

For more information about the --shm-size flag, see Running containers.

Enable extensions

The list of extensions available in AlloyDB Omni is available in Supported database extensions. Although PostGIS and Orafce are not included with AlloyDB Omni, they can both be installed by following instructions:

Installed extensions are enabled using standard PostgreSQL CREATE EXTENSION statements as detailed in Enable an extension.