gitlab 安装

镜像

镜像地址传送门

安装

[root@gitlab ~]# yum install -y curl policycoreutils-python openssh-server
[root@gitlab ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
  
[root@gitlab ~]# rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm

警告:gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:gitlab-ce-10.2.2-ce.0.el7        ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ \`/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

说明

目录

目录说明
/etc/gitlab/gitlab.rb配置文件
/opt/gitlab安装目录
/var/opt/gitlab目录数据
/var/opt/gitlab/git-data仓库数据

命令

运行状态: gitlab-ctl status

查看服务: gitlab-ctl service-list

查看日志: gitlab-ctl tail

重启服务: gitlab-ctl restart

停止服务: gitlab-ctl stop

更新配置: gitlab-ctl reconfigure

配置

Nginx

nginx配置文件
upstream gitlab-workhorse {
  server 127.0.0.1:8000;
}


server {
  listen 80;
  server_name code.qvbilam.xin;
  access_log /data/wwwlogs/code.qvbilam.xin_nginx.log combined;
  index index.html index.htm index.php;

  #error_page 404 /404.html;
  #error_page 502 /502.html;


  location / {
    proxy_cache off;
    proxy_pass  http://gitlab-workhorse;
  }

  location ~ (\.git/gitlab-lfs/objects|\.git/info/lfs/objects/batch$) {
    proxy_cache off;
    proxy_pass http://gitlab-workhorse;
    proxy_request_buffering off;
  }

  location /assets {
    proxy_cache off;
    proxy_pass  http://gitlab-workhorse;
  }


  location ~ /\.ht {
    deny all;
  }
}
修改访问地址与监听地址
[root@gitlab ~]# vi /etc/gitlab/gitlab.rb

## GitLab URL
external_url 'http://code.qvbilam.xin'
##! **Override only if you use a reverse proxy**
##! Docs: https://docs.gitlab.com/omnibus/settings/nginx.html#setting-the-nginx-listen-port
nginx['listen_port'] = 8000

DB

不支持mysql数据库, 宿主机需要开放端口5432

创建数据库与账户
# 拉取镜像
[root@gitlab ~]# docker pull postgres

# 创建数据卷
[root@gitlab ~]# docker volume create gitlb-sql

# 启动容器 账号: postgres. 密码: 123456
[root@gitlab ~]# docker run --name git-postgres --mount source=gitlab-sql,target=/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -d -p 5432:5432 docker.io/postgres

进入容器的数据库中

  • 创建用户,与数据库.
  • 数据库: gitlab_production
  • 账号: gitlab
  • 密码: git
[root@gitlab ~]# docker container exec -it c55a14c4ce22 psql -U postgres

# 创建用户,与数据库. 数据库: gitlab_production, 账号: gitlab. 密码: git
postgres=# create role gitlab login encrypted password 'git';
CREATE ROLE
postgres=# create database gitlab_production owner=gitlab ENCODING = 'UTF8';
CREATE DATABASE
postgres=# exit

# git终端 连接测试
# psql -U gitlab -h172.17.69.12 -d gitlab_production
设置允许远程访问
[root@iz2ze1epzqld1dhcl3itv5z ~]# docker volume inspect gitlab-sql
[
    {
        "CreatedAt": "2022-03-28T17:43:08+08:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/gitlab-sql/_data",
        "Name": "gitlab-sql",
        "Options": null,
        "Scope": "local"
    }
]
[root@iz2ze1epzqld1dhcl3itv5z ~]# vi /var/lib/docker/volumes/gitlab-sql/_data/pg_hba.conf
修改数据配置
[root@gitlab ~]# vi /etc/gitlab/gitlab.rb

### GitLab database settings
postgresql['enable'] = false
gitlab_rails['db_adapter'] = "postgresql"
gitlab_rails['db_encoding'] = "unicode"
gitlab_rails['db_collation'] = nil
gitlab_rails['db_database'] = "gitlab_production"
gitlab_rails['db_pool'] = 10
gitlab_rails['db_username'] = "gitlab"
gitlab_rails['db_password'] = "git"
gitlab_rails['db_host'] = "172.17.69.12"
gitlab_rails['db_port'] = 5432

Redis

链接本地地址, 密码为空,数据库使用10
[root@gitlab ~]# vi /etc/gitlab/gitlab.rb

#### Redis TCP connection
gitlab_rails['redis_host'] = "127.0.0.1"
gitlab_rails['redis_port'] = 6379
gitlab_rails['redis_password'] = nil
gitlab_rails['redis_database'] = 10

更新

[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl restart

汉化

1、下载汉化补丁
[root@gitlab ~]# git clone https://gitlab.com/xhang/gitlab.git
[root@gitlab ~]# cd gitlab    
2、查看全部分支版本
[root@gitlab ~]# git branch -a
3、对比版本、生成补丁包
[root@gitlab ~]# git diff remotes/origin/10-2-stable remotes/origin/10-2-stable-zh > /tmp/10.2.2-zh.diff
4、停止服务器
[root@gitlab ~]# gitlab-ctl stop
5、打补丁
[root@gitlab ~]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/10.2.2-zh.diff
6、启动和重新配置
[root@gitlab ~]# gitlab-ctl start
[root@gitlab ~]# gitlab-ctl reconfigure
Last modification:June 3rd, 2022 at 11:41 pm