Skip to main content

Configuring a repository cache

You can configure a repository cache by creating a new appliance, connecting the repository cache to your primary appliance, and configuring replication of repository networks to the repository cache.

Note: Repository caching is currently in beta and subject to change.

About configuration for repository caching

You can configure repository caching by creating a special type of replica called a repository cache. Then, you can set data location policies that govern which repository networks are replicated to the repository cache.

Repository caching is not supported with clustering.

DNS for repository caches

The primary instance and repository cache should have different DNS names. For example, if your primary instance is at, you might decide to name a cache or

To have your CI machines fetch from the repository cache instead of the primary instance, you can use Git's url.<base>.insteadOf configuration setting. For more information, see git-config in the Git documentation.

For example, the global .gitconfig for the CI machine would include these lines.

[url ""]
    insteadOf =

Then, when told to fetch, Git will instead fetch from

Configuring a repository cache

  1. 新しい GitHub Enterprise Server アプライアンスを希望するプラットフォームにセットアップします。 This appliance will be your repository cache. 詳細は「GitHub Enterprise Serverインスタンスをセットアップする」を参照してください。

  2. プライマリアプライアンス上のパスワードと一致する管理者パスワードを設定して続行します。

  3. Configure as Replica(レプリカとして設定)をクリックしてください。 新しいインスタンスをレプリカとして設定するリンクを持つインストールオプション

  4. "Add new SSH key(新しいSSH鍵の追加)"の下でSSH鍵を入力してください。 SSHキーの追加

  5. Add key(キーの追加)をクリックしてください。

  6. Connect to the repository cache's IP address using SSH.

    $ ssh -p 122 admin@REPLICA IP
  7. レプリケーション用の鍵ペアを生成するには、プライマリアプライアンスの IP アドレスを指定した ghe-repl-setup コマンドを使用し、そのコマンドが返す公開鍵をコピーします。

    $ ghe-repl-setup PRIMARY IP
  8. プライマリアプライアンスの認証済みキーのリストに公開鍵を追加するには、https://<PRIMARY-HOSTNAME>/setup/settingsにアクセスし、レプリカからコピーした鍵をリストに追加してください。

  9. To verify the connection to the primary and enable replica mode for the repository cache, run ghe-repl-setup again.

    $ ghe-repl-setup PRIMARY IP
  10. Set a cache_location for the repository cache, replacing CACHE-LOCATION with an alphanumeric identifier, such as the region where the cache is deployed. Also set a datacenter name for this cache; new caches will attempt to seed from another cache in the same datacenter.

    $ ghe-repl-node --cache CACHE-LOCATION --datacenter REPLICA-DC-NAME
  11. データストアのレプリケーションを開始するには、ghe-repl-startコマンドを使ってください。

    $ ghe-repl-start

    警告: ghe-repl-startを使うとプライマリサーバーは短期間利用できなくなり、その間ユーザにはinternal server errorが返されます。 もっと親切なメッセージを提供するには、ghe-repl-startをレプリカノードで実行する前にプライマリノード上でghe-maintenance -sを実行し、アプライアンスをメンテナンスモードにしてください。 レプリケーションを開始したら、ghe-maintenance -uでメンテナンスモードを無効化してください。 Git replication will not progress while the primary node is in maintenance mode.

  12. 各データストアのレプリケーションチャネルのステータスを確認するには、ghe-repl-status コマンドを使用します。

    $ ghe-repl-status
  13. To enable replication of repository networks to the repository cache, set a data location policy. For more information, see "Data location policies."

Data location policies

You can control data locality by configuring data location policies for your repositories with the spokesctl cache-policy command. Data location policies determine which repository networks are replicated on which repository caches. By default, no repository networks will be replicated on any repository caches until a data location policy is configured.

Data location policies affect only Git content. Content in the database, such as issues and pull request comments, will be replicated to all nodes regardless of policy.

Note: Data location policies are not the same as access control. You must use repository roles to control which users may access a repository. For more information about repository roles, see "Repository roles for an organization."

You can configure a policy to replicate all networks with the --default flag. For example, this command will create a policy to replicate a single copy of every repository network to the set of repository caches whose cache_location is "kansas".

$ ghe-spokesctl cache-policy set --default 1 kansas

To configure replication for a repository network, specify the repository that is the root of the network. A repository network includes a repository and all of the repository's forks. You cannot replicate part of a network without replicating the whole network.

$ ghe-spokesctl cache-policy set <owner/repository> 1 kansas

You can override a policy that replicates all networks and exclude specific networks by specifying a replica count of zero for the network. For example, this command specifies that any repository cache in location "kansas" cannot contain any copies of that network.

$ ghe-spokesctl cache-policy set <owner/repository> 0 kansas

Replica counts greater than one in a given cache location are not supported.