天天看点

自动化部署之gitlab部署

安装依赖及gitlab

1

2

<code>[root@linux-node1 ~]</code><code># yum install -y curl policycoreutils openssh-server openssh-clients postfix </code>

<code>[root@linux-node1 ~]</code><code># systemctl start postfix</code>

2.安装gitlab

3

4

5

6

7

8

9

10

11

<code>由于国内网络偏慢,这里使用清华大学的镜像源进行安装gitlab-ce</code>

<code>[root@linux-node1 ~]</code><code># cat /etc/yum.repos.d/gitlab-ce.repo</code>

<code>[gitlab-ce]</code>

<code>name=gitlab-ce</code>

<code>baseurl=http:</code><code>//mirrors</code><code>.tuna.tsinghua.edu.cn</code><code>/gitlab-ce/yum/el7</code>

<code>repo_gpgcheck=0</code>

<code>gpgcheck=0</code>

<code>enabled=1</code>

<code>gpgkey=</code>

<code>[root@linux-node1 ~]</code><code>#  yum makecache</code>

<code>[root@linux-node1 ~]</code><code>#  yum install -y gitlab-ce</code>

3.修改配置文件

<code>[root@linux-node1 ~]</code><code># vim /etc/gitlab/gitlab.rb </code>

<code>external_url </code><code>'http://192.168.56.11'</code> 

<code>[root@linux-node1 ~]</code><code># gitlab-ctl reconfigure</code>

<code>这一步时间比较长,耐心等待</code>

<code>gitlab常用命令:</code>

<code>关闭gitlab:[root@linux-node1 ~]</code><code># gitlab-ctl stop</code>

<code>启动gitlab:[root@linux-node1 ~]</code><code># gitlab-ctl start</code>

<code>重启gitlab:[root@linux-node1 ~]</code><code># gitlab-ctl restart</code>

<code>重载配置文件: gitlab-ctl reconfigure</code>

可以使用<code>gitlab-ctl</code>管理gitlab,例如查看gitlab状态:

12

13

14

<code>[root@linux-node1 ~]</code><code># gitlab-ctl status</code>

<code>run: gitaly: (pid 53207) 176s; run: log: (pid 52331) 647s</code>

<code>run: gitlab-monitor: (pid 53233) 174s; run: log: (pid 52406) 620s</code>

<code>run: gitlab-workhorse: (pid 53189) 180s; run: log: (pid 52274) 671s</code>

<code>run: logrotate: (pid 52307) 654s; run: log: (pid 52306) 654s</code>

<code>run: nginx: (pid 53694) 2s; run: log: (pid 52285) 665s</code>

<code>run: node-exporter: (pid 52388) 631s; run: log: (pid 52387) 631s</code>

<code>run: postgres-exporter: (pid 53262) 171s; run: log: (pid 52478) 581s</code>

<code>run: postgresql: (pid 52013) 855s; run: log: (pid 52012) 855s</code>

<code>run: prometheus: (pid 53245) 172s; run: log: (pid 52443) 598s</code>

<code>run: redis: (pid 51951) 867s; run: log: (pid 51950) 867s</code>

<code>run: redis-exporter: (pid 52426) 609s; run: log: (pid 52425) 609s</code>

<code>run: sidekiq: (pid 52256) 677s; run: log: (pid 52255) 677s</code>

<code>run: unicorn: (pid 52218) 683s; run: log: (pid 52217) 683s</code>

提示:gitlab需要使用到80端口,所以得保证80端口不被占用

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

<code>[root@linux-node1 ~]</code><code># lsof -i:80</code>

<code>COMMAND   PID   USER   FD   TYPE DEVICE SIZE</code><code>/OFF</code> <code>NODE NAME</code>

<code>httpd     963 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd    1156 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd    1392 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd    1544 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd   22057   root    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd   22793 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd   23247 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd   23367 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd   26356 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd   64149 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>httpd   64641 apache    4u  IPv6  56349      0t0  TCP *:http (LISTEN)</code>

<code>[root@linux-node1 ~]</code><code># systemctl stop httpd</code>

<code>[root@linux-node1 ~]</code><code># gitlab-ctl restart</code>

<code>ok: run: gitaly: (pid 55012) 0s</code>

<code>ok: run: gitlab-monitor: (pid 55022) 1s</code>

<code>ok: run: gitlab-workhorse: (pid 55025) 0s</code>

<code>ok: run: logrotate: (pid 55034) 1s</code>

<code>ok: run: nginx: (pid 55036) 0s</code>

<code>ok: run: node-exporter: (pid 55046) 1s</code>

<code>ok: run: postgres-exporter: (pid 55051) 0s</code>

<code>ok: run: postgresql: (pid 55059) 1s</code>

<code>ok: run: prometheus: (pid 55066) 0s</code>

<code>ok: run: redis: (pid 55072) 0s</code>

<code>ok: run: redis-exporter: (pid 55081) 0s</code>

<code>ok: run: sidekiq: (pid 55105) 0s</code>

<code>ok: run: unicorn: (pid 55112) 0s</code>

<code>COMMAND   PID       USER   FD   TYPE  DEVICE SIZE</code><code>/OFF</code> <code>NODE NAME</code>

<code>nginx   54794       root    8u  IPv4 1562548      0t0  TCP *:http (LISTEN)</code>

<code>nginx   54802 gitlab-www    8u  IPv4 1562548      0t0  TCP *:http (LISTEN)</code>

4.浏览器访问登录:

安装完成!

本文转自 IT_外卖小哥  51CTO博客,原文链接:http://blog.51cto.com/jinlong/2052334