gitlab服务器安装

news/2024/7/4 13:26:48

1、示例主机信息:

hostname:vm0.lansgg.com

ip        :    192.168.85.128

Os        : centos 6.5 x64

gitlab版本:  gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm

Ps : 关闭 iptables selinux

2、系统依赖软件安装

1
root@vm0 ~] # yum install curl openssh-server openssh-clients  cronie –y

3、安装gitlab

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@vm0 ~] # rpm -vhi gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm 
Preparing...                 ########################################### [100%]
    1:gitlab-ce               ########################################### [100%]
gitlab: Thank you  for  installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:
 
sudo  gitlab-ctl reconfigure
 
gitlab: GitLab should be reachable at http: //vm0 .lansgg.com
gitlab: Otherwise configure GitLab  for  your system by editing  /etc/gitlab/gitlab .rb  file
gitlab: And running reconfigure again.
gitlab: 
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https: //gitlab .com /gitlab-org/omnibus-gitlab/blob/master/README .md
gitlab: 
It looks like GitLab has not been configured yet; skipping the upgrade script.
[root@vm0 ~] #

3.1、初始化 

1
[root@vm0 ~] # gitlab-ctl reconfigure

到此安装成功:

地址:http://192.168.85.128/

默认用户名是 root , 密码是 5iveL!fe

登陆后会提示修改当前管理员密码

4、设置https

创建ssl证书目录

1
2
3
4
5
6
7
[root@vm0 ~] # mkdir -p /etc/gitlab/ssl
[root@vm0 ~] # cd /etc/gitlab/ssl/
[root@vm0 ssl] # ll
总用量 8
-rw-r--r--. 1 root root 1444 9月   7 16:16 vm0.lansgg.com.crt
-rw-r--r--. 1 root root 1704 9月   7 16:16 vm0.lansgg.com.key
[root@vm0 ssl] #

4.1、修改git配置项中的ssl证书文件地址     #/etc/gitlab/gitlab.rb(#大约是477行)

1
2
3
4
5
6
7
11 external_url '
472  nginx[ 'enable' ] =  true
473  nginx[ 'client_max_body_size' ] =  '250m'
474  nginx[ 'redirect_http_to_https' ] =  false
475  # nginx['redirect_http_to_https_port'] = 80
476  nginx[ 'ssl_client_certificate' ] =  "/etc/gitlab/ssl/vm0.lansgg.com.crt"
477  nginx[ 'ssl_certificate' ] =  "/etc/gitlab/ssl/vm0.lansgg.com.crt"

wKioL1fPzhOS90LRAABeko6ArO4912.jpg-wh_50

4.2、修改nginx配置文件

1
2
3
4
5
38 server {
  39   listen *:443;
  40   ssl on;
  41   ssl_certificate  /etc/gitlab/ssl/vm0 .lansgg.com.crt;
  42   ssl_certificate_key  /etc/gitlab/ssl/vm0 .lansgg.com.key;

wKiom1fPzqGwCYj2AAAps_98CtY988.jpg-wh_50

4.3、配置http跳转https

1
2
3
4
5
6
7
[root@vm0 ssl] # vim /var/opt/gitlab/nginx/conf/index.conf            ###新建
server {
     listen *:80;
     server_name www.abc.com;
   
     rewrite ^(.*)$  https: // $host$1 permanent;
}

wKiom1fPzwyz__gqAAAnVI1TsZQ705.jpg-wh_50

4.4、修改配置文件载入index.conf

配置文件地址:/var/opt/gitlab/nginx/conf/nginx.conf,在其中加入以下内容

1
2
include /var/opt/gitlab/nginx/conf/index .conf;
include /var/opt/gitlab/nginx/conf/gitlab-http .conf;

4.5、重启服务

以上操作全部完成之后, 使用gitlab-ctl restart来重启所有服务, 即可使用HTTPS访问GitLab了.

https://192.168.85.128 

https://vm0.lansgg.com


5、gitlab的备份与还原

5.1、gitlab的备份

使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份:

1
[root@vm0 ssl] # gitlab-rake gitlab:backup:create

使用以上命令会在/var/opt/gitlab/backups目录下创建一个名称类似为:

1467362634_gitlab_backup.tar 的压缩包, 这个压缩包就是Gitlab整个的完整部分, 其中开头的  1473237111  是备份创建的日期.

wKiom1fP0Lfyt1blAAB4iUGQjJE645.jpg-wh_50

Gitlab 修改备份文件默认目录

1
[root@vm0 etc] # vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

wKiom1fP0TKjQ8G4AABixakT-_U893.jpg-wh_50

Gitlab 自动备份

也可以通过crontab使用备份命令实现自动备份:

1
0 2 * * * /opt/gitlab/bin/gitlab-rake  gitlab:backup:create

5.2、gitlab的还原


停止相关服务

1
2
[root@vm0 etc] # gitlab-ctl stop unicorn
[root@vm0 etc] # gitlab-ctl stop sidekiq


从备份文件中恢复

以20160630 的备份文件 1467225280_gitlab_backup.tar为例 )

将恢复文件 1467225280_gitlab_backup.tar 放到gitlab的备份目录

[root@slvae4 gitback]# cp 1467225280_gitlab_backup.tar/var/opt/gitlab/backups/

 

按照编号进行恢复

[root@slvae4 gitback]# gitlab-rake gitlab:backup:restoreBACKUP=1467225280


重新启动

1
[root@vm0 etc] # gitlab-ctl restart


解决方案

1、按照上述恢复 gitlab后,放你访问git地址时,可能会出现 500 错误;如下:

wKiom1fP0ifBTLtKAAB6vu3u9TM032.jpg-wh_50

查看日志信息如下:

wKiom1fP0l6CRvxJAAB5D1ujIeA751.jpg-wh_50

初步以为,因为使用ssl访问时加解密的问题;查了资料,尝试以下步骤:

The temporary solutions are:

  1. Copy the old     db_key_base from the old instance to the new one.

  2. Delete     imported project data that is no longer required by projects. Something     like this may work:


执行命令:gitlab-rails runner "Project.where.not(import_url: nil).each { |p| p.import_data.destroyif p.import_data }"



本文转自 西索oO 51CTO博客,原文链接:http://blog.51cto.com/lansgg/1847370


http://www.niftyadmin.cn/n/3046010.html

相关文章

java super csv_java导出csv方法实现讲解

首先,通过ibatis中的sql语句查询出所要得到的记录,并将其存放在List中:List> results this.reportService.getArrayBeanReportDataSource(super.getQuery_sql_csv(), query_obj);这样的情况下,因为我们是要写公共方法&#xf…

Windows系统默认的SID 值

许多用户帐户、 本地的组和全局组已跨所有安装的 Windows NT 的默认安全标识符 (SID) 或相对标识符 (RID) 值。可以通过使用该实用程序从 Windows NT 资源工具包 Getsid.exe 显示这些值。 下面的信息来自名为域名的域控制器。在 Windows NT 工作站或服务器安装的默认组不同&am…

POJ 1833 排列【STL/next_permutation】

题目描述: 大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n3时,列出1 2 3,1 3 2,2 1 3&am…

第三方库的编译

ACE的编译问题 ACE链接时碰到下面一大堆错误: client-SSL-client.o: In function ACE_SSL_SOCK_Stream::close():../../../../ace/SSL/SSL_SOCK_Stream.i:278: undefined reference to SSL_shutdown../../../../ace/SSL/SSL_SOCK_Stream.i:280: undefined reference…

配置远程客户机使用命名管道协议访问SQL服务器

配置远程客户机使用命名管道协议访问SQL服务器 标签:配置 SQL 服务器 管道 命名 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://alligator.blog.51cto.com/36993/79687 常见…

java 编译器static_java之static的详解

static关键字在类中,用static声明的成员变量为静态成员变量,也成为类变量。类变量的生命周期和类相同,在整个应用程序执行期间都有效。这里要强调一下:static修饰的成员变量和方法,从属于类普通变量和方法从属于对象静…

访问量破1000之记录

哇,蒟蒻凭着不停的膜题解,然后再用自己的话说一遍出来的方法,居然骗到了1000只野生神犇的访问[有时候觉得别人说得太好了,还只给了一个链接...而且有时候还自己刷刷访问量啥的...2333] 而且发现自己也从没有照顾没有权限的人的意识,题目都只给一个链接,都没有想过去截图什么的.…

java反射 fast reflect_Java 反射的性能问题

最近在了解反射优化的东西,做了一个 cglib,java 的反射 api 和直接调用的性能比较public class SampleBean {public String echo(String name) {return name;}}测试代码:FastClass fastClass FastClass.create(SampleBean.class);FastMethod fastMethod…