GitLab安装使用

安装

Docker方式

http://www.cnblogs.com/int32bit/p/5310382.html

docker run -d --restart=always \
    --hostname gitlab \
    -p 84:80  \
    --name gitlab \
    --volume /data/gitlab/conf:/etc/gitlab \
    --volume /data/gitlab/home:/var/opt/gitlab \
    --volume /data/gitlab/data:/var/opt/gitlab/git-data/repositories \
    --volume /temp/gitlab/logs:/var/log/gitlab \
    gitlab/gitlab-ce

默认用户root,密码第一次登录时设置

配置GitLab

修改/data/gitlab/etc/gitlab.rb(对应docker容器中为/etc/gitlab/gitlab.rb)

external_url 'http://YOUR_GITLAB_SERVER_DNS_OR_IP'  # 不能加端口
gitlab_rails['internal_api_url'] = 'http://YOUR_GITLAB_SERVER_DNS_OR_IP:PORT'
gitlab-ctl reconfigure

配置LDAP

参考https://docs.gitlab.com/ce/administration/auth/ldap.html

# docker exec -i -t gitlab /bin/bash
root@gitlab:/# vi /etc/gitlab/gitlab.rb
# docker restart gitlab
# gitlab_rails['ldap_enabled'] = false

###! **remember to close this block with 'EOS' below**
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
   main: # 'main' is the GitLab 'provider ID' of this LDAP server
     label: 'LDAP'
     host: 'YOUR_LDAP_SERVER'
     port: 389
     uid: 'uid'
#     uid: 'sAMAccountName'
     bind_dn: 'cn=admin,dc=nodomain'
     password: 'YOUR_LDAP_PASSWORD'
     encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
     timeout: 10
     verify_certificates: true
     ca_file: ''
     ssl_version: ''
     active_directory: true
     allow_username_or_email_login: false
     block_auto_created_users: false
     base: 'ou=users,dc=nodomain'
#     user_filter: '(employeeType=developer)'
     attributes:
       username: ['uid', 'userid', 'sAMAccountName']
       email:    ['mail', 'email', 'userPrincipalName']
       name:       'cn'
       first_name: 'givenName'
       last_name:  'sn'
#     ## EE only
     group_base: ''
     admin_group: ''
     sync_ssh_keys: false 
EOS

备份数据(Docker安装方式)

参考:https://docs.gitlab.com/ee/raketasks/backup_restore.html

sudo docker exec -it gitlab bash
root@gitlab# gitlab-rake gitlab:backup:create

恢复数据(Docker安装方式)

host# docker exec -it gitlab bash
docker# gitlab-ctl reconfigure
docker# gitlab-ctl start
cp 1493107454_2017_04_25_9.1.0_gitlab_backup.tar /data/gitlab/data/backups/
docker# gitlab-ctl stop unicorn
docker# gitlab-ctl stop sidekiq
# Verify
docker# gitlab-ctl status
# 恢复数据
docker# gitlab-rake gitlab:backup:restore BACKUP=1493107454_2017_04_25_9.1.0
# 重启并检查gitlab
docker# gitlab-ctl start
docker# gitlab-rake gitlab:check SANITIZE=true

备份数据(bitnami安装方式)

docker exec -it gitlab /bin/bash
cd /opt/gitlab/
./use_gitlab
cd /opt/gitlab/apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

恢复数据(bitnami安装方式)

cd /opt/gitlab/
./use_gitlab
cd /opt/gitlab/apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:restore RAILS_ENV=production
chown git:git -R /opt/gitlab/apps/gitlab/repositories

使用

免密码登录

参考:https://docs.gitlab.com/ce/ssh/README.html
针对特定的主机,可以免密码执行git的clone、push等命令。

  • 登录git客户端所在主机的bash,注意登录的用户名
  • 确认是否有现成ssh公钥
cd  ~/.ssh
ls   # 确认是否有id_rsa.pub 或 id_dsa.pub
  • 创建一个 SSH key
ssh-keygen -t rsa -C "your_email@example.com"

所有的输入请直接回车,尤其是

Enter passphrase (empty for no passphrase): 

否则git push的时候,每次都需要输入该密码(非git服务器的密码)

  • 添加你的 SSH key 到 github上面去
    登录gitlab–》个人settings–》“SSH Key”
    把前面步骤生成的id_rsa.pub中的内容全部拷贝到Key编辑框中,Title中输入你喜欢的代表该key的任意名字。“Add Key”添加。

  • 在客户端测试
    在客户机上运行git clone、git push等命令。

  • 或在客户端运行

git config --global credential.helper store

当第一输入用户名密码后,会生成~/.git-credentials文件并保存用户名密码

迁移遇到的问题

拷贝data后,不能启动, permission deny

docker exec -it gitlab update-permissions
docker restart gitlab

chown -R git:git /var/opt/gitlab/gitaly/
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值