抹布
精华
|
战斗力 鹅
|
回帖 0
注册时间 2010-8-26
|
楼主 |
发表于 2015-5-8 18:03
|
显示全部楼层
感谢LS几位前辈的帮助 现在我的gitlab基本可以工作了 虽然仍然有一大堆问题在。。 这里贴出我的一些总结 让后来者可以缩短一些摸索时间(以天为单位!!!) 因为不能贴图 所以有些地方可能很奇怪 见谅
使用CentOs 推荐6.x 7.x 带GUI的版本
下载Bitnami Gitlab installer安装包 注意32/64位
安装CentOs 注意磁盘空间分配不要太小 因为系统和bitnami installer安装完就要占用8G空间
打开iptables/防火墙 开放web ssh的端口
打开服务 启动sshd服务
某些情况下可能需要设置一个固定ip 而不能用dhcp
把installer包(xxx.run文件)拷贝进系统
首先修改run文件的属性 参照 https://bitnami.com/stack/gitlab/README.txt
chmod 755 bitnami-gitlab-xxxxxxx-linux.run
然后双击安装 需要等待一会才会跳出界面 如果出现的是解压而不是安装 应该是属性不对
安装中可以设置smtp 但是我没有成功收到过邮件 原因不明
默认安装在 /opt/gitlab-xxxx 路径 安装完毕会出现这个界面
一些修改:
修改host 参照 https://wiki.bitnami.com/Applications/BitNami_GitLab
If you want, you can configure it manually. These are the configuration options that you should modify in the "/opt/bitnami/apps/gitlab/htdocs/config/gitlab.yml" file:
host: YOUR_DOMAIN
把 这里的 YOUR_DOMAIN 改成服务器ip地址
Then restart Apache server
单独重启 Apache服务
关闭用户注册
admin area界面 左边menu里选择最下面的那个设置 右边界面去掉sign up的勾勾
这样做是为了 只能让管理员手动添加帐户
备份 恢复
bitnami官方的: https://wiki.bitnami.com/Applications/BitNami_GitLab
貌似是整个运行环境(程序和数据)的全备份 没有意义
gitlab官方的: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md
推荐用我测试测试通过的方法: http://devzc.com/m/?post=438
使用use_gitlab 完美完成备份和恢复
原文如下(下划线为我的补充):
----------begin-----------
重要说明: 至少要保证mysql是处于运行中才可以 否则会出现数据库连接错误
另外就是为了防止升级后不兼容导致不能恢复 应该把当前正在使用的版本做好保存 尤其是操作系统和bitnami installer(.run文件)
没有做定时备份的话应该定期备份一下 比如每天一次。。。
假定gitlab安装路径为: /opt/gitlab-6.4.3-1/
全程以root用户操作
1.设定备份目录:
/opt/gitlab-6.4.3-1/apps/gitlab/htdocs/config/gitlab.yml
其实可以不用修改 使用默认的tmp/backups 具体目录是 /opt/gitlab-xxxx/apps/gitlab/htdocs/tmp/backups/
2.备份:
有些时候会报错: You have already activated rake 0.9.2.2,but our Gemfile requires rake 10.1.0,Using bundle exec may solve this.
原因是默认的path路径不对,需要执行下bitnami自带的环境变量设置脚本: use_gitlab 即可解决。
没遇到过 不清楚在说什么
下面是备份用到的完整命令:
cd /opt/gitlab-6.4.3-1/
./use_gitlab
cd /opt/gitlab-6.4.3-1/apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production
3.恢复:
恢复的时候需要用到backups这个文件夹 但是新安装好的环境没有这个文件夹 推荐先做一次备份操作让他自动生成这个文件夹然后再进行恢复操作
BACKUP=timestamp_of_backup #(required if more than one backup exists):
下面是恢复用到的完整命令:
cd /opt/gitlab-6.4.3-1/
./use_gitlab
cd /opt/gitlab-6.4.3-1/apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:restore RAILS_ENV=production BACKUP=1405247282
如果backups里面没有其他文件 可以不添加backup=xxx这个参数
chown git:git -R /opt/gitlab-6.4.3-1/apps/gitlab/repositories
这个命令必须 否则git这个用户账号不能访问repositories这个目录 会引发git操作相关的所有问题
另外 恢复之后做git操作可能会出现如下错误
/opt/gitlab-7.10.1-0/ruby/lib/ruby/2.0.0/logger.rb:594:in `initialize': Permission denied - /opt/gitlab-7.10.1-0/apps/gitlab/gitlab-shell/gitlab-shell.log (Errno::EACCES)
原因是gitlab-shell.log这个文件的所有权或读写权里没有git这个用户 需要手动修改
查看文件权限的方法: ls -l
修改这个文件权限: chown git:git gitlab-shell.log
下面这段没测试过不清楚
4.crontab定时备份脚本参考:
use_gitlab使用了exec,脚本会重新打开一个进程,没有上下文,所以需要单独提出path.
脚本需要使用root账户运行。脚本包含了rsync远程同步到nas相应目录中,按照自己实际修改即可(预先生成ssh证书,免密码登录)。
#!/bin/bash
if [ `id -u` -ne 0 ];then
echo "this backup script must be exec as root."
exit
fi
date
PATH="/opt/gitlab-6.4.3-1/apps/gitlabci/gitlabci-runner/bin:/opt/gitlab-6.4.3-1/apps/gitlab/gitlab-shell/bin:/opt/gitlab-6.4.3-1/redis/bin:/opt/gitlab-6.4.3-1/sqlite/bin:/opt/gitlab-6.4.3-1/python/bin:/opt/gitlab-6.4.3-1/perl/bin:/opt/gitlab-6.4.3-1/git/bin:/opt/gitlab-6.4.3-1/ruby/bin:/opt/gitlab-6.4.3-1/mysql/bin:/opt/gitlab-6.4.3-1/apache2/bin:/opt/gitlab-6.4.3-1/common/bin:$PATH"
echo "backup gitlab to local storage begin.. "
cd /opt/gitlab-6.4.3-1/apps/gitlab/htdocs
bundle exec bin/rake gitlab:backup:create RAILS_ENV=production
echo "rsync -avzP --delete /data/backups_gitlab xxx@xxx.com:/mnt/disk1/docs/rsync_gitlab_backup"
rsync -avzP --delete /data/backups_gitlab xxx@xxx.com:/mnt/disk1/docs/rsync_gitlab_backup/
date
echo "this job is end."
----------end-----------
其他补充:
gitlab多人协同工作
http://herry2013git.blog.163.com/blog/static/219568011201341111240751/ |
|