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.

Nota: El almacenamiento en caché del repositorio se encuentra actualmente en beta y está sujeto a cambios.

About configuration for repository caching

Ahora puedes configurar el almacenamiento de repositorios en caché si creas un tipo especial de réplica llamado caché de repositorio. 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 github.example.com, you might decide to name a cache europe-ci.github.example.com or github.asia.example.com.

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 "https://europe-ci.github.example.com/"]
	insteadOf = https://github.example.com/

Then, when told to fetch https://github.example.com/myorg/myrepo, Git will instead fetch from https://europe-ci.github.example.com/myorg/myrepo.

Configuring a repository cache

  1. Set up a new GitHub Enterprise Server appliance on your desired platform. This appliance will be your repository cache. For more information, see "Setting up a GitHub Enterprise Server instance."

  2. Establece una contraseña de administrador que coincida con la contraseña del aparato principal y continúa.

  3. Haz clic en Configure as Replica (Configurar como réplica). Opciones de instalación con enlace para configurar tu nueva instancia como una réplica

  4. En "Agregar nueva clave SSH", escribe tu clave SSH. Agrega la clave SSH

  5. Da clic en Agregar llave.

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

    $ ssh -p 122 admin@REPLICA IP
  7. Para generar un par de claves para la replicación, usa el comando ghe-repl-setup con la dirección IP del aparato principal y copia la clave pública que este devuelve.

    $ ghe-repl-setup PRIMARY IP
  8. Para agregar una llave pública a la lista de llaves autorizadas en el aparato principal, ingresa a https://PRIMARY-HOSTNAME/setup/settings y agrega a la lista la llave que copiaste de la réplica.

  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. Para comenzar la replicación de las bases de datos, utiliza el comando ghe-repl-start.

    $ ghe-repl-start

    Advertencia: ghe-repl-start causa una breve interrupción en el servidor principal, durante la cual los usuarios pueden ver errores internos del servidor. Para proporcionar un mensaje más amigable, ejecuta ghe-maintenance -s en el nodo principal antes de ejecutar ghe-repl-start en el nodo réplica para poner la aplicación en modo de mantenimiento. Una vez que se inicie la replicación, deshabilita el modo de mantenimiento con ghe-maintenance -u. La replicación de Git no progresará mientras el nodo primario esté en modo de mantenimiento.

  12. Para verificar el estado de cada canal de replicación del almacén de datos, utiliza el comando 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.