运行并连接到 AlloyDB Omni for Linux

选择文档版本:

本页面介绍了如何在将 AlloyDB Omni 安装到您自己的机器上后,运行并连接到 AlloyDB Omni。

准备工作

在系统上安装 AlloyDB Omni

运行 AlloyDB Omni

请使用以下部分中的信息来启动、检查状态和停止 AlloyDB Omni。

启动 AlloyDB Omni

  sudo systemctl start alloydbomni17

可选:启用自动服务重启

如需启用 AlloyDB Omni 服务的自动重启功能,请执行以下操作:

  1. 将以下配置添加到 /etc/systemd/system/alloydbomni17.service.d/override.conf 文件中。

      [Service]
        Restart=on-failure
  2. 重新加载 systemd 管理器配置并重启 alloydbomni17 服务,以使更改生效。

    sudo systemctl daemon-reload
    sudo systemctl restart alloydbomni17

检查 AlloyDB Omni 的状态

   sudo systemctl status alloydbomni17

停止 AlloyDB Omni

  sudo systemctl stop alloydbomni17

连接到 AlloyDB Omni

AlloyDB Omni RPM 软件包还包含 psql 客户端,可让您打开与数据库服务器的交互式 SQL shell 会话。

您还可以使用自己选择的与 PostgreSQL 兼容的软件连接到 AlloyDB Omni。

使用捆绑的 psql 进行连接

  /usr/lib/postgresql/17/bin/psql -h localhost -U postgres

此命令会将您以 postgres 用户角色连接到服务器,并显示 postgres=# 命令提示符。现在,您可以运行 psql 命令和 SQL 查询。

如需退出 psql,请运行 \q 命令。

使用您自己的应用进行连接

任何与 PostgreSQL 搭配使用的客户端应用也可以与 AlloyDB Omni 搭配使用,而无需进行任何修改。

使用任何与 PostgreSQL 兼容的客户端或代码库连接到 AlloyDB Omni。

连接到数据库服务器后,您可以通过标准 PostgreSQL 通信协议发送 DML 和 SQL 查询来定义、查询和修改数据库。

由于 AlloyDB Omni 在您自己的环境中运行,因此您可以控制连接到 AlloyDB Omni 的方式。您可以根据应用需求允许或限制对 AlloyDB Omni 的网络访问,就像使用普通 PostgreSQL 服务器一样。

后续步骤