美文网首页
[Gitlab] CentOS7安装gitlab-ce-10.0

[Gitlab] CentOS7安装gitlab-ce-10.0

作者: syushin | 来源:发表于2020-03-18 11:31 被阅读0次

安装

1. 环境说明

$ cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

$ ls
gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

$ ifconfig ens33|awk -F "[ :]+" 'NR==2{print $3}'
192.168.32.130

2. 安装依赖包

$ yum install -y curl policycoreutils-python openssh-server wget 

3. 下载gitlab的rpm包

$ wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

4. 安装gitlab

$ rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

5. 配置gitlab
修改gitlab的配置文件,将external_url改为本机服务器的ip地址。

$ vim /etc/gitlab/gitlab.rb
修改gitlab访问地址

6. 重启gitlab

$ gitlab-ctl reconfigure # 重新配置更新
$ gitlab-ctl restart # 重启
$ gitlab-ctl status # 查看gitlab状态
run: gitaly: (pid 3887) 3281s; run: log: (pid 3257) 3336s
run: gitlab-monitor: (pid 3924) 3280s; run: log: (pid 3643) 3306s
run: gitlab-workhorse: (pid 3909) 3280s; run: log: (pid 3367) 3330s
run: logrotate: (pid 3476) 3318s; run: log: (pid 3475) 3318s
run: nginx: (pid 3428) 3324s; run: log: (pid 3427) 3324s
run: node-exporter: (pid 3591) 3312s; run: log: (pid 3590) 3312s
run: postgres-exporter: (pid 3981) 3279s; run: log: (pid 3815) 3292s
run: postgresql: (pid 2898) 3374s; run: log: (pid 2897) 3374s
run: prometheus: (pid 3969) 3279s; run: log: (pid 3740) 3298s
run: redis: (pid 2774) 3380s; run: log: (pid 2773) 3380s
run: redis-exporter: (pid 3687) 3304s; run: log: (pid 3686) 3304s
run: sidekiq: (pid 3173) 3342s; run: log: (pid 3172) 3342s
run: unicorn: (pid 3104) 3348s; run: log: (pid 3103) 3348s

7. 检查端口

$ netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1170/master         
tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      3428/nginx: master  
tcp        0      0 127.0.0.1:9121          0.0.0.0:*               LISTEN      3687/redis_exporter 
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      3969/prometheus     
tcp        0      0 127.0.0.1:9187          0.0.0.0:*               LISTEN      3981/postgres_expor 
tcp        0      0 127.0.0.1:9100          0.0.0.0:*               LISTEN      3591/node_exporter  
tcp        0      0 127.0.0.1:9168          0.0.0.0:*               LISTEN      3924/ruby           
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      3149/unicorn master 
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3428/nginx: master  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1063/sshd  

8. web首次访问
首次访问时,需要设置密码,我这里设置为12345678。图片是设置后的登陆界面。

gitlab登陆

登陆后就可以进入gitlab界面了。


gitlab主界面

创建第一个Gitlab项目

点击右上角的加号,新建一个project。


在创建项目页面,填写项目名称,项目描述和选择私有,最后点击create project。

image.png

gitlab添加服务器秘钥,现在服务器上创建秘钥

[root@localhost bin]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): ^C
[root@localhost bin]# ssh-keygen -t rsa 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:r6TglxRAl1Om9/7xs5ebol6XpA2S94bbDR6JUn80OA8 root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|   .. .oo        |
|    ..oo         |
|     ....        |
|      .. .  . .  |
|       .S .o.E o.|
|      .  o .oo@oo|
|    .. .. + o+=Bo|
|   . .oo . o.=*=+|
|    ... . .oo.=Bo|
+----[SHA256]-----+
[root@localhost bin]# cd /root/.ssh/
[root@localhost .ssh]# ls
id_rsa  id_rsa.pub
[root@localhost .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGsG1SStRI3pglyv7ou++CvJXzmgRyO99BHo0HeQATwO8bk4O8azIJAMYisegMJzHihG4bjHxo4jmbA6a5f+Dca6al8iJUduCx81BtrS4BWZZpcpfp6Jx9T3vCsPAxOQU6fS6+UoX5/JLqbT0BeZGShZ+00up+RsxKnew38U2uSlw529fQXq4TxpJGraGoc3WkkY4uA4271PgD8tFCgpJBZe2dzNrEMfwvNRTcJROX8btHkzgrwvm+WkRLiKrEwcAvj2hUOZLzG0cDCu/TCHeNvQ0ui4PAc6BLEin6WkRK+pjYsbDtS9z+ffW2/hQNT4wugz9U2IBSeIV7kHBPFp6B root@localhost.localdomain

将秘钥添加到setting中


1
2
3

这样,一个项目就创建完成了。


测试

[root@localhost data]# git clone git@192.168.32.130:root/my-first-project.git
正克隆到 'my-first-project'...
warning: 您似乎克隆了一个空版本库。
[root@localhost data]# cd my-first-project/
[root@localhost my-first-project]# echo "README.md" >> README.md
[root@localhost my-first-project]# git add .
[root@localhost my-first-project]# git commit -m "首次提交" README.md 
[master(根提交) 5beab0b] 首次提交
 Committer: root <root@localhost.localdomain>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 README.md
[root@localhost my-first-project]# git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 233 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.32.130:root/my-first-project.git
 * [new branch]      master -> master
分支 master 设置为跟踪来自 origin 的远程分支 master。
[root@localhost my-first-project]# 

web界面刷新,已经看到新的提交了。


相关文章

网友评论

      本文标题:[Gitlab] CentOS7安装gitlab-ce-10.0

      本文链接:https://www.haomeiwen.com/subject/yccqyhtx.html