zoukankan      html  css  js  c++  java
  • CentOS7下gitlab的搭建

    gitlab的搭建

    • 安装基础包
    yum -y install curl policycoreutils openssh-server openssh-clients
    • 启动sshd
    systemctl enable sshd
    systemctl start sshd
    • 安装postfix
    yum -y install postfix
    systemctl enable postfix
    systemctl start postfix
    • 添加防火墙规则
    firewall-cmd --permanent --add-service=http
    systemctl reload firewalld

     or

    yum install firewalld
    systemctl unmask firewalld
    • 下载并安装软件包(软件包下载较慢)
    curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
    yum install gitlab-ce

    添加国内的镜像源

    执行上面的命令,会一直 time out ,所以我们要换成国内的源.

    以下操作针对CentOS 7 ,其他的请戳 https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

    vi /etc/yum.repos.d/gitlab-ce.repo
    [gitlab-ce]
    name=gitlab-ce
    baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
    repo_gpgcheck=0
    gpgcheck=0
    enabled=1
    gpgkey=https://packages.gitlab.com/gpg.key

    注意,如果对应配置文件下有文件gitlab_gitlab-ce.repo,重命名一下,不然会默认加载这个导致上面的文件不起作用.

    查看目前的yum进程,并杀死

    ps -a
      PID TTY          TIME CMD
    18781 pts/0    00:00:00 sudo
    18783 pts/0    00:00:00 bash
    18796 pts/0    00:00:00 yum
    18855 pts/0    00:00:00 sudo
    18856 pts/0    00:00:00 yum
    18871 pts/0    00:00:00 ps
    
    kill -9 18796
    kill -9 18856

    然后安装:

    sudo yum makecache
    sudo yum install gitlab-ce 

    上面执行完了,是这样的展示结果

    sudo gitlab-ctl reconfigure
    
    gitlab: GitLab should be reachable at http://iZ2851te7e5Z
    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.
      验证中      : gitlab-ce-8.7.6-ce.0.el7.x86_64                                                                                         1/1 
    
    已安装:
      gitlab-ce.x86_64 0:8.7.6-ce.0.el7                                                                                                         
    
    完毕!

    默认安装的是最新的gitlab-ce的包,如果需要特定的版本可以在官网去下载特定的版本 地址:

    https://packages.gitlab.com/gitlab/gitlab-ce/
    • 配置并启动gitlab
     gitlab-ctl reconfigure
    • 默认账户密码是
    Username: root 
    Password: 5iveL!fe

     测试地址(默认80端口):

    http://127.0.0.1/

    2、 gitlab的备份

    • 备份命令
    gitlab-rake gitlab:backup:create

    默然的备份目录为:    /var/opt/gitlab/backups 备份文件名类似:       1393513186_gitlab_backup.tar

    • 备份目录的修改
    vi /etc/gitlab/gitlab.rb
    gitlab_rails['backup_path'] = '/mnt/gitlab_backups'

    3、gitlab数据的恢复或还原

    提示:gitlab数据的恢复或者迁移成功的前提——两台服务器的gitlab的版本必须相同,若不相同则可能迁移或者恢复失败

    • 将备份文件放在gitlab的默认备份目录

    比如/var/opt/gitlab/backups下的1458217074_gitlab_backup.tar

    • 设置自动备份
    0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create 
    • 恢复或者还原

    停服务

     gitlab-ctl stop unicorn
     gitlab-ctl stop sidekiq

    恢复数据

    gitlab-rake gitlab:backup:restore BACKUP=1458213020

    BACKUP后面跟的是备份文件的时间戳,比如恢复备份文件1458217074_gitlab_backup.tar

    gitlab-rake gitlab:backup:restore BACKUP=1458217074
    • 恢复完启动服务
     gitlab-ctl start

    gitlab nginx 修改

    • 配置文件 /var/opt/gitlab/nginx/conf/gitlab-http.conf。这个文件是gitlab内置的nginx的配置文件,里面可以影响到nginx真实监听端口号。
    server {
      listen *:82;
    
      server_name gitlab.123.123.cn;
      server_tokens off; ## Don't show the nginx version number, a security best practice
    • 修改完成后,重启下,就可以放82端口的gitlab了。
    gitlab-ctl restart
    
    

    gitlab redis 修改启用

    默认情况下gitlab是没有启用自带的redis的(虽然redis已经和gitlab一起启动):
    ok: run: gitlab-workhorse: (pid 14263) 1s
    ok: run: logrotate: (pid 14271) 0s
    ok: run: nginx: (pid 14278) 1s
    ok: run: node-exporter: (pid 14284) 0s
    ok: run: postgres-exporter: (pid 14288) 1s
    ok: run: postgresql: (pid 14303) 0s
    ok: run: prometheus: (pid 14312) 1s
    ok: run: redis: (pid 14317) 0s
    ok: run: redis-exporter: (pid 14320) 0s
    ok: run: sidekiq: (pid 14330) 1s
    ok: run: unicorn: (pid 14336) 0s

    启用自带的redis,修改/etc/gitlab/gitlab.rb:

    redis['port'] = 6379
    redis['bind'] = '127.0.0.1'
    [root@localhost ~]# gitlab-ctl reconfigure

    可以看到redis-server和端口6379,redis已经开始工作了:

    Running handlers:
    Running handlers complete
    Chef Client finished, 15/397 resources updated in 25 seconds
    gitlab Reconfigured!

    [root@localhost ~]# gitlab-ctl restart

    [root@localhost ~]# ps -ef|grep redis
    root 639 632 0 14:54 ? 00:00:00 runsv redis
    root 649 632 0 14:54 ? 00:00:00 runsv redis-exporter
    root 653 639 0 14:54 ? 00:00:00 svlogd -tt /var/log/gitlab/redis
    root 668 649 0 14:54 ? 00:00:00 svlogd -tt /var/log/gitlab/redis-exporter
    gitlab-+ 14317 639 0 16:36 ? 00:00:00 /opt/gitlab/embedded/bin/redis-server 127.0.0.1:6379
    gitlab-+ 14320 649 0 16:36 ? 00:00:00 /opt/gitlab/embedded/bin/redis_exporter -web.listen-address=localhost:9121 -redis.addr=unix:///var/opt/gitlab/redis/redis.socket
    root 14376 8935 0 16:36 pts/2 00:00:00 grep --color=auto redis

    访问一下gitlab主页和各页面,然后查看redis里的缓存清况,已经出现缓存内容了:

    [root@localhost ~]# /opt/gitlab/embedded/bin/redis-cli 
    127.0.0.1:6379> keys *
      1) "resque:gitlab:cron_job:admin_email_worker"
      2) "resque:gitlab:cron_job:repository_archive_cache_worker"
      3) "resque:gitlab:limit_fetch:probed:repository_import"
      4) "cache:gitlab:last_commit_id_for_path:2af1c3ff162bb2...................

    详细文档:https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/redis.md



  • 相关阅读:
    WordPress Contact Form插件‘cntctfrm_contact_emai’参数跨站脚本漏洞
    WordPress Pretty Link插件跨站脚本漏洞
    WordPress Responsive Logo Slideshow插件多个HTML注入漏洞
    WordPress Mingle Forum插件多个SQL注入漏洞
    WordPress Car Demon插件多个HTML注入漏洞
    WordPress Marekkis Watermark 跨站脚本漏洞
    WordPress Mingle Forum插件跨站脚本漏洞
    WordPress Contact Form插件‘contact_form.php’跨站脚本漏洞
    WordPress WPTable Reloaded插件 ‘id’参数跨站脚本漏洞
    遇到困难沟通一下
  • 原文地址:https://www.cnblogs.com/river2005/p/6757670.html
Copyright © 2011-2022 走看看