Install AlloyDB Omni with AlloyDB AI

Select a documentation version:

This page shows you how to install AlloyDB Omni and integrate AlloyDB AI in it.

AlloyDB AI is a suite of features included with AlloyDB Omni that let you build enterprise generative AI applications. For more information about the ML functionality of AlloyDB, see Build generative AI applications .

AlloyDB Omni with AlloyDB AI lets you query remote ML models to work with online predictions and text embeddings generated from ML models. AlloyDB Omni with AlloyDB AI can also process vector embeddings from other content such as an image, for example, if you use the google_ml.predict_row interface and do the translation yourself in the query.

Based on where you want to install AlloyDB Omni with AlloyDB AI, select one of the following options:

Configure your AlloyDB Omni instance to query remote models

To configure AlloyDB Omni to query remote models, follow these steps:

  1. Create a service account with Google Cloud.

  2. Create a service account key , in JSON format, and download it.

  3. Store the key in a permanent location on your file system. It resides at this location for the lifetime of your AlloyDB Omni server.

    Note its location on your file system; you need it for the next step.

  4. Add Vertex AI Identity and Access Management (IAM) permissions to the appropriate project and service account.

       
    gcloud  
    projects  
    add-iam-policy-binding  
     PROJECT_ID 
      
     \ 
      
    --member = 
     "serviceAccount: SERVICE_ACCOUNT_ID 
    " 
      
     \ 
      
    --role = 
     "roles/aiplatform.user" 
     
    

    Replace the following:

    • PROJECT_ID : the ID of your Google Cloud project.

    • SERVICE_ACCOUNT_ID : the ID of the service account that you created in the previous step. This includes the full @ PROJECT_ID .iam.gserviceaccount.com suffix—for example, my-service@my-project.iam.gserviceaccount.com .

Install AlloyDB Omni with AlloyDB AI

To install AlloyDB Omni and integrate AlloyDB AI, follow these steps:

  1. Ensure you completed all of the steps listed in Configure your AlloyDB Omni to query cloud-based models .

  2. Make a local copy of the default AlloyDB Omni configuration file:

    Docker

       
    docker  
    run  
    -i  
    --rm  
    google/alloydbomni:15.5.5  
    cat  
    /usr/share/postgresql/postgresql.conf.sample > 
    my-postgres.conf 
    

    Podman

       
    podman  
    run  
    -i  
    --rm  
    google/alloydbomni:15.5.5  
    cat  
    /usr/share/postgresql/postgresql.conf.sample > 
    my-postgres.conf 
    
  3. Edit the configuration file copy to add directives for AlloyDB AI integration:

       
     echo 
      
     "omni_enable_ml_agent_process = 'on'" 
     >> 
    my-postgres.conf 
       
     echo 
      
     "omni_google_cloud_private_key_file_path = '/etc/postgresql/private-key.json'" 
     >> 
    my-postgres.conf 
    
  4. Adjust the file system permissions of the key and configuration files:

       
    sudo  
    chmod  
    +r  
    my-postgres.conf 
       
    sudo  
    chmod  
    +r  
     KEY_PATH 
     
    

    Replace KEY_PATH with the path to the service account private key file on your host file system. This is the key that you created and downloaded earlier in this procedure.

  5. Install the key and configuration files mounted onto the container:

    Docker

       
    docker  
    run  
    --name  
     CONTAINER_NAME 
      
    -e  
     POSTGRES_PASSWORD 
     = 
     NEW_PASSWORD 
      
    -p  
     HOST_PORT 
    :5432  
    -v  
     " 
     $PWD 
     /my-postgres.conf" 
    :/etc/postgresql/postgresql.conf  
    -v  
     " FULL_KEY_PATH 
    " 
    :/etc/postgresql/private-key.json  
    -d  
    google/alloydbomni:15.5.5  
    -c  
     'config_file=/etc/postgresql/postgresql.conf' 
     
    

    Replace the following:

    • CONTAINER_NAME : the name to assign this new simplified AlloyDB Omni installation method container in your host machine's container registry—for example, my-omni-1 .

    • NEW_PASSWORD : the password assigned to new container's postgres user after its creation.

    • HOST_PORT : * HOST_PORT : the TCP port on the host machine to which the container publishes port 5432. To use the PostgreSQL default port on the host machine as well, specify 5432 .

    • FULL_KEY_PATH : the full file system path to the service account private key file on your host system.

    Podman

       
    podman  
    run  
    --name  
     CONTAINER_NAME 
      
    -e  
     POSTGRES_PASSWORD 
     = 
     NEW_PASSWORD 
      
    -p  
     HOST_PORT 
    :5432  
    -v  
     " 
     $PWD 
     /my-postgres.conf" 
    :/etc/postgresql/postgresql.conf  
    -v  
     " FULL_KEY_PATH 
    " 
    :/etc/postgresql/private-key.json  
    -d  
    google/alloydbomni:15.5.5  
    -c  
     'config_file=/etc/postgresql/postgresql.conf' 
     
    

    Replace the following:

    • CONTAINER_NAME : the name to assign this new simplified AlloyDB Omni installation method container in your host machine's container registry—for example, my-omni-1 .

    • NEW_PASSWORD : the password assigned to new container's postgres user after its creation.

    • HOST_PORT : the 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 .

    • FULL_KEY_PATH : the full file system path to the service account private key file on your host system.

Verify AlloyDB Omni with AlloyDB AI installation

To verify your installation is successful and uses model prediction, enter the following:

   
 CREATE 
  
 EXTENSION 
  
 google_ml_integration 
  
 CASCADE 
 ; 
  
 SELECT 
  
 array_dims 
 ( 
 embedding 
 ( 
  
 'textembedding-gecko@001' 
 , 
  
 'AlloyDB AI' 
 ):: 
 real 
 []); 
  
 array_dims 
 

The output looks similar to the following:

 [1:768]
    (1 row) 

In the previous query, the embedding() call generates embeddings for the input text AlloyDB AI . array_dims returns the dimensions of the array returned by embedding() . Since the pre-registered textembedding-gecko model returns an output with 768 dimensions, the output is [768] .

What's next

Design a Mobile Site
View Site in Mobile | Classic
Share by: