Mulai dari AlloyDB Omni 15.5.4, Anda dapat mengontrol AlloyDB Omni dengan alat pengelolaan paket umum.
Jika Anda telah menginstal AlloyDB Omni, ikuti petunjuk di halaman ini untuk bermigrasi ke penginstalan satu image yang baru.
Prasyarat
Sebelum Anda dapat mulai mengupgrade ke AlloyDB Omni versi terbaru, selesaikan prasyarat berikut, jika Anda belum melakukannya.
Mengupgrade ke AlloyDB Omni 15.5.2
Versi AlloyDB Omni terbaru yang mendukung AlloyDB Omni CLI adalah 15.5.2.
Untuk memeriksa versi AlloyDB Omni, jalankan perintah berikut:
sudoalloydbversion
Outputnya terlihat mirip dengan yang berikut ini:
AlloyDB Omni CLI version: 1.6
AlloyDB Omni database server version: 15.5.2
Jika output menampilkan versi database yang lebih lama dari 15.5.2, jalankan perintah berikut untuk mengupgrade:
sudoalloydbdatabase-serverupgrade
Mengumpulkan informasi tentang penginstalan yang ada
Jalankan perintah berikut:
cat/var/alloydb/config/dataplane.conf
Dari output perintah cat, catat nilai variabel berikut untuk referensi Anda:
DATADIR_PATH—misalnya, /var/alloydb/main
ENABLE_ALLOYDB_AI—misalnya, FALSE
PGPORT—misalnya, 5432
INSTANCE_TYPE—misalnya, PRIMARY/READ_REPLICA
Menghapus indeks ScaNN yang dibuat dengan ekstensi postgres_ann
Ekstensi postgres_ann diganti namanya menjadi alloydb_scann. Jika Anda telah menginstal ekstensi postgres_ann dan membuat indeks ScaNN menggunakan ekstensi tersebut, Anda harus menghapus semua indeks ScaNN dan meng-uninstal ekstensi sebelum melakukan upgrade.
Untuk menangani dampak apa pun pada database Anda akibat penggantian nama ekstensi postgres_ann, selesaikan langkah-langkah berikut:
Ganti DATABASE_NAME dengan nama database tempat Anda ingin menjalankan kueri.
Simpan definisi dan parameter indeks sebagai DDL dump menggunakan utilitas seperti pg_dump untuk membuat ulang indeks ScaNN nanti.
pg_dump-stTABLE_NAMEDATABASE_NAME
Ganti kode berikut:
DATABASE_NAME: nama database.
TABLE_NAME: nama tabel.
Menghapus Indeks ScaNN yang dibuat menggunakan indeks postgres_ann.
DROPINDEXINDEX_NAME;
Ganti INDEX_NAME dengan nama database tempat Anda ingin menjalankan kueri.
Pastikan tidak ada database Anda yang menyertakan indeks ScaNN. Gunakan kueri SQL berikut untuk memverifikasi penghapusan: SQL berikut akan menampilkan set hasil kosong.
Argumen untuk docker run adalah argumen yang digunakan dalam versi AlloyDB Omni sebelumnya, tetapi Anda dapat menyesuaikannya lebih lanjut. Lihat Menyesuaikan penginstalan AlloyDB Omni untuk mengetahui detailnya.
Jika jenis instance database Anda adalah PRIMARY, jalankan perintah berikut untuk membuat pengguna berikut. Ini adalah nama pengguna yang saat ini tidak digunakan, tetapi dicadangkan untuk ekstensi mendatang.
fornameinalloydbagentalloydbexportalloydbiamgroupuseralloydbiamuseralloydbimportexportalloydbobservabilityalloydbsqllogicalalloydbsuperuser;doechodockerexec-itCONTAINER_NAMEpsql-hlocalhost-Upostgresalloydbadmin\-c"CREATE ROLE ${name} NOLOGIN;"\-c"CREATE TABLE ${name}_table();"\-c"ALTER TABLE ${name}_table OWNER TO ${name};"done
Uninstalasi CLI AlloyDB Omni tidak memengaruhi data Anda yang disimpan di AlloyDB Omni.
Membuat ulang indeks ScaNN menggunakan ekstensi alloydb_scann
Setelah Anda mengupgrade AlloyDB Omni, ekstensi alloydb_scann juga akan diinstal. Selesaikan langkah-langkah berikut untuk membuat ulang indeks ScaNN yang Anda hapus di bagian Hapus indeks ScaNN yang dibuat dengan ekstensi postgres_ann sebelum upgrade.
Buat ekstensi alloydb_scann menggunakan langkah-langkah berikut:
Untuk membuat ekstensi alloydb_scann, jalankan kueri berikut:
createextensionalloydb_scanncascade;
Pastikan ekstensi alloydb_scann berhasil dibuat.
select*frompg_extension;
Buat ulang indeks ScaNN untuk tabel Anda, lalu pulihkan definisi indeks DDL pg_dump sebelumnya.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-02 UTC."],[[["\u003cp\u003eThis page details the migration process for upgrading AlloyDB Omni from version 15.5.2 or earlier to the latest version, which now utilizes common package-management tools.\u003c/p\u003e\n"],["\u003cp\u003eBefore upgrading, users must first update to AlloyDB Omni version 15.5.2 if they are on an earlier version, using the provided command.\u003c/p\u003e\n"],["\u003cp\u003eIf the existing installation uses ScaNN indexes created with the \u003ccode\u003epostgres_ann\u003c/code\u003e extension, those indexes and the extension must be dropped before performing the upgrade, as the extension is now \u003ccode\u003ealloydb_scann\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe upgrade process involves stopping the existing database, running a new single-image AlloyDB Omni with the existing data directory, and setting specific parameters and requirements based on the previous instance.\u003c/p\u003e\n"],["\u003cp\u003eAfter upgrading, the \u003ccode\u003ealloydb_scann\u003c/code\u003e extension is installed, and any previously dropped ScaNN indexes can be recreated using this new extension.\u003c/p\u003e\n"]]],[],null,["# Migrate from AlloyDB Omni version 15.5.2 and earlier to the latest version\n\nSelect a documentation version: 15.7.0keyboard_arrow_down\n\n- [15.7.0](/alloydb/omni/15.7.0/docs/migrate-to-latest-version)\n- [15.5.5](/alloydb/omni/15.5.5/docs/migrate-to-latest-version)\n- [15.5.4](/alloydb/omni/15.5.4/docs/migrate-to-latest-version)\n\n\u003cbr /\u003e\n\nThis page provides instructions for migrating from version 15.5.2 and earlier to the latest version of AlloyDB Omni.\n\n\u003cbr /\u003e\n\nStarting with AlloyDB Omni 15.5.4, you control AlloyDB Omni with common package-management tools.\n\nIf you have an existing installation of AlloyDB Omni, follow the instructions on this page to migrate to the new, single-image installation.\n\nPrerequisites\n-------------\n\nBefore you can start upgrading to the latest version of AlloyDB Omni, complete the following prerequisites, if you haven't done so already.\n\n### Upgrade to AlloyDB Omni 15.5.2\n\nThe latest AlloyDB Omni version that supports the AlloyDB Omni CLI is 15.5.2.\nTo check the version of AlloyDB Omni, run the following command: \n\n sudo alloydb version\n\nThe output looks similar to the following: \n\n AlloyDB Omni CLI version: 1.6\n AlloyDB Omni database server version: 15.5.2\n\nIf the output displays a database version earlier than 15.5.2, run the following command to upgrade: \n\n sudo alloydb database-server upgrade\n\n### Gather information about your existing installation\n\n1. Run the following command:\n\n cat /var/alloydb/config/dataplane.conf\n\n2. From the output of the `cat` command, note the values of the following variables for your reference:\n\n - \u003cvar translate=\"no\"\u003eDATADIR_PATH\u003c/var\u003e---for example, `/var/alloydb/main`\n - \u003cvar translate=\"no\"\u003eENABLE_ALLOYDB_AI\u003c/var\u003e---for example, `FALSE`\n - \u003cvar translate=\"no\"\u003ePGPORT\u003c/var\u003e---for example, `5432`\n - \u003cvar translate=\"no\"\u003eINSTANCE_TYPE\u003c/var\u003e---for example, `PRIMARY/READ_REPLICA`\n\n### Drop ScaNN indexes created with `postgres_ann` extension\n\nThe `postgres_ann` extension is renamed to `alloydb_scann`. If you have installed the `postgres_ann` extension and created `ScaNN` indexes using the extension, you must drop all `ScaNN` indexes and uninstall the extension before performing an upgrade.\n\nTo handle any impact to your database due to the renaming of the `postgres_ann` extension, complete the following steps:\n\n1. [Run and connect to AlloyDB Omni.](/alloydb/omni/15.7.0/docs/run-connect)\n2. Identify all tables that use the `ScaNN` index.\n\n \\c \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e\n select schemaname, relname, indexrelname, indextype, indexconfig, indexsize, indexscan FROM pg_stat_ann_indexes;\n\n Replace \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e with the name of the database where you want to run the query.\n3. Save index definitions and parameters as a dump DDL using a utility like `pg_dump` to recreate the `ScaNN` indexes later.\n\n pg_dump -st \u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e: the name of the database.\n - \u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e: the name of the table.\n4. Drop `ScaNN` Indexes that were created using the `postgres_ann` index.\n\n DROP INDEX \u003cvar translate=\"no\"\u003eINDEX_NAME\u003c/var\u003e;\n\n Replace \u003cvar translate=\"no\"\u003eINDEX_NAME\u003c/var\u003e with the name of the database where you want to run the query.\n | **Note:** If the index is not successfully dropped before upgrading, then the table will be not used and queried in subsequent query requests.\n5. Verify that none of your databases include `ScaNN` indexes. Use the following SQL query to verify the deletion: The following sql should return an empty result set.\n\n \\c \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e\n select schemaname, relname, indexrelname, indextype, indexconfig, indexsize, indexscan FROM pg_stat_ann_indexes;\n\n6. Drop the `postgres_ann` extension using the following steps:\n\n 1. Verify that the `postgres_ann` extension is installed in your database.\n\n select * from pg_extension;\n\n 1. Drop the `postgres_ann` extension.\n\n DROP EXTENSION postgres_ann CASCADE;\n\n 1. Verify that the `postgres_ann` extension is no longer installed in your database.\n\n select * from pg_extension;\n\nPerform an in-place upgrade\n---------------------------\n\n1. Stop the existing database:\n\n sudo alloydb database-server stop\n\n2. Start the new single-image AlloyDB Omni, mounting your existing data directory from before:\n\n docker run --name \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e \\\n -e POSTGRES_PASSWORD=\u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e \\\n -e PGDATA=/var/lib/postgresql/data \\\n -v /var/alloydb/main/data:/var/lib/postgresql/data \\\n -v /dev/shm:/dev/shm \\\n -p \u003cvar translate=\"no\"\u003ePGPORT\u003c/var\u003e:5432 \\\n --network=host \\\n --ulimit=nice=-20:-20 \\\n --ulimit=core=-1:-1 \\\n --log-driver=journald \\\n -d google/alloydbomni\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e: The name to assign this new AlloyDB Omni container in your host machine's container registry---for example, `my-omni`.\n\n - \u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e: The password assigned the new container's `postgres` user after its creation.\n\n - \u003cvar translate=\"no\"\u003ePGPORT\u003c/var\u003e: The IP address of the port the AlloyDB Omni runs on. This is the value you noted down in step 2 of [Gather information about your existing installation](#gather-information).\n\n The arguments to `docker run` are the ones used in earlier versions of AlloyDB Omni, but you may further customize them. See [Customize your AlloyDB Omni installation](/alloydb/omni/15.7.0/docs/install) for details.\n3. If your database instance type is `PRIMARY`, run the following command to create the following users. These are usernames which are unused at the moment, but reserved for future extensions.\n\n for name in alloydbagent alloydbexport alloydbiamgroupuser alloydbiamuser alloydbimportexport alloydbobservability alloydbsqllogical alloydbsuperuser; do\n echo docker exec -it \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e psql -h localhost -U postgres alloydbadmin \\\n -c \"CREATE ROLE ${name} NOLOGIN;\" \\\n -c \"CREATE TABLE ${name}_table();\" \\\n -c \"ALTER TABLE ${name}_table OWNER TO ${name};\"\n done\n\n4. If `ENABLE_ALLOYDB_AI` is set to `TRUE`, follow instructions in [Install AlloyDB Omni with AlloyDB AI](/alloydb/omni/15.7.0/docs/install-with-alloydb-ai) to set up AlloyDB AI.\n\n5. Connect to the database to verify that the data is unchanged:\n\n docker exec -it \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e psql -h localhost -U postgres\n\n6. Uninstall the AlloyDB Omni CLI:\n\n sudo alloydb database-server uninstall\n\n The AlloyDB Omni CLI uninstallation does not affect your data stored in AlloyDB Omni.\n\nRecreate ScaNN indexes using `alloydb_scann` extension\n------------------------------------------------------\n\nAfter you upgrade AlloyDB Omni, the `alloydb_scann` extension is also installed. Complete the following steps to recreate ScaNN indexes that you dropped in the [Drop ScaNN indexes created with `postgres_ann` extension](#drop-extension-postgres-ann) section before the upgrade.\n\n1. Create the `alloydb_scann` extension using the following steps:\n\n 1. To create the `alloydb_scann` extension, run the following query:\n\n create extension alloydb_scann cascade;\n\n 1. Verify that the `alloydb_scann` extension was created successfully.\n\n select * from pg_extension;\n\n2. Recreate `ScaNN` index for your table, and then restore the previous `pg_dump` DDL index definitions.\n\n 1. Create `ScaNN` index on the table:\n\n CREATE INDEX \u003cvar translate=\"no\"\u003eINDEX_NAME\u003c/var\u003e ON \u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e\n USING scann (\u003cvar translate=\"no\"\u003eVECTOR_COLUMN\u003c/var\u003e \u003cvar translate=\"no\"\u003eDISTANCE\u003c/var\u003e)\n WITH (num_leaves = \u003cvar translate=\"no\"\u003eNUM_LEAVES_VALUE\u003c/var\u003e);\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eINDEX_NAME\u003c/var\u003e: the name of the index.\n - \u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e: the name of the table.\n - \u003cvar translate=\"no\"\u003eVECTOR_COLUMN\u003c/var\u003e: the name of the column that stores vector data.\n - \u003cvar translate=\"no\"\u003eDISTANCE\u003c/var\u003e: the distance function to use with this index.\n - \u003cvar translate=\"no\"\u003eNUM_LEAVES_VALUE\u003c/var\u003e: the number of partitions to apply to the index.\n\n 1. Verify that the index is created.\n\n \\d TABLE_NAME\n\n 1. Recommended: Backup your indexes data. We recommend creating a backup of your database and indexes as a best practice.\n\n | **Caution:** Any backup that includes the `postgres_ann` extension and was taken before the upgrade cannot be restored after the upgrade."]]