gitlab一键安装+配置(备份+LADP认证)
#gitlab一键安装#centos6 mini, GitLab社区版#参考官方最新文档 https://www.gitlab.com.cn/installation#关闭防火墙(略)ntpdate ntp6.aliyun.com ##同步时间#更换源yum -y install wget vimmv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repoyum -y install http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpmyum makecache #生成缓存#安装配置依赖yum install curl openssh-server openssh-clients postfix cronie -yservice postfix startchkconfig postfix onlokkit -s http -s ssh# 添加GitLab仓库curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | bashyum install gitlab-ce #(自动安装最新版)#yum install gitlab-ce-8.8.4-ce.0.el6 #(安装指定版本)#下载rpm包安装#https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/#curl -LJO https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-XXX.rpm#rpm -i gitlab-ce-*.rpmvim /etc/gitlab/gitlab.rb #修改配置external_url 'http://192.168.18.9' #修改访问webgitlab_rails['backup_path'] = '/home/backup' #修改备份文件的目录gitlab_rails['backup_keep_time'] = 604800 #备份保存7天(604800是7天的秒数)gitlab-ctl reconfigure #载入配置#v8初始密码:Username: root Password: 5iveL!fe#w1w1e1e1gitlab-ctl status #查看服务状态gitlab-rake gitlab:check SANITIZE=true --trace #检查gitlabgitlab-ctl reconfigure #启动服务gitlab-ctl stop #停止所有 gitlab 组件gitlab-ctl startgitlab-ctl restartvim /etc/gitlab/gitlab.rb #修改默认的配置cat /opt/gitlab/embedded/service/gitlab-rails/VERSION #查看版本gitlab-ctl tail #查看日志##备份gitlab-rake gitlab:backup:create #创建备份#自动备份(定时任务凌晨2点执行)crontab -e0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create#恢复gitlab-ctl stop#BACKUP=xxxxxx ,为备份文件前面的数字部分cd /var/opt/gitlab/backups # 默认备份存放目录gitlab-rake gitlab:backup:restore BACKUP=xxxxxxgitlab-rake gitlab:backup:restore #backups目录只有一个备份时使用 #############################################################汉化#下载对于版本的汉化包https://coding.net/u/larryli/p/gitlab/git/tree/v8.1.2.zh1/#停止服务gitlab-ctl stopcp -arp /opt/gitlab/embedded/service/gitlab-rails /opt/gitlab/embedded/service/gitlab-rails-bak/#下载汉化版替换cd /root/gitlabunzip *.zh1.zip \cp -arp /root/gitlab/gitlab-v8.1.2.zh1/. /opt/gitlab/embedded/service/gitlab-rails/gitlab-ctl reconfigure #重新加载配置启动GitLab##GitLab修改root用户密码# root用户下执行 gitlab-rails console production user = User.where(id: 1).first user.password=12345678 user.password_confirmation=12345678 user.save! quit########完成############################################################AD域配置文件,AD认证用户要对应其目录#也可以使用OpenLADPcp /etc/gitlab/gitlab.rb{,.bak}#cp /etc/gitlab/gitlab.rb.bak /etc/gitlab/gitlab.rbvim /etc/gitlab/gitlab.rb#gitlabexternal_url 'http://192.168.18.10'# LDAP,AD gitlab_rails['ldap_enabled'] = true gitlab_rails['ldap_servers'] = YAML.load <<-EOS main: # 'main' is the GitLab 'provider ID' of this LDAP server label: 'xlh' host: '172.16.16.16' #AD的IP# port: 389 uid: 'sAMAccountName' method: 'plain' # "tls" or "ssl" or "plain" bind_dn: 'CN=gitlab,OU=Dev,OU=users,DC=test,DC=dev' password: '12345678' active_directory: true allow_username_or_email_login: false block_auto_created_users: false allow_username_or_email_login: false block_auto_created_users: false base: 'OU=Dev,OU=users,DC=test,DC=dev' user_filter: '' group_base: '' admin_group: '' sync_ssh_keys: falseEOS###########gitlab-ctl reconfigure #重新载入配置
赞 (0)