博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gitlab的介绍
阅读量:5052 次
发布时间:2019-06-12

本文共 11293 字,大约阅读时间需要 37 分钟。

gitlab的安装:

首次登陆的密码:

输入:root/5iveL!fe 登录!

——————————————————————————————————————————————————————

 

一键安装

------------------------------------

1.安装配置依赖关系

yum install curl openssh-server openssh-clients postfix cronie wget lokkit -y

service postfix start 邮件服务的开通

lokkit -s http -s ssh #配置iptables开放http和ssh端口

iptables -L 查看iptables的规则

ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22

ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80

----------------------------------------------------------------------------
下载RPM包:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-8.9.9-ce.0.el6.x86_64.rpm 清华大学开源软件镜像站

rpm -ivh gitlab-ce-8.9.9-ce.0.el6.x86_64.rpm

启动GitLab

gitlab-ctl reconfigure

------------------------------------------------------------------------------
另一种方法:(官方文档)

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

yum install gitlab-ee

gitlab-ctl reconfigure

-------------------------------------------------------------------------------
http://ip

root/5iveL!fe

重启:

gitlab-ctl restart

-----------------------------------------------------

502错误

是内存不足导致

dd if=/dev/zero of=/var/swap bs=1024 count=2048000

mkswap /var/swap

swapon /var/swap 激活虚拟内存

vim /etc/fstab

/var/swap swap swap defaults 0 0

mount -a

------------------------------------------------------------

修改端口:

vim /etc/gitlab/gitlab.rb

## Advanced settings

unicorn['listen'] = '127.0.0.1'
# unicorn['port'] = 8080
unicorn['port'] = 8082

# nginx['ssl_dhparam'] = nil # Path to dhparams.pem, eg. /etc/gitlab/ssl/dhparams.pem
nginx['listen_addresses'] = ['*']
nginx['listen_port'] = 82 # override only if you use a reverse proxy: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#setting-the-nginx-listen-port

vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

listen "127.0.0.1:8082", :tcp_nopush => true

listen "/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket", :backlog => 1024

vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

server {
# listen *:80;
listen *:82;

server_name localhost;
server_tokens off;

gitlab-ctl restart 重启gitlab

nginx做代理进行修改:

vim /usr/local/nginx/conf/conf.d/gitlab.conf

server {

listen 80;
server_name gitlab.123.123.cn;

location / {

#rewrite ^(.*) http://127.0.0.1:8082;
proxy_pass http://127.0.0.1:8082;
}
}

修改gitlab-shell

vim /var/opt/gitlab/gitlab-shell/config.yml

# Url to gitlab instance. Used for api calls. Should end with a slash.

#gitlab_url: "http://127.0.0.1:9090"
gitlab_url: "http://127.0.0.1:82"

gitlab-ctl restart 重启服务

---------------------------------------------------------------------------

创建私钥公钥:

ssh-keygen -t rsa -C "xxxx@163.com" 生成私钥公钥

git config --global user.name "tom" 设置username

git config --global user.email "alice" 设置user的email地址

上传公钥:

cat id_rsa.pub 把公钥复制到web页面相应位置上

创建新的项目:

git clone git@localhost:root/project.git 克隆一个项目

cd project/

touch README.md

git add README.md

git commit -m "add README"

git push -u origin master

 ==========================================================================================

 

gitlab的备份

 

gitlab的备份

1.必须是root用户执行

vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/gitlab.yml

backup:

path: "/tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/) 路径可以自定义
keep_time: 604800 # default: 0 (forever) (in seconds)

cd /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/

/opt/gitlab-6.6.5-0/ruby/bin/bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

ll /tmp/backups

-rw-r--r--. 1 root root 40960 Jun 1 16:10 1496304653_gitlab_backup.tar

成功

gitlab的数据恢复

cd /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/

/opt/gitlab-6.6.5-0/ruby/bin/bundle exec bin/rake gitlab:backup:restore RAILS_ENV=production

如果有多个备份文件则在RAILS_ENV=production 后制定恢复哪个文件 BACKUP=1496304653_gitlab_backup.tar

 

备份脚本

#!/bin/bash

#if [ `id -u` -ne 0 ];then

# echo "this backup script must be exec as root."
# exit
#fi
#date
PATH="/opt/gitlab-6.6.5-0/apps/gitlabci/gitlabci-runner/bin:/opt/gitlab-6.6.5-0/apps/gitlab/gitlab-shell/bin:/opt/gitlab-6.6.5-0/redis/bin:/opt/gitlab-6.6.5-0/sqlite/bin:/opt/gitlab-6.6.5-0/python/bin:/opt/gitlab-6.6.5-0/perl/bin:/opt/gitlab-6.6.5-0/git/bin:/opt/gitlab-6.6.5-0/ruby/bin:/opt/gitlab-6.6.5-0/mysql/bin:/opt/gitlab-6.6.5-0/apache2/bin:/opt/gitlab-6.6.5-0/common/bin:$PATH"

echo "backup gitlab to local storage begin.. "

cd /opt/gitlab-6.6.5-0/apps/gitlab/htdocs

/opt/gitlab-6.6.5-0/ruby/bin/bundle exec bin/rake gitlab:backup:create RAILS_ENV=production

echo "rsync -avzP --delete /tmp/backups 192.168.1.100:/gitlab/back"

rsync -avzP --delete /tmp/backups 192.168.1.100:/gitlab/back

date

echo "this job is end."

=======================================================================================

git的上传文件和代码

创建私钥公钥:

ssh-keygen -t rsa -C "xxxx@163.com" 生成私钥公钥

上传公钥:

cat /root/.ssh/id_rsa.pub 把公钥复制到web页面相应位置上

git config --global user.name "tom" 设置username

git config --global user.email "alice" 设置user的email地址

创建新的项目:

git clone git@localhost:root/project.git 克隆一个项目

cd project/

touch README.md

git add README.md

git commit -m "add README"

git push -u origin master

git init 创建可管理的仓库

git clone ssh:git@192.168.1.132:good/test.git 克隆线上仓库

git status 查看是否有文件需要提交

git add -A or git add . 把文件添加到暂存区里面去 -A和. 是全部

git status 查看状态

git commit -m "first push" 提交文件到仓库 ""是注释

git log 查看日志

git remote add origin [git@192.168.1.132:good/test.git] 填写项目的url地址 这样做可以默认推送到远端master分支

git push -u origin master 把本地仓库分支推送到元仓库(远程)

git pull origin master 接收数据 (不能应用多分支Pull的情况)

git branch 查看当前分支

git checkout -b dev dev是分支名 创建并切换到分支

git checkout dev 切换分支

git branch dev 创建分支

git branch -d dev 删除分支

git merge dev 合并分支

====================================================================================

一键安装

chmod +x bitnami-gitlab-6.6.5-0-linux-x64-installer.run

./ bitnami-gitlab-6.6.5-0-linux-x64-installer.run

GitLab CI [Y/n] :Y

Is the selection above correct? [Y/n]: Y

Select a folder [/opt/gitlab-6.6.5-0] 安装目录(默认在/opt/gitlab-6.6.5-0)

Email Address [user@example.com]: zhangxiandong@e-eduspace.com 邮件地址

Login [user]: tom 登陆名

Password: 默认是8位字符以上

Please confirm your password :

Domain [127.0.0.1]: 192.168.1.131 域名地址

Do you want to configure mail support? [y/N]: N 是否支持邮件

Default email provider:

[1] GMail 谷歌邮箱

[2] Custom 自定义

Please choose an option [1] : 2

Configure SMTP Settings

This data is stored in the application configuration files and may be visible to

others. For this reason, it is recommended that you do not use your personal
account credentials.

Username []: zhangxiandong 邮箱名

Password : 邮箱密码

Re-enter : 重复输入

SMTP Host []: e-eduspace@.com

SMTP Port []: 25

Secure connection 安全连接

[1] None

[2] SSL
[3] TLS

Please choose an option [3] : 1

Setup is now ready to begin installing Bitnami Gitlab Stack on your computer.

Do you want to continue? [Y/n]: Y

Please wait while Setup installs Bitnami Gitlab Stack on your computer.

Installing

0% ______________ 50% ______________ 100%
#########################################

----------------------------------------------------------------------------

Setup has finished installing Bitnami Gitlab Stack on your computer.

Info: To access the Bitnami Gitlab Stack, go to

http://192.168.1.131:80 from your browser.
Press [Enter] to continue :

开启服务的命令:

cd /opt/gitlab-6.6.5-0/

./ctlscript.sh

也可以单独服务的重启和关闭

./ctlscript.sh mysql or redis

============================================================================================
apache mysql和redis的端口修改文件

httpd的默认端口的修改

vim /opt/gitlab-6.6.5-0/apache2/conf/httpd.conf apache的配置文件

Listen 8080

ServerName localhost:8080

vim /opt/gitlab-6.6.5-0/apache2/conf/bitnami/bitnami.conf

NameVirtualHost *:8080

<VirtualHost _default_:8080>

vim /opt/gitlab-6.6.5-0/apache2/scripts/ctl.sh

echo "$0 $ARG: httpd started at port 8080"

vim /opt/gitlab-6.6.5-0/apache2/conf/extra/httpd-vhosts.conf

<VirtualHost *:8080>

<VirtualHost *:8080>

vim /opt/gitlab-6.6.5-0/apps/gitlabci/conf/httpd-vhosts.conf

<VirtualHost *:8080>

vim /opt/gitlab-6.6.5-0/redis/etc/redis.conf redis的配置文件

mysql默认端口的修改

vim /opt/gitlab-6.6.5-0/mysql/my.cnf mysqld的配置文件

port=3306

vim /opt/gitlab-6.6.5-0/mysql/scripts/ctl.sh 修改mysql的端口

--port=3306

echo "$0 $ARG: mysql started at port 3306"

vim /opt/gitlab-6.6.5-0/apps/gitlabci/htdocs/config/database.yml

port: 3306 修改端口号

redis默认端口的修改

vim /opt/gitlab-6.6.5-0/redis/etc/redis.conf

port 6379

vim /opt/gitlab-6.6.5-0/redis/scripts/ctl.sh

REDIS_PORT=6379

REDIS_PORT=6379

==================================================================================

vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/gitlab.yml 邮件发送的配置

# Email address used in the "From" field in mails sent by GitLab

email_from: 15100126734@163.COM

# Email address of your support contact (default: same as email_from)

support_email: 15100126734@163.COM

## GitLab settings

gitlab:

## Web server settings (note: host is the FQDN, do not include http://)

host: 192.168.1.132 改成域名 例如:pepstack.com

port: 80

https: false

# Uncomment and customize the last line to run in a non-root path

# WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this.
# Note that four settings need to be changed for this to work.
# 1) In your application.rb file: config.relative_url_root = "/gitlab"
# 2) In your gitlab.yml file: relative_url_root: /gitlab
# 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
# 4) In ../gitlab-shell/config.yml: gitlab_url: "http://127.0.0.1/gitlab"
# To update the path, run: sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
#

relative_url_root: /gitlab

==================================================================================

vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/environments/production.rb 发送邮件的配置

cp /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/initializers/{smtp_settings.rb.sample,smtp_settings.rb}

vim /opt/gitlab-6.6.5-0/apps/gitlab/htdocs/config/initializers/smtp_settings.rb 邮件的配置文件

=====================================================================================================

 

vim /opt/gitlab-6.6.5-0/apps/gitlab/conf/httpd-app.conf 置于nginx后面使用

<Directory "/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/public">

Options -MultiViews
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>

SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"

PassengerEnabled on

PassengerAppRoot "/opt/gitlab-7.8.1-0/apps/gitlab/htdocs/"
<IfModule pagespeed_module>
ModPagespeedDisallow "*"
</IfModule>
PassengerUser git
PassengerGroup git
SetEnv MAGIC "/opt/gitlab-7.8.1-0/ruby/lib/ruby/gems/2.0.0/gems/charlock_holmes-0.6.9.4/ext/charlock_holmes/src/file-5.08/magic/magic.mgc"
SetEnv PATH "/opt/gitlab-7.8.1-0/python/bin:${PATH}"

</Directory>
PassengerPreStart http://127.0.0.1:80/gitlab

不同之处在于:

SetEnv RAILS_RELATIVE_URL_ROOT "/gitlab"

PassengerPreStart http://127.0.0.1:80/gitlab

vim /opt/gitlab-6.6.5-0/apps/gitlab/gitlab-shell/config.yml

gitlab_url: "http://192.168.1.132:80/" 改成 http://pepstack.com/ 改成域名,和上面gitlab.yml中的

host保持一致

vim /opt/gitlab-6.6.5-0/apps/gitlabci/htdocs/config/database.yml 定义数据库的密码和用户名

production:

adapter: mysql2
encoding: utf8
reconnect: false
database: bitnami_gitlabci
pool: 5
username: bitnami
password: "1a36ddf4bb"
# host: localhost
socket: /opt/gitlab-6.6.5-0/mysql/tmp/mysql.sock
port: 3306
# socket: /tmp/mysql.sock

 

转载于:https://www.cnblogs.com/Neverstopfootsteps/p/8907458.html

你可能感兴趣的文章
关于Xshell无法连接centos6.4的问题
查看>>
css3动画——基本准则
查看>>
javaweb常识
查看>>
Java注解
查看>>
web自己主动保存表单
查看>>
一个小的日常实践——高速Fibonacci数算法
查看>>
机器学些技法(9)--Decision Tree
查看>>
drf权限组件
查看>>
输入月份和日期,得出是今年第几天
查看>>
Qt中子窗口全屏显示与退出全屏
查看>>
使用brew安装软件
查看>>
[BZOJ1083] [SCOI2005] 繁忙的都市 (kruskal)
查看>>
Centos6.4安装JDK
查看>>
201521123069 《Java程序设计》 第4周学习总结
查看>>
线性表的顺序存储——线性表的本质和操作
查看>>
【linux】重置fedora root密码
查看>>
pig自定义UDF
查看>>
输入名字显示其生日,没有则让输入生日,做记录
查看>>
Kubernetes 运维学习笔记
查看>>
并查集 经典 畅通工程
查看>>