常用的版本控制工具:
- gitlab
- subversion
gitlab部署
(部署需要至少4GB内存来运行)
//安装epel和git
[root@localhost ~]# yum -y install epel-release git
//安装依赖包
[root@localhost ~]# yum -y install curl openssh-server openssh-clients postfix cronie
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm
[root@localhost ~]# rpm -ivh --nodeps policycoreutils-python-2.5-34.el7.x86_64.rpm //忽略依赖关系强制安装
//启动postfix服务并设置开机自启
[root@localhost ~]# systemctl restart postfix.service
[root@localhost ~]# systemctl enable postfix.service
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
//关闭防火墙和selinux
[root@localhost ~]# systemctl disable --now firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
#下载gitlab的rpm包
地址:https://mirror.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm
[root@localhost ~]# ls
anaconda-ks.cfg gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm initial-setup-ks.cfg
//安装 gitlab包
[root@localhost ~]# rpm -ivh gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm
警告:gitlab-ce-15.2.2-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:gitlab-ce-15.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
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=15-2
//修改配置文件
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.2.129' //将此处设为gitlab的服务器ip地址亦或域名
//重载配置文件并重启gitlab
[root@localhost ~]# gitlab-ctl reconfigure
[root@localhost ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 1952) 1s
ok: run: gitaly: (pid 1960) 0s
ok: run: gitlab-exporter: (pid 1974) 0s
ok: run: gitlab-kas: (pid 1976) 1s
ok: run: gitlab-workhorse: (pid 1984) 0s
ok: run: grafana: (pid 1992) 1s
ok: run: logrotate: (pid 2000) 0s
ok: run: nginx: (pid 2006) 0s
ok: run: node-exporter: (pid 2013) 1s
ok: run: postgres-exporter: (pid 2021) 0s
ok: run: postgresql: (pid 2032) 0s
ok: run: prometheus: (pid 2041) 0s
ok: run: puma: (pid 2049) 1s
ok: run: redis: (pid 2054) 0s
ok: run: redis-exporter: (pid 2060) 1s
ok: run: sidekiq: (pid 2066) 0s
[root@localhost ~]# ss -antl //启动后查看会有很多相关服务的端口
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 1024 127.0.0.1:9100 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9229 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:8080 0.0.0.0:*
LISTEN 0 511 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9168 0.0.0.0:*
LISTEN 0 128 127.0.0.1:8082 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9236 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:8150 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:8151 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:3000 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:8153 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:8154 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:8155 0.0.0.0:*
LISTEN 0 128 127.0.0.1:8092 0.0.0.0:*
LISTEN 0 511 0.0.0.0:8060 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9121 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9090 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9187 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9093 0.0.0.0:*
LISTEN 0 128 [::1]:9168 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 1024 *:9094 *:*
ip访问,部署成功出现这个页面
密码破解
[root@localhost ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 15.2.2 (4ecb014a935) FOSS
GitLab Shell: 14.9.0
PostgreSQL: 13.6
------------------------------------------------------------[ booted in 30.36s ]
Loading production environment (Rails 6.1.4.7)
irb(main):001:0> user = User.where(id: 1).first //id为root账户
=> #<User id:1 @root>
irb(main):002:0> user.password = '12345678' //设置密码
=> "12345678"
irb(main):003:0> user.password_confirmation = '12345678'
=> "12345678"
irb(main):004:0> user.save! //保存修改
=> true
irb(main):005:0> exit
登录之后的页面
gitlab常用管理操作
- 项目管理(通常只是创建新项目)
- 创建成员组(针对某个项目创建一个成员组)
- 用户管理(此用户乃gitlab用户而非系统用户)
- 来了新员工,为其添加gitlab用户
- 员工离职,将其gitlab用户禁用或删除
点击创建项目
点击创建空项目
项目创建好之后设置好权限,上传的动作开发人员操作就ok了
使用它提供的代码创建README文件 然后上传到仓库里
[root@localhost ~]# git config --global user.name "root"
[root@localhost ~]# git config --global user.email "ltt20010@126.com"
[root@localhost ~]# git clone http://192.168.2.129/gitlab-instance-abd3cc21/ansible.git
Cloning into 'ansible'...
Username for 'http://192.168.2.129': root // 用户
Password for 'http://root@192.168.2.129': // 密码
warning: You appear to have cloned an empty repository.
// 您似乎克隆了一个空的存储库。
// 自动创建项目目录 Ansible
[root@localhost ~]# ls
anaconda-ks.cfg ansible policycoreutils-python-2.5-34.el7.x86_64.rpm yum.sh
[root@localhost ~]# cd ansible
[root@localhost ansible]# git switch -c main
Switched to a new branch 'main'
[root@localhost ansible]# touch README.md // 创建文件 README.md
[root@localhost ansible]# git add README.md // 最后一次提交
[root@localhost ansible]# git commit -m "add README" // 提交文件
[main (root-commit) 2fd4a82] add README
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
[root@localhost ansible]# git push -u origin main // 上传 文件
Username for 'http://192.168.2.129': root
Password for 'http://root@192.168.2.129':
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 205 bytes | 205.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To http://192.168.2.129/gitlab-instance-abd3cc21/ansible.git
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
// 创建新项目后把本地文件传到仓库里的一种方法
到网页查看是否已提交
创建组
添加用户到 20220810
组里,所以先创建用户
把用户加到组里,给组设置权限。
把用户添加到组里,然后设置组权限,不然来一个用户你就需要设置一个权限,来一个设置一个,工作的效率就低了
使用 tom
用户登录
邀请20220810组到Ansible项目里
总体流程应该是
创建项目
创建组 、 设置组的权限
创建用户 、 把用户拉到组里
项目邀请组,组里面的用户就可以对这个项目进行操作
本文含有隐藏内容,请 开通VIP 后查看