GItlab 安装

1、安装相关U依赖

$ yum -y install policycoreutils openssh-clients postfix

2、启动ssh服务&设置为开机启动

$ systemctl enable sshd & sudo systemctl start sshd

3、设置postfix开机自启,并启动,postfix支持gitlab发信功能

$ systemctl enable postfix && systemctl start postfix

4、开放ssh 以及http服务,然后重新加载防火墙列表

$ firewall-cmd --add-service=ssh --permanent
$ firewall-cmd --add-service=http --permanent
$ firewall-cmd --reload

5、下载gitlab 包,并且安装

安装

$ wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm 
 wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-13.6.7-ce.0.el6.x86_64.rpm

$ rpm -i gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm 

6、修改gitlab 配置

vi /etc/gitlab/gitlab.rb

修改 gitlab 访问地址和端口,默认为80,我们改为82

external_url'http://192.168.66.100:82'
nginx['listen_port']=82 #这行是注释掉了,直接打开即可

7、重载配置及启动gitlab

gitlab-ctl reconfigure
gitlab-ctl restart
gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
gitlab-ctl reconfigure # 启动服务;
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
gitlab-ctl tail # 查看日志;

此时有可能报错

报错:There was an error running gitlab-ctl reconfigure:
ruby_block[authorize Grafana with Gitlab] (monitoring::grafana line 92) had an error: NoMethodError: undefined method ‘zero?’ for nil:NilClass

解决办法

分配2G空间

sudo dd if=/dev/zero of=/root/swapfile bs=1M count=1500;

制作文件并生效

sudo mkswap /root/swapfile
sudo swapon /root/swapfile

设置开机启动
sudo vim /etc/fstab 在最后一行加进去

/root/swapfile swap swap defaults 0 0

最后free -m查看是否生效
生效后重新执行gitlab-ctl reconfigure 即可

8、把端口添加到防火墙

firewall-cmd --zone=public --add-port=82/tcp --permanent
firewall-cmd --reload

启动成功后,访问: xxxx:82 看到一下修改管理员root密码的页面,修改密码后,然后登录即可

Gitlab 安装问题

1、Gitlab访问出现403"Forbidden"现象

问题原因分析:

可能因较多的并发导致的访问被拒绝, Gitlab使用rack_attack做了并发访问的限制!

解决办法:

打开/etc/gitlab/gitlab.rb文件,查找 gitlab_rails[‘rack_attack_git_basic_auth’] 关键词,取消注释,

修改ip_whitelist白名单属性,加入Gitlab部署的IP地址。

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
......
 gitlab_rails['rack_attack_git_basic_auth'] = {
   'enabled' => true,
   'ip_whitelist' => ["127.0.0.1","172.16.60.222"],   //把gitlab服务器IP地址添加
   'maxretry' => 10,
   'findtime' => 60,
   'bantime' => 3600
 }  

然后进行重新配置

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

2、Gitlab访问出现502的现象

Gitlab访问出现:Whoops, GitLab is taking too much time to respond.

问题原因分析:

1)unicorn原8080默认端口被容器中别的进程已经占用,必须调整为没用过的
2)gitlab的timeout设置过小,默认为60

解决办法:

1)关闭gitlab服务

[root@gitlab ~]``# gitlab-ctl stop

2)选择一个没有被系统占用的端口作为unicorn端口,比如8877端口(lsof -i:8877 确认此端口没有被占用)

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
unicorn['port'] = 8877
gitlab_workhorse['auth_backend'] = "http://localhost:8877"

3)重新生成配置,并进行重启。

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

3、Gitlab启动失败,或重新安装时出现卡的状态

问题现象:在卸载gitlab然后再次安装执行sudo gitlab-ctl reconfigure的时候往往会出现:ruby_block[supervise_redis_sleep] action run,会一直卡无法往下进行!

解决办法:

1)按ctrl + c 强制结束
2)执行"systemctl restart gitlab-runsvdir" 命令
3)接着再执行"gitlab-ctl reconfigure"

如果Gitlab服务器重启后,启动"gitlab-ctl start"失败,解决办法相同。

[root@gitlab ~]# systemctl restart gitlab-runsvdir
[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl start

4、Gitlab异常关机,导致gitlab启动失败!gitlab-runsvdir方式启动没反应(僵尸状态)

问题现象:Gitlab部署的服务器异常断电,机器重启后,尝试启动gitlab服务,启动失败!通过gitlab-runsvdir方式启动一直没有反应!一直在卡顿状态!日志也没有任务输入!

执行下面的启动命令报错:
[root@gitlab ~]# gitlab-ctl start      // 或者 "gitlab-ctl restart"
fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-monitor: runsv not running
fail: gitlab-workhorse: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running

那么尝试通过supervisor进程方式启动gitlab,发现一直在卡顿中,根本没有任何反应!

[root@gitlab ~]# systemctl restart gitlab-runsvdir

查看日志,发现也没有任务启动信息打印到日志中 (日志都是之前的)

[root@gitlab ~]``# /usr/bin/gitlab-ctl tail

gitlab-runsvdir启动在卡顿中,gitlab服务也没有起来

root@gitlab ~]# cat /etc/systemd/system/multi-user.target.wants/gitlab-runsvdir.service
[Unit]
Description=GitLab Runit supervision process
After=multi-user.target
  
[Service]
ExecStart=/opt/gitlab/embedded/bin/runsvdir-start           #最后通过这条命令启动了Gitlab
Restart=always
  
[Install]
WantedBy=multi-user.target
  
执行下面的启动,虽然发现这个也会一直在卡顿中,但是不影响gitlab服务启动。
[root@gitlab ~]# /opt/gitlab/embedded/bin/runsvdir-start
  
重新打开一个终端窗口,发现gitlab已经有新的日志信息打入了,gitlab也服务已经起来了
[root@gitlab ~]# /usr/bin/gitlab-ctl tail
[root@gitlab ~]# ps -ef|grep gitlab
  
这时候关闭上面执行"/opt/gitlab/embedded/bin/runsvdir-start"的卡顿的终端窗口,发现gitlab也还是启动状态(ps -ef|grep gitlab)
[root@gitlab ~]# ps -ef|grep gitlab
[root@gitlab ~]# lsof -i:80
[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 29804) 1640s; run: log: (pid 29789) 1640s
run: gitaly: (pid 29795) 1640s; run: log: (pid 29781) 1640s
run: gitlab-monitor: (pid 29799) 1640s; run: log: (pid 29785) 1640s
run: gitlab-workhorse: (pid 29794) 1640s; run: log: (pid 29780) 1640s
run: logrotate: (pid 29798) 1640s; run: log: (pid 29783) 1640s
run: nginx: (pid 29800) 1640s; run: log: (pid 29786) 1640s
run: node-exporter: (pid 29802) 1640s; run: log: (pid 29788) 1640s
run: postgres-exporter: (pid 29805) 1640s; run: log: (pid 29790) 1640s
run: postgresql: (pid 29796) 1640s; run: log: (pid 29782) 1640s
run: prometheus: (pid 29797) 1640s; run: log: (pid 29784) 1640s
run: redis: (pid 29818) 1640s; run: log: (pid 29793) 1640s
run: redis-exporter: (pid 29817) 1640s; run: log: (pid 29792) 1640s
run: sidekiq: (pid 29801) 1640s; run: log: (pid 29787) 1640s
run: unicorn: (pid 29807) 1640s; run: log: (pid 29791) 1640s
  
查看日志也有新信息写入,一切正常了!
[root@gitlab ~]# /usr/bin/gitlab-ctl tail  

5、Gitlab重新安装,在执行"gitlab-ctl reconfigure"配置环节出现了下面报错:

[root@gitlab ~]# gitlab-ctl reconfigure
.........
.........
STDERR: sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf": No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf": No such file or directory
---- End output of sysctl -e --system ----
Ran sysctl -e --system returned 255

问题原因分析:
丢失了报错中的这两个配置文件,进入/etc/sysctl.d目录发现,这两个文件都是通过链接到/opt/gitlab/embedded/etc/目录下。
然而/opt/gitlab/embedded/etc/确实没有这两个文件。

[root@gitlab ~]# ll /etc/sysctl.d/
total 0
lrwxrwxrwx  1 root root 58 Nov 10 22:23 90-omnibus-gitlab-kernel.sem.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
lrwxrwxrwx  1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmall.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmall.conf
lrwxrwxrwx  1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmmax.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmmax.conf
lrwxrwxrwx  1 root root 66 Nov 10 22:25 90-omnibus-gitlab-net.core.somaxconn.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
lrwxrwxrwx. 1 root root 14 Oct 30 09:13 99-sysctl.conf -> ../sysctl.conf
  
[root@gitlab ~]# ll /opt/gitlab/embedded/etc
total 12
-rw-r--r-- 1 root root  24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root  28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig
  
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf: No such file or directory
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf: No such file or directory
  
解决方法一:
从别的备份机(或者在别的机器上重新安装一次,"gitlab-ctl reconfigure"之后生成这两个文件)将这两个文件拷贝回来!
  
解决方法二:
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
# unicorn['port'] = 8080
修改为:
unicorn['port'] = 8090
  
之后重新加载配置文件
[root@gitlab ~]# gitlab-ctl reconfigure
  
再次会报错,然后再修改/etc/gitlab/gitlab.rb,修改为原来的配置
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
# unicorn['port'] = 8080
  
再次重新加载配置文件就OK了!
[root@gitlab ~]# gitlab-ctl reconfigure
  
再次查看,发现上面配置中报错的两个文件已经存在了
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/
total 20
-rw-r--r-- 1 root root  30 Apr 12 23:33 90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root  24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root  28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rw-r--r-- 1 root root  26 Apr 12 23:35 90-omnibus-gitlab-net.core.somaxconn.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root 30 Apr 12 23:33 /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
-rw-r--r-- 1 root root 26 Apr 12 23:35 /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
  
最后再启动gitlab
[root@gitlab ~]# gitlab-ctl start

6、Gitlab更改默认Nginx

更换gitlab自带Nginx,使用自行编译Nginx来管理gitlab服务。

自行编译的nginx服务和gitlab在同一台机器上
1)编辑gitlab配置文件禁用自带Nignx服务器
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
...
#设置nginx为false,关闭自带Nginx
nginx['enable'] = false
...
  
2)检查默认nginx配置文件,并迁移至新Nginx服务 (即将下面两个gitlab自带nginx的配置文件迁移到自行编译的新的nginx配置中)
/var/opt/gitlab/nginx/conf/nginx.conf                #nginx配置文件,包含gitlab-http.conf文件
/var/opt/gitlab/nginx/conf/gitlab-http.conf          #gitlab核心nginx配置文件
  
[root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/nginx.conf /etc/nginx/conf.d/
[root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/gitlab-http.conf /etc/nginx/conf.d/
  
3)重启gitlab服务
[root@gitlab ~]# gitlab-ctl reconfigure  
[root@gitlab ~]# gitlab-ctl restart
  
重启自行编译的nginx服务
[root@gitlab ~]# service nginx restart
  
如果访问报502。原因是nginx用户无法访问gitlab用户的socket文件。
重启gitlab需要重新授权
[root@gitlab ~]# chmod -R o+x /var/opt/gitlab/gitlab-rails  
  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: Windows GitLab安装使用步骤: 1. 下载并安装Git for Windows,下载地址:https://git-scm.com/download/win 2. 下载并安装Ruby,下载地址:https://rubyinstaller.org/downloads/ 3. 安装GitLab,下载地址:https://about.gitlab.com/install/#windows 4. 打开Git Bash,输入以下命令: ``` git config --global user.name "Your Name" git config --global user.email "your.email@example.com" ``` 5. 创建一个新的GitLab项目,输入以下命令: ``` mkdir ~/project cd ~/project git init git remote add origin https://gitlab.com/yourusername/yourproject.git ``` 6. 将本地代码推送到GitLab,输入以下命令: ``` git add . git commit -m "Initial commit" git push -u origin master ``` 7. 在GitLab上查看项目,输入以下命令: ``` gitlab ``` 然后在浏览器中打开http://localhost:8080/,输入用户名和密码登录GitLab。 8. 在GitLab上管理项目,包括添加成员、设置权限、创建分支、合并请求等。 以上就是Windows GitLab安装使用的步骤,希望对你有帮助。 ### 回答2: Windows上安装GitLab可以在本地服务器上搭建GitLab私有仓库,为团队成员提供代码仓库、部署服务等管理功能。GitLab安装过程非常简单,只需要按照以下步骤操作即可。 1. 安装Git 首先需要安装Git,下载最新版本的Git或者从Git官网上下载安装程序进行安装。 2. 安装Ruby 安装完成Git之后,需要安装Ruby。可以从Ruby官网下载最新的安装包进行安装,在安装完成后需要在系统环境变量中添加Ruby路径。 3. 安装GitLab 下载并解压GitLab安装包,将其移动到相应的安装目录下。然后打开Git Bash或者命令行工具进入该安装目录,并执行以下命令: ``` sudo -u git -H bundle install --deployment --without development test postgres aws ``` 这个命令会自动按照GitLab所需的所有必需软件包和依赖项进行安装安装过程可能需要一段时间,请耐心等待。 4. 配置GitLab GitLab安装完成之后,需要配置GitLab以使用它所需的数据库。默认情况下,GitLab会使用SQLite。如果你想使用其他数据库,需要按照相应的说明进行配置。 5. 启动GitLab 通过以下命令启动GitLab: ``` sudo service gitlab start ``` 启动完成后,访问http://localhost:8080/即可访问GitLab。 6. 创建用户和项目 在访问GitLab之前,需要在GitLab上创建用户和项目。首先需要在GitLab的用户管理界面中创建用户,并设置用户的访问权限。然后在GitLab的项目管理界面中创建项目,并添加相应的用户。 7. 提交代码 在创建好项目之后,就可以在本地Git客户端中使用Git命令提交代码了。首先需要将代码库克隆到本地,然后进行修改并提交到GitLab中。 以上就是在Windows上安装和使用GitLab的详细步骤。通过GitLab,可以极大地提高团队开发的效率,并确保代码的安全性和稳定性。 ### 回答3: Windows GitLab是一种基于Web的Git代码仓库管理工具,它可以帮助团队更好地协作开发。Windows GitLab是一种开源软件,用户可以访问其GitHub存储库以获取最新版本的源代码。 安装GitLab 第一步是下载GitLab安装程序。官方网站上提供了适用于Windows的安装程序,您可以从下载页面下载它们,并按照安装向导进行安装。 在安装过程中,您需要指定GitLab数据库及其连接字符串。您可以使用内置的SQLite或MySQL或PostgreSQL数据库引擎。如果您愿意,可以安装一个现有的数据库引擎,并使用其连接字符串。 安装并启动GitLab后,您可以在Web浏览器中访问GitLab的主页。您应该会看到一个登录页面,您可以在其中输入自己的用户名和密码,以开始使用GitLab。 配置GitLab GitLab有许多配置选项,例如安全性、用户设置、存储库设置和集成等。您可以在GitLab的管理区域中设置这些选项。 在GitLab的管理区域中,您可以添加新的用户并分配权限。还可以创建新的项目和存储库,并设置存储库的访问权限。配置GitLab需要执行许多任务,因此最好读取GitLab文档并理解各个设置选项。 使用GitLab 现在,您可以开始使用GitLab与其他用户共享代码并协作开发。您可以创建新的存储库、分支和提交,然后将它们推送到GitLab服务器。其他用户可以从GitLab服务器获取您的代码,并进行修改或添加新的功能。 在GitLab中,您可以通过使用问题、合并请求、发布和标签等功能来管理项目。如果您在团队中使用Agile方法,则可以利用GitLab的Kanban面板来跟踪任务和进度。 总结 GitLab是一种功能强大的Git代码仓库管理工具。在Windows上安装和配置它并没有什么特别困难的地方。使用它可以帮助您更好地管理代码并与其他开发者进行协作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

半夏_2021

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值