Linux【8】-软件管理-9-软件安装2-gitlab

一、下载安装

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

二、开启服务

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

三、安装

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

sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee

或者安装好以后:

vim /etc/gitlab/gitlab.rb

修改:

external_url 'http://gitlab所在服务器的ip:端口'

四、其他

1. 停止gitlab服务

sudo gitlab-ctl stop

重启服务:

sudo gitlab-ctl restart

2.设置管理员密码

管理员账号登录的用户名:root

虽然登录后管理员的用户名为Administrator,但是实际登录的用户名是root)

方法一:网页方式

浏览器访问gitlab所在的ip,输入密码后点击 “Change your password”(如果进行汉化,点击“修改密码”)。

方法二:指令方式

gitlab-rails console production

稍等一会后会出现

irb(main):001:0> user = User.where(id: 1).first     // id为1的是超级管理员
irb(main):002:0>user.password = 'yourpassword'      // 密码必须至少8个字符
irb(main):003:0>user.save!                          // 如没有问题 返回true
exit                                                // 退出

3.日志文件

GitLab使用gitlab-ctl日志查看的方法

Gitlab 默认的日志文件存放在/var/log/gitlab 目录下

1.查看所有日志

sudo gitlab-ctl tail

2.查看nginx 访问日志

sudo gitlab-ctl tail nginx/gitlab_acces.log

3.查看 postgresql 日志

sudo gitlab-ctl tail  postgresql

4.4 gitlab免密登陆

方法一

git config --global credential.helper store

执行此命令后,用户主目录下的.gitconfig文件会多了一项:[credential]

helper = store

重新git push就不需要用户名密码了。

方法二:

首先生成密钥对:

ssh-keygen -t rsa -C "youremail"

接下来按照提示操作,默认可以一路往下。

然后将生成的位于~/.ssh/的id_rsa.pub的内容复制到你github setting里的ssh key中。

复制之后,如果你还没有克隆你的仓库,那你直接使用ssh协议用法:

git@github.com:yourusername/yourrepositoryname克隆就行了。

如果已经使用https协议克隆了,那么按照如下方法更改协议:

git remote set-url origin git@github.com:yourusername/yourrepositoryname.git

4.5 删除本地 中已经在gitlab被删除的origin

#查看remote发现有一个多余的remote,refs/remotes/orig

[sam@c01 germline_dection]$ git remote show origin
* remote origin
  Fetch URL: git@192****:molinfo/BPkit.git
  Push  URL: git@192****:molinfo/BPkit.git
  HEAD branch: sam
  Remote branches:
    jinxs                     new (next fetch will store in remotes/origin)
    refs/remotes/origin/xsjin stale (use 'git remote prune' to remove)
    sam                       tracked
  Local ref configured for 'git push':
    sam pushes to sam (fast-forwardable)

#清理
[sam@c01 germline_dection]$ git remote prune origin
Pruning origin
URL: git@192****:molinfo/BPkit.git
 * [pruned] origin/xsjin

#再次查看,发现已经被删了
[sam@c01 germline_dection]$ git remote show origin
* remote origin
  Fetch URL: git@192****:molinfo/BPkit.git
  Push  URL: git@192****:molinfo/BPkit.git
  HEAD branch: sam
  Remote branches:
    jinxs new (next fetch will store in remotes/origin)
    sam   tracked
  Local ref configured for 'git push':
    sam pushes to sam (fast-forwardable)

4.6 时区的修改

GitLab上查看时间的时候,发现GitLab上显示的时间和提交的时间不一致。

现在默认的时区如下图所示为 UTC,我们需要中国的东八区时间,因此

vim /etc/gitlab/gitlab.rb

# gitlab_rails['time_zone'] = 'UTC'
修改为:

gitlab_rails[‘time_zone’] = ‘Asia/Shanghai’

接着重新载入配置和重启服务

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-ctl status

参考资料

药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn