<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Geo with external PostgreSQL instances > 原文:[https://docs.gitlab.com/ee/administration/geo/replication/external_database.html](https://docs.gitlab.com/ee/administration/geo/replication/external_database.html) * [**Primary** node](#primary-node) * [Configure the external database to be replicated](#configure-the-external-database-to-be-replicated) * [Leverage your cloud provider’s tools to replicate the primary database](#leverage-your-cloud-providers-tools-to-replicate-the-primary-database) * [Manually configure the primary database for replication](#manually-configure-the-primary-database-for-replication) * [**Secondary** nodes](#secondary-nodes) * [Manually configure the replica database](#manually-configure-the-replica-database) * [Configure **secondary** application nodes to use the external read-replica](#configure-secondary-application-nodes-to-use-the-external-read-replica) * [Configure the tracking database](#configure-the-tracking-database) # Geo with external PostgreSQL instances[](#geo-with-external-postgresql-instances-premium-only "Permalink") 如果您使用的*不是由 Omnibus 管理*的 PostgreSQL 實例,則此文檔很重要. 這包括 AWS RDS 之類的云托管實例,或者手動安裝和配置的 PostgreSQL 實例. **注意:**我們強烈建議運行 Omnibus 管理的實例,因為它們是積極開發和測試的. 我們的目標是與大多數外部數據庫(不受 Omnibus 管理)兼容,但我們不保證兼容性. ## **Primary** node[](#primary-node "Permalink") 1. SSH 到 GitLab **主**應用程序服務器并以 root 用戶身份登錄: ``` sudo -i ``` 2. 編輯`/etc/gitlab/gitlab.rb`并為您的節點添加一個**唯一的** ID(任意值): ``` # The unique identifier for the Geo node. gitlab_rails['geo_node_name'] = '<node_name_here>' ``` 3. 重新配置**主**節點以使更改生效: ``` gitlab-ctl reconfigure ``` 4. 執行以下命令以將節點定義**為主**節點: ``` gitlab-ctl set-geo-primary-node ``` 該命令將使用您在`/etc/gitlab/gitlab.rb`定義的`external_url` . ### Configure the external database to be replicated[](#configure-the-external-database-to-be-replicated "Permalink") 要設置外部數據庫,您可以: * 自己設置流復制(例如,在 AWS RDS 中). * 手動執行 Omnibus 配置,如下所示. #### Leverage your cloud provider’s tools to replicate the primary database[](#leverage-your-cloud-providers-tools-to-replicate-the-primary-database "Permalink") 假設您在使用 RDS 的 AWS EC2 上設置了一個主節點. 現在,您僅可以在其他區域中創建只讀副本,復制過程將由 AWS 管理. 確保已根據需要設置了網絡 ACL,子網和安全組,以便輔助應用程序節點可以訪問數據庫. 以下說明詳細說明了如何為常見的云提供程序創建只讀副本: * Amazon RDS- [創建只讀副本](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html#USER_ReadRepl.Create) * PostgreSQL 的 Azure 數據庫-在 PostgreSQL 的 Azure 數據庫中[創建和管理只讀副本](https://docs.microsoft.com/en-us/azure/postgresql/howto-read-replicas-portal) 設置只讀副本后,您可以跳過以[配置輔助應用程序節點](#configure-secondary-application-nodes-to-use-the-external-read-replica) . #### Manually configure the primary database for replication[](#manually-configure-the-primary-database-for-replication "Permalink") [`geo_primary_role`](https://docs.gitlab.com/omnibus/roles/)通過更改`pg_hba.conf`和`postgresql.conf`來配置要復制的**主**節點數據庫. 手動對外部數據庫配置進行以下配置更改,并確保稍后重新啟動 PostgreSQL 才能使更改生效: ``` ## ## Geo Primary Role ## - pg_hba.conf ## host all all <trusted primary IP>/32 md5 host replication gitlab_replicator <trusted primary IP>/32 md5 host all all <trusted secondary IP>/32 md5 host replication gitlab_replicator <trusted secondary IP>/32 md5 ``` ``` ## ## Geo Primary Role ## - postgresql.conf ## wal_level = hot_standby max_wal_senders = 10 wal_keep_segments = 50 max_replication_slots = 1 # number of secondary instances hot_standby = on ``` ## **Secondary** nodes[](#secondary-nodes "Permalink") ### Manually configure the replica database[](#manually-configure-the-replica-database "Permalink") 手動對外部副本數據庫的`pg_hba.conf`和`postgresql.conf`進行以下配置更改,并確保之后重新啟動 PostgreSQL 才能使更改生效: ``` ## ## Geo Secondary Role ## - pg_hba.conf ## host all all <trusted secondary IP>/32 md5 host replication gitlab_replicator <trusted secondary IP>/32 md5 host all all <trusted primary IP>/24 md5 ``` ``` ## ## Geo Secondary Role ## - postgresql.conf ## wal_level = hot_standby max_wal_senders = 10 wal_keep_segments = 10 hot_standby = on ``` ### Configure **secondary** application nodes to use the external read-replica[](#configure-secondary-application-nodes-to-use-the-external-read-replica "Permalink") 對于 Omnibus, [`geo_secondary_role`](https://docs.gitlab.com/omnibus/roles/)具有三個主要功能: 1. 配置副本數據庫. 2. 配置跟蹤數據庫. 3. 啟用[地理日志光標](index.html#geo-log-cursor) (本節未介紹). 要配置與外部只讀副本數據庫的連接并啟用 Log Cursor,請執行以下操作: 1. SSH 到 GitLab **輔助**應用程序服務器并以 root 用戶身份登錄: ``` sudo -i ``` 2. 編輯`/etc/gitlab/gitlab.rb`并添加以下內容 ``` ## ## Geo Secondary role ## - configure dependent flags automatically to enable Geo ## roles ['geo_secondary_role'] # note this is shared between both databases, # make sure you define the same password in both gitlab_rails['db_password'] = '<your_password_here>' gitlab_rails['db_username'] = 'gitlab' gitlab_rails['db_host'] = '<database_read_replica_host>' # Disable the bundled Omnibus PostgreSQL, since we are # using an external PostgreSQL postgresql['enable'] = false ``` 3. 保存文件并[重新配置 GitLab](../../restart_gitlab.html#omnibus-gitlab-reconfigure) ### Configure the tracking database[](#configure-the-tracking-database "Permalink") **輔助**節點使用單獨的 PostgreSQL 安裝作為跟蹤數據庫,以跟蹤復制狀態并自動從潛在的復制問題中恢復. 設置了`roles ['geo_secondary_role']` Omnibus 會自動配置跟蹤數據庫. 如果要在 Omnibus 外部運行此數據庫,請按照以下說明進行操作. 如果您將云托管服務用于跟蹤數據庫,則可能需要向跟蹤數據庫用戶授予其他角色(默認情況下,這是`gitlab_geo` ): * Amazon RDS 需要[`rds_superuser`](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.Roles)角色. * PostgreSQL 的 Azure 數據庫需要[`azure_pg_admin`](https://docs.microsoft.com/en-us/azure/postgresql/howto-create-users#how-to-create-additional-admin-users-in-azure-database-for-postgresql)角色. 跟蹤數據庫需要與**輔助**副本數據庫建立[FDW](https://s0www0postgresql0org.icopy.site/docs/11/postgres-fdw.html)連接以提高性能. 如果您準備好將外部數據庫用作跟蹤數據庫,請按照以下說明使用它: **注意:**如果您要將 AWS RDS 用作跟蹤數據庫,請確保其有權訪問輔助數據庫. 不幸的是,僅分配相同的安全組是不夠的,因為出站規則不適用于 RDS PostgreSQL 數據庫. 因此,您需要將入站規則顯式添加到只讀副本的安全組,以允許來自跟蹤數據庫的端口 5432 上的所有 TCP 通信. 1. 通過手動更改與跟蹤數據庫關聯的`pg_hba.conf` ,確保輔助節點可以與跟蹤數據庫通信. 請記住,之后要重新啟動 PostgreSQL 才能使更改生效: ``` ## ## Geo Tracking Database Role ## - pg_hba.conf ## host all all <trusted tracking IP>/32 md5 host all all <trusted secondary IP>/32 md5 ``` 2. SSH 到 GitLab **輔助**服務器并以 root 用戶身份登錄: ``` sudo -i ``` 3. 使用 PostgreSQL 實例的機器的連接參數和憑據編輯`/etc/gitlab/gitlab.rb` : ``` geo_secondary['db_username'] = 'gitlab_geo' geo_secondary['db_password'] = '<your_password_here>' geo_secondary['db_host'] = '<tracking_database_host>' geo_secondary['db_port'] = <tracking_database_port> # change to the correct port geo_secondary['db_fdw'] = true # enable FDW geo_postgresql['enable'] = false # don't use internal managed instance ``` 4. 保存文件并[重新配置 GitLab](../../restart_gitlab.html#omnibus-gitlab-reconfigure) 5. 運行跟蹤數據庫遷移: ``` gitlab-rake geo:db:create gitlab-rake geo:db:migrate ``` 6. 配置[PostgreSQL FDW](https://s0www0postgresql0org.icopy.site/docs/11/postgres-fdw.html)連接和憑據: 將下面的腳本保存在一個文件中,例如. `/tmp/geo_fdw.sh`并修改連接參數以匹配您的環境. 執行它以建立 FDW 連接. ``` #!/bin/bash # Secondary Database connection params: DB_HOST="<public_ip_or_vpc_private_ip>" DB_NAME="gitlabhq_production" DB_USER="gitlab" DB_PASS="<your_password_here>" DB_PORT="5432" # Tracking Database connection params: GEO_DB_HOST="<public_ip_or_vpc_private_ip>" GEO_DB_NAME="gitlabhq_geo_production" GEO_DB_USER="gitlab_geo" GEO_DB_PORT="5432" query_exec () { gitlab-psql -h $GEO_DB_HOST -U $GEO_DB_USER -d $GEO_DB_NAME -p $GEO_DB_PORT -c "${1}" } query_exec "CREATE EXTENSION postgres_fdw;" query_exec "CREATE SERVER gitlab_secondary FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '${DB_HOST}', dbname '${DB_NAME}', port '${DB_PORT}');" query_exec "CREATE USER MAPPING FOR ${GEO_DB_USER} SERVER gitlab_secondary OPTIONS (user '${DB_USER}', password '${DB_PASS}');" query_exec "CREATE SCHEMA gitlab_secondary;" query_exec "GRANT USAGE ON FOREIGN SERVER gitlab_secondary TO ${GEO_DB_USER};" ``` **注意:**上面的腳本模板使用`gitlab-psql`因為它打算從 Geo 機器上執行,但是您可以將其更改為`psql`并從任何有權訪問數據庫的機器上運行. 我們還建議將`psql`用于 AWS RDS. 7. 保存文件并[重新啟動 GitLab](../../restart_gitlab.html#omnibus-gitlab-restart) 8. Populate the FDW tables: ``` gitlab-rake geo:db:refresh_foreign_tables ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看