栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

gitlab部署及配置

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

gitlab部署及配置

gitlab部署及配置
  • gitlab部署
    • 关闭防火墙和selinux
    • 下载软件包、安装
    • web界面登陆
  • gitlab界面配置
    • 用户
    • 组和权限
    • 项目

gitlab部署 关闭防火墙和selinux
[root@localhost src]# systemctl stop  firewalld.service
[root@localhost src]# setenforce 0

下载软件包、安装
//先要下载一个eple-release源
[root@localhost ~]# yum -y install epel-release

//然后安装所需的依赖包
[root@localhost ]# yum -y install git curl openssh-server openssh-clients postfix cronie policycoreutils-python-utils

//去清华大学的源站中下载gitlab软件包到本地的/usr/src中,然后安装
[root@localhost src]# rpm -ivh gitlab-ce-14.3.2-ce.0.el8.x86_64.rpm 
[root@localhost src]# rpm -ivh gitlab-ce-14.3.2-ce.0.el8.x86_64.rpm 
警告:gitlab-ce-14.3.2-ce.0.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID f27eab47: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:gitlab-ce-14.3.2-ce.0.el8        ################################# [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

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-3


//修改配置文件 /etc/gitlab/gitlab.rb 把域名改成本机的IP地址即可
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.164.133'

//开启邮箱服务
[root@localhost ~]# systemctl enable --now postfix.service 
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@localhost ~]# ss -antl
State   Recv-Q  Send-Q     Local Address:Port     Peer Address:Port  
LISTEN  0       128              0.0.0.0:22            0.0.0.0:*     
LISTEN  0       100            127.0.0.1:25            0.0.0.0:*     
LISTEN  0       128                 [::]:22               [::]:*     
LISTEN  0       100                [::1]:25               [::]:*   

//重新加载配置文件并重启服务,这一步需要点时间,需要耐心等待一会。
[root@localhost src]# gitlab-ctl reconfigure
[root@localhost src]# gitlab-ctl restart
ok: run: alertmanager: (pid 176006) 1s
ok: run: gitaly: (pid 176037) 0s
ok: run: gitlab-exporter: (pid 176161) 0s
ok: run: gitlab-workhorse: (pid 176177) 0s
ok: run: grafana: (pid 176212) 0s
ok: run: logrotate: (pid 176223) 0s
ok: run: nginx: (pid 176254) 1s
ok: run: node-exporter: (pid 176271) 0s
ok: run: postgres-exporter: (pid 176325) 1s
ok: run: postgresql: (pid 176353) 0s
ok: run: prometheus: (pid 176411) 0s
ok: run: puma: (pid 176898) 0s
ok: run: redis: (pid 176903) 0s
ok: run: redis-exporter: (pid 176909) 1s
ok: run: sidekiq: (pid 177268) 0s

破解管理员的密码

[root@localhost ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
 GitLab:       14.3.2 (92acfb1b8a9) FOSS
 GitLab Shell: 13.21.1
 PostgreSQL:   12.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.1.3.2)
irb(main):001:0> user = User.where(id: 1).first   //查找UID是1的管理员账户
=> #   
irb(main):002:0> user.password = 'wjmwjm123'  //设置啊管理员的密码
=> "wjmwjm123"
irb(main):003:0> user.password_confirmation = 'wjmwjm123'    //设置啊管理员的密码
=> "wjmwjm123"
irb(main):004:0> user.save!     //保存用户修改信息
Enqueued ActionMailer::MailDeliveryJob (Job ID: e643fa7a-ff6b-4ab9-b3c5-bd2fc607e78a) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#>]}
=> true
irb(main):006:0> exit
[root@localhost ~]# 

web界面登陆


gitlab界面配置

所有的配置都是在admin界面中进行配置

用户

创建账户
可以直接点击new user,如果已经创建过用户这里没有这个按钮,可以到左边的导航栏中点击users进行创建或其他的操作

设置名称和邮箱、还有访问权限等。这里的密码等创建完成用户后再进行设置点击编辑进行设置密码
password=wjmwjm123

测试,用更改创建好的这个用户登陆gitlab


为了账户的安全,新创建的用户在第一次登陆的时候是需要跟改密码的,这里改成wjmwjm111

更改密码后是要重新登陆一次的


禁用用户
禁用用户后该用户则无法登陆gitlab。同时这里还可以删除用户或者删除用户的同时一并删除这个用户所贡献的内容。

解除禁用的账户
如果这个账户要给新的人使用只需要改一下名称然后把密码设置成初始的密码wjmwjm123即可。当新人第一次登陆的时候同意也是需要重新设置秘密的

组和权限

创建组
组的权限
如果一用户添加到这个组里面后,则组有什么权限 用户就有什么权限

创建完成后可以添加用户到这个组里面

此时这个runtime组里面就有wjm用户了

点击Manage access可以跟改组员的角色,或删除用户等。
组的权限是创建组的时候选择的角色

项目

创建项目

一般情况下我们都是选择创建项目

这里先不勾选最后一个选项


克隆项目到linux服务器中
复制这个地址然后到服务器中执行

[root@localhost ~]# git clone http://192.168.164.133/root/app.git
正克隆到 'app'...
Username for 'http://192.168.164.133': root
Password for 'http://root@192.168.164.133': 
warning: 您似乎克隆了一个空仓库。
[root@localhost ~]# ll
总用量 4
-rw-------. 1 root root 1198 8月   1 14:09 anaconda-ks.cfg
drwxr-xr-x. 3 root root   18 10月 12 20:26 app
[root@localhost ~]# cd app/
[root@localhost app]# ls -a
.  ..  .git
//这个目录中有一个叫.git的文件,说明这是一个仓库

上传文件到仓库中

//全局设置
[root@localhost app]# git config --global user.name "Administrator"
[root@localhost app]# git config --global user.email "admin@example.com"

//切换到一个分支
[root@localhost app]# git switch -c master
切换到一个新分支 'master'

//创建文件,并把这个添加到仓库中去
[root@localhost app]# touch README.md
[root@localhost app]# git add README.md

//提交
[root@localhost app]# git commit -m "add README"
[master(根提交) 176d06d] add README
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
 # -m 描述,做了哪些改动
 
//把代码推送到master中
[root@localhost app]# git push -u origin master 
Username for 'http://192.168.164.133': root
Password for 'http://root@192.168.164.133': 
枚举对象: 3, 完成.
对象计数中: 100% (3/3), 完成.
写入对象中: 100% (3/3), 216 字节 | 216.00 KiB/s, 完成.
总共 3(差异 0),复用 0(差异 0),包复用 0
To http://192.168.164.133/root/app.git
 * [new branch]      master -> master
分支 'master' 设置为跟踪来自 'origin' 的远程分支 'master'。
[root@localhost app]# 

刷新网站就可以看见刚刚推送的文件

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/318063.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号