<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Using PostgreSQL > 原文:[https://docs.gitlab.com/ee/ci/services/postgres.html](https://docs.gitlab.com/ee/ci/services/postgres.html) * [Use PostgreSQL with the Docker executor](#use-postgresql-with-the-docker-executor) * [Use PostgreSQL with the Shell executor](#use-postgresql-with-the-shell-executor) * [Example project](#example-project) # Using PostgreSQL[](#using-postgresql "Permalink") 由于許多應用程序都依賴 PostgreSQL 作為其數據庫,因此最終需要它才能運行測試. 下面將指導您如何使用 GitLab Runner 的 Docker 和 Shell 執行程序執行此操作. ## Use PostgreSQL with the Docker executor[](#use-postgresql-with-the-docker-executor "Permalink") 如果您將[GitLab Runner](../runners/README.html)與 Docker 執行程序一起使用,則基本上已經完成了所有設置. 首先,在您的`.gitlab-ci.yml`添加: ``` services: - postgres:12.2-alpine variables: POSTGRES_DB: nice_marmot POSTGRES_USER: runner POSTGRES_PASSWORD: "" POSTGRES_HOST_AUTH_METHOD: trust ``` **注意:**不能在 GitLab UI 中設置`POSTGRES_DB` , `POSTGRES_USER` , `POSTGRES_PASSWORD`和`POSTGRES_HOST_AUTH_METHOD`變量. 要設置它們,請將它們分配給[UI 中](../variables/README.html#create-a-custom-variable-in-the-ui)的變量,然后將該變量分配給`.gitlab-ci.yml`的`POSTGRES_DB` , `POSTGRES_USER` , `POSTGRES_PASSWORD`和`POSTGRES_HOST_AUTH_METHOD`變量. 然后將您的應用程序配置為使用數據庫,例如: ``` Host: postgres User: runner Password: '' Database: nice_marmot ``` 如果您想知道為什么我們對`Host`使用`postgres` ,請閱讀[如何將服務鏈接到作業的更多信息](../docker/using_docker_images.html#how-services-are-linked-to-the-job) . 您還可以使用[Docker Hub](https://hub.docker.com/_/postgres)上可用的任何其他 Docker 映像. 例如,要使用 PostgreSQL 9.3,服務將變為`postgres:9.3` . `postgres`圖像可以接受一些環境變量. 有關更多詳細信息,請參閱[Docker Hub](https://hub.docker.com/_/postgres)上的文檔. ## Use PostgreSQL with the Shell executor[](#use-postgresql-with-the-shell-executor "Permalink") 您還可以在手動配置的服務器上使用 PostgreSQL,這些服務器將 GitLab Runner 與 Shell 執行程序一起使用. 首先安裝 PostgreSQL 服務器: ``` sudo apt-get install -y postgresql postgresql-client libpq-dev ``` 下一步是創建用戶,因此登錄 PostgreSQL: ``` sudo -u postgres psql -d template1 ``` 然后創建一個將由您的應用程序使用的用戶(在我們的示例中為`runner` ). 將以下命令中的`$password`更改`$password`真實的強密碼. ***注意:**不要輸入`template1=#` ,這是 PostgreSQL 提示的一部分.* ``` template1=# CREATE USER runner WITH PASSWORD '$password' CREATEDB; ``` ***注意:**請注意,我們創建的用戶具有創建數據庫的特權( `CREATEDB` ). 在以下步驟中,我們將為該用戶顯式創建一個數據庫,但是如果在您的測試框架中有刪除和創建數據庫的工具,則具有該特權將很有用.* 創建數據庫,并授予其上的所有特權用戶`runner` : ``` template1=# CREATE DATABASE nice_marmot OWNER runner; ``` 如果一切順利,您現在可以退出數據庫會話: ``` template1=# \q ``` 現在,嘗試連接到與用戶新創建的數據庫`runner`檢查一切就緒. ``` psql -U runner -h localhost -d nice_marmot -W ``` ***注意:**我們明確告訴`psql`連接到 localhost 以便使用 md5 身份驗證. 如果您省略此步驟,則將被拒絕訪問.* 最后,將您的應用程序配置為使用數據庫,例如: ``` Host: localhost User: runner Password: $password Database: nice_marmot ``` ## Example project[](#example-project "Permalink") 為了方便起見,我們使用公共可[共享的](../runners/README.html)運行程序在[GitLab.com](https://gitlab.com)上運行了一個[示例 PostgreSQL 項目](https://gitlab.com/gitlab-examples/postgres) . 想要破解嗎? 只需對其進行分叉,提交并推送您的更改. 稍后,公共跑步者將選擇更改并開始工作.
                  <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>

                              哎呀哎呀视频在线观看