5

Ubuntu16.04 安装与汉化Gitlab

感谢两位作者的帮助

gitlab安装与汉化 作者: crisen
Ubuntu16.04 安装Gitlab 作者:冯天鹅

我将命令进行了整理,系统环境是Ubuntu16.04,
你可以将下面的命令保存成shell脚本部署到自己的服务器上面,直接执行即可

#!/bin/bash

apt-get install -y curl openssh-server ca-certificates postfix

curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
#从清华大学下载,这样要比官网的快很多
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main' >/etc/apt/sources.list.d/gitlab-ce.list

apt-get update

apt-get install -y gitlab-ce

gitlab-ctl reconfigure
gitlab-ctl status


#下面开始汉化
wget https://gitlab.com/xhang/gitlab/-/archive/11-0-stable-zh/gitlab-11-0-stable-zh.tar

tar -xvf  gitlab-11-0-stable-zh.tar

cp -R /opt/gitlab/embedded/service/gitlab-rails  /opt/gitlab/embedded/service/gitlab-rails.back

cp -rf gitlab-11-0-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/

#cp -rf后会报两个错误,这个没有关系不影响

gitlab-ctl reconfigure
gitlab-ctl restart
# 如果看到 502 , Dont worry, 重启需要时间,等一分钟后再来看看

所有的安装步骤都应该尽可能脚本化,让他人直接执行脚本就能够部署成功。


特别说明,上面的在18.04就不好用了,清华大学的那个源会报错

 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 14219A96E15E78F4
Reading package lists... Done                                                                                                                                        
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 14219A96E15E78F4
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

这个时候需要看下面这个
在Ubuntu18.04安装gitlab国内镜像加速

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

vim /etc/apt/sources.list.d/gitlab_gitlab-ce.list
#deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main
#deb-src https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main

apt-get update

apt-get install -y gitlab-ce

gitlab-ctl reconfigure
gitlab-ctl restart

如果gitlab执行有问题,可以使用命令 gitlab-ctl tail 来查看


GitLab 项目创建后地址由Localhost改为实际IP的方法

GitLab 项目创建后地址由Localhost改为实际IP的方法

vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
将host修改为你的服务器域名或者ip,然后重启

gitlab-ctl restart

gitlab的数据备份

gitlab的数据备份

数据备份地址在
/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
中配置,请注意

## Backup settings
  backup:
    path: "/var/opt/gitlab/backups"   # Relative paths are relative to Rails.root (default: tmp/backups/)
    archive_permissions:  # Permissions for the resulting backup.tar file (default: 0600)
    keep_time:    # default: 0 (forever) (in seconds)
    pg_schema:    # default: nil, it means that all schemas will be backed up
    upload:
      # Fog storage connection settings, see http://fog.io/storage/ .
      connection:
      # The remote 'directory' to store your backups. For S3, this would be the bucket name.
      remote_directory:
      multipart_chunk_size:
      encryption:
      storage_class:

备份命令(可以直接加到crontab里面)

gitlab-rake gitlab:backup:create

之后可以去backup的path中查看是否生成成功

数据恢复

  • 停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
  • 从指定时间戳的备份恢复(backups目录下有多个备份文件时):
gitlab-rake gitlab:backup:restore BACKUP=1500809139
  • 从默认备份恢复(backups目录下只有一个备份文件时):
gitlab-rake gitlab:backup:restore
  • 启动Gitlab
gitlab-ctl start
gitlab-ctl reconfigure

本机生成ssh-key,用来提交gitlab的项目

ssh-keygen -t rsa -C 'xxxx@xxx.com'

sunwenzheng
1.5k 声望126 粉丝