CentOS部署Gitlab代码管理平台

部署环境准备
#rpm -eperl-Git-1.7.1-3.el6_4.1.noarch git-1.7.1-3.el6_4.1.x86_64 |
#tar -zxvf git-2.6.3.tar.gz #cd git-2.6.3 #autoconf #./configure #make && make install |
1
|
#rpm -e ruby-1.8.7.374-4.el6_6.x86_64ruby-libs-1.8.7.374-4.el6_6.x86_64 |
#tar -zxvf ruby-2.1.7.tar.gz #cd ruby-2.1.7 #./configure #make && make install |
#tar zxvf redis-3.0.5.tar.gz #cd redis-3.0.5 #make install #mkdir -p /opt/apps/redis/bin #mkdir -p /opt/apps/redis/var #mkdir -p/opt/apps/redis/data #mkdir -p /opt/conf/redis #cp redis.conf /opt/conf/redis #cp /opt/src/redis-3.0.5/src/redis-* /opt/apps/redis/bin |
#grep -v ^# /opt/conf/redis/redis.conf | grep -v ^$ daemonize yes pidfile /opt/apps/redis/var/redis .pid port 6379 tcp-backlog 511 bind 192.168.1.236 unixsocket /opt/apps/redis/var/redis .sock unixsocketperm 777 timeout 0 tcp-keepalive 0 loglevel notice logfile "/opt/logs/redis/redis.log" databases 16 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /opt/apps/redis/var slave-serve-stale-data yes slave- read -only yes repl-diskless- sync no repl-diskless- sync -delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua- time -limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash -max-ziplist-entries 512 hash -max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set -max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes |
/opt/apps/redis/bin/redis-server /opt/conf/redis/redis .conf |
sql>create user 'gitlab' @ 'localhost' identified by '123456' ; sql>create database gitlabhq_production; sql>grant all privileges on gitlabhq_production.* to 'gitlab' @ '%' ; sql>flush privileges; |
gem sources --remove https: //rubygems .org/ gem sources -a https: //ruby .taobao.org/ gem install bundler --no-ri --no-rdoc |
安装与配置gitlab
#yum -y install readline readline-develncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-develexpat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffilibffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-develsystem-config-firewall-tui redis sudo wget crontabs logwatch logrotateperl-Time-HiRes git cmake libcom_err-devel libcom_err-devel |
#adduser --system --shell /bin/bash--comment 'Gitlab' --create-home --home-dir /home/git/ git #chmod 775 /home/git |
#su - git $ tar -zxvf gitlabhq-7.12.2. tar .gz $ mv gitlabhq-7.12.2 gitlab |
$ cd gitlab $bundle install --deployment --without development test postgres awsKerberos |
$ cp config /gitlab .yml.example config /gitlab .yml $ vi config /gitlabyml gitlab: host: 192.168.1.236 port: 443 https: true backup: path: "/opt/backups/gitlab" |
$ cp config /database .yml.mysql config /database .yml $ vi config /database .yml production: adapter: mysql2 encoding: utf8 collation: utf8_general_ci reconnect: false database:gitlabhq_production pool: 10 username: gitlab password: "123456" host: localhost socket: /tmp/mysql .sock |
$ cp config /resque .yml.example config /resque .yml $ vi config /resque .yml production: unix: /opt/apps/redis/var/redis .sock |
$ cp config /unicorn .rb.example config /unicorn .rb $ cp config /initializers/rack_attack .rb.example config /initializers/rack_attack .rb $ cp config /initializers/smtp_settings .rb.sample config /initializers/smtp_settings .rb |
$ chmod -R u+rwX,go-w log/ $ chmod -R u+rwX tmp/ $ chmod -R u+rwX tmp /pids/ $ chmod -R u+rwX tmp /sockets/ $ mkdir public /uploads $ chmod -R u+rwX public /uploads $ chmod -R u+rwX builds/ $ chmod -R u+rwX shared /artifacts/ |
安装gitlab相关组件
$bundle exec rake gitlab:shell:installREDIS_URL=unix: /var/run/redis/redis .sock RAILS_ENV=production $ cd /home/git/gitlab-shell $ vi config.yml --- user: git gitlab_url: https: //192 .168.1.236/ http_settings: self_signed_cert: true repos_path: "/home/git/repositories/" auth_file: "/home/git/.ssh/authorized_keys" redis: bin: "/opt/apps/redis//bin/redis-cli" namespace: resque:gitlab socket: "/opt/apps/redis/var/redis.sock" log_level:INFO audit_usernames: false |
$ mkdir -p /home/git/gitlab-satellites |
初始化gitlab
$bundle exec rake gitlab:setup RAILS_ENV=production |
配置系统服务
#cd /home/git/gitlab #cp lib/support/init.d/gitlab /etc/init.d/ #chmod +x /etc/init.d/gitlab #chkconfig --add gitlab |
cp lib /support/logrotate/gitlab /etc/logrotate .d /gitlab |
安装nginx web服务
#yum -y install yum -y install pcre* #tar -zxvfnginx-1.8.0.tar.gz #cd nginx-1.8.0 #./configure--prefix=/opt/apps/nginx --conf-path=/opt/conf/nginx/nginx.conf--error-log-path=/opt/logs/nginx/error.log--http-log-path=/opt/logs/nginx/access.log --with-http_stub_status_module--with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module--with-http_realip_module--http-client-body-temp-path=/opt/apps/nginx/client_body_temp--http-fastcgi-temp-path=/opt/apps/nginx/fastcgi_temp--http-proxy-temp-path=/opt/apps/nginx/proxy_temp--http-uwsgi-temp-path=/opt/apps/nginx/uwsgi_temp--http-scgi-temp-path=/opt/apps/nginx/scgi_temp #make&& make install |
#vi /opt/conf/nginx/nginx.conf includevhost/*.conf; #cp /home/git/gitlab/lib/support/nginx/gitlab-ssl/opt/conf/nginx/vhost/gitlab.conf #vi /opt/conf/nginx/vhost/gitlab.conf(修改相关端口的servername) server_name 192.168.1.236; |
开启服务与测试
#/opt/apps/nginx/sbin/nginx -c /opt/conf/nginx/nginx.conf #servicegitlab start |
#su - git $ cd gitlab $bundle exec rake gitlab:checkRAILS_ENV=production |
Gitlab的备份与恢复
#!/bin/bash # Author: chenminghui # Email: chenminghui@qq.com # Date: 2015-12-09 ###set ENV### GITLAB_HOME= /home/git/gitlab BAK_DIR= /opt/backups/gitlab RAILS_ENV=production backup_gitlab () { su - git -c "cd${GITLAB_HOME} && bundle exec rake gitlab:backup:createRAILS_ENV=${RAILS_ENV}" sleep 3 RETVAL=$? if [ $RETVAL == 0 ]; then echo "The GitLab backupedsuccess.." else echo "Backuk failure!!" fi } backup_gitlab #Delete backup files beforesysdate-30 days. find ${BAK_DIR} - type f-mtime +30 - exec rm -rf {} \; ##restore command if youneed.. ##bundle exec rakegitlab:backup:restore RAILS_ENV=production BACKUP=timestamp_of_backup |
本文由 CentOS中文站 - 专注Linux技术 作者:centos 发表,其版权均为 CentOS中文站 - 专注Linux技术 所有,文章内容系作者个人观点,不代表 CentOS中文站 - 专注Linux技术 对观点赞同或支持。如需转载,请注明文章来源。