Gitlab社区版安装和配置

来自linux中国网wiki
Evan讨论 | 贡献2021年7月1日 (四) 07:07的版本 →‎usage
跳到导航 跳到搜索

usage

GitLab 管理员手册

GitLab如何删除已有项目

为GitLab帐号添加SSH keys并连接GitLab

GitLab 如何修改项目从私有到公有

本地java代码上传Gitlab仓库

第零 docker-compose for gitlab  



2020 直接 docker-compose 其实可以上 alpine的  不过官方的没有  
用ng upstream 到 80 or 443 

cat docker-compose.yml


web:
  image: 'gitlab/gitlab-ce:14.0.0-ce.0'
  #image: 'gitlab/gitlab-ce:11.4.3'
  #image: 'gitlab/gitlab-ce:latest'  
  restart: always
  hostname: 'mygitlab.com'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://gitlab.lliao.net'
      #external_url 'https://mygitlab.com'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '7080:80'
    - '4433:443'
    - '2222:22'
  volumes:
    - ./gitlab/config:/etc/gitlab
    - ./gitlab/logs:/var/log/gitlab
    - ./gitlab/data:/var/opt/gitlab



这个首次登录密码重置为什么没了 june 2021 version gitlab14
 Browse to the hostname and login

On your first visit, you'll be redirected to a password reset screen. Provide the password for the initial administrator account and you will be redirected back to the login screen. Use the default account's username root to login.


https://mygitlab.com:4433/
7080端口好像不行 要改下面的ssh相关就好了 


改进 

    运行在自定义的 HTTP 和 SSH 端口:

    web:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: 'gitlab.example.com'
    environment:
        GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab.example.com:8929'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
    ports:
        - '8929:8929'
        - '2224:22'
    volumes:
        - '/srv/gitlab/config:/etc/gitlab'
        - '/srv/gitlab/logs:/var/log/gitlab'
        - '/srv/gitlab/data:/var/opt/gitlab'



Install GitLab with Docker

gitlab搭配ssh默认端口引发的问题

明明 docker-compose.yml  用 了2222端口但还是有问题   rb文件也要改为 2222  这个是为了开外网 给外面的用  例如jenkins 在外面的 

修改sshd_config中的Port #这一步 试过 可以不用操作的
service sshd restart

#第一步的我没改哦 好像可以不动 
修改/etc/gitlab/gitlab.rb [再次声明,gitlab.yml中的配置会被这个给覆盖]

启用下面这行,并把端口改为自己服务器的sshd端口 如果是我常用的 这里50022 应该是2222才对哦

gitlab_rails['gitlab_shell_ssh_port'] = 50022

使之生效,大功告其!

gitlab-ctl reconfigure



其它办法 
然后要等待一会儿直到页面能够重新显示为止
修改http的clone地址加上端口
修改gitlab.yml文件
进入容器内部
docker exec -it gitlab /bin/bash
修改文件
cd /opt/gitlab/embedded/service/gitlab-rails/config
vim gitlab.yml
复制代码
修改gitlab
             host:10.10.0.44
             port:7002

然后在容器内执行gitlab-ctl restart (注意 这里如果docker restart gitlab了,设置会被重新覆盖,也就丢失了,因为restart会重新执行gitlab-ctl reconfigure,目前没有什么好的方式,只有尽量少启动gitlab)

修改http的clone地址加上端口

java+maven项目+tapd+jenkins+gitlab+sonarqube+docker实现自动化持续部署(超详细)

第一种 Install and configure the necessary dependencies

进入gitlab官方网站,选择对应的操作系统——CentOS 6 (and RedHat/Oracle/Scientific Linux 6),
https://about.gitlab.com/downloads/#centos6

按照官方的提示进行安装:
安装配置必要的依赖
在Centos 6 和 7 中,以下的命令将会打开HTTP和SSH在系统防火墙中的可访问权限。

#sudo lokkit -s http -s ssh





[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key


sudo yum makecache

# 安装依赖包
sudo yum install curl openssh-server openssh-clients postfix cronie
# 启动 postfix 邮件服务
sudo service postfix start
# 检查 postfix
sudo chkconfig postfix on
# 安装 GitLab 社区版
sudo yum install gitlab-ce
# 初始化 GitLab 配置并启动GitLab
打开/etc/gitlab/gitlab.rb,将external_url = ‘http://git.example.com’修改为自己的IP地址:http://xxx.xx.xxx.xx,,然后执行下面的命令,对GitLab进行编译。





sudo gitlab-ctl reconfigure
一直都有更新的。



sudo gitlab-ctl reconfigure
登录GitLab
Username: root
Password: 5iveL!fe





我在ubuntu下的一键安装,如果用汉化版的有问题的。
所以现在只能用英文原版的。


现在会要求改密码了 在第一次 

dkm12345678



git_data_dirs({"default" => "/data/gitlab/git-data"})
/data/gitlab/git-data

gitlab-ctl reconfigure 

 

第二种 Add the GitLab package server and install the package

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

 

 


【gitlab小症状】gitlab搭配ssh默认端口引发的血战

docker安装gitlab并使用非标准端口

gitlab性能优化调化 占用内存过大问题


/etc/gitlab/gitlab.rb

#进程数目 
 unicorn['worker_processes'] = 2

#减少数据库缓存 默认为  256M
postgresql['shared_buffers'] = "128MB"


#减少并发数 默认为8
postgresql['max_worker_processes'] = 4



#减少 sidekiq并发数 
sidekiq['concurrency'] = 20


#最后  reload 
gitlab-ctl reconfigure

gitlab占用内存过大问题

GitLab配置优化及汉化


Gitlab 重置 root 密码


先登录入容器

要重置root密码,请先使用root权限登录服务器。使用以下命令启动Ruby on Rails控制台:

su - git
gitlab-rails console
#gitlab-rails console production

等到控制台加载完毕,您可以通过搜索电子邮件或用户名等方法找到您的账号。

user = User.where(id: 1).first

或者

user = User.find_by(email: '[email protected]')

找出用户以后,可以更改其密码:

user.password = '12345678'
#user.password_confirmation = 'e12345678'

user.save!
可能得先重启服务呢  一定要保存 有时登录不对 可能是浏览器缓存了哦 
最后,保存上面的更改,即可使用新密码登录。
注意:root密码不能小于8位即12345678,不然会显示false

服务器Gitlab忘记root密码

https://docs.gitlab.com/ee/security/reset_user_password.html

报错

================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb
================================================================================

RuntimeError
------------
GitLab external URL must include a schema and FQDN, e.g. http://gitlab.example.com/

记得前缀有http样

https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

https://www.linuxchina.net/?p=2750

 

see also

GitLab Docker images

在 CentOS 7 上使用 Docker 部署安装 GitLab

GitLab 中文社区版 Docker 镜像

ouyangzhiping/docker-gitlab.md

GitLab的安装及使用教程

使用Docker安装GitLab

GitLab安装教程

Docker 搭建 Gitlab 服务

快速安装 GitLab 并汉化

old

 # 下面这个手工的 线上一般不用了 以前学习用的

获取 GitLab 镜像
docker search gitlab

docker pull gitlab/gitlab-ce:latest

查看本地镜像
docker images

创建目录

mkdir -p /data/gitlab/{config,data,logs}

创建并运行容器

docker run --detach \
       --hostname git.evan.com \
       --publish 443:443 \
       --publish 80:80 \
       --publish 222:22 \
       --name gitlabce\
       --restart always \
       --volume /data/gitlab/config:/etc/gitlab \
       --volume /data/gitlab/logs:/var/log/gitlab \
       --volume /data/gitlab/data:/var/opt/gitlab \
       gitlab/gitlab-ce:latest


查看运行状态

docker ps
netstat -ntulap | grep docker
访问 GitLab

启动
docker start gitlabce

docker stop gitlabce

如果没有域名,直接使用 IP 访问即可。
初始账户

用户: root
密码: 5iveL!fe  现在一般要自己配置密码的了