设为首页 收藏本站
查看: 974|回复: 0

[经验分享] centos6.8安装 gitlab 9.3.5及使用

[复制链接]

尚未签到

发表于 2018-4-20 10:35:28 | 显示全部楼层 |阅读模式
  centos6.8安装  gitlab 9.3.5及使用
  环境准备:

[root@caosm03 conf]# cat /etc/issue
CentOS release 6.8 (Final)
Kernel \r on an \m
注意:这个需要配置好主机名不然安装的时候会出现地址错误
[root@caosm03 caosm]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.24.130 caosm03.com
  1.安装配置依赖项

[root@caosm03 ~]#yum install curl openssh-server openssh-clients postfix cronie  -y
[root@caosm03 ~]#service postfix start  #GitLab使用postfix发送邮件  
[root@caosm03 ~]#chkconfig postfix on   #设置postfix开机自启动  
[root@caosm03 ~]#lokkit -s http -s ssh  #配置iptables开放http和ssh端口,这里需要注意,腾讯云安全组选择那里要选择开放所有端口  
#这一步可能会显示failed ip6tables start,这个不需要管,直接运行下面查看是否打开端口就可以了  
  输入命令查看是否打开http和ssh端口
[root@caosm03 ~]# iptables -L

  Chain INPUT (policy ACCEPT)
  target     prot opt source               destination
  ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
  ACCEPT     icmp --  anywhere             anywhere
  ACCEPT     all  --  anywhere             anywhere
  ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
  ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http
  REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
  Chain FORWARD (policy ACCEPT)
  target     prot opt source               destination
  REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
  Chain OUTPUT (policy ACCEPT)
  target     prot opt source               destination
  2.下载RPM包,并上传到服务器 (我这里是选择的下载rpm包,也有其他的方式,就是下载他的安装脚本或者镜像等方式,如果不想用rpm安装,可以自行搜索其它方式,官网也都有说明)
  国内镜像下载地址: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/ (Centos 6.8 64位)
  打开后可以看到各个版本的rpm包,我是选择的 9.3.5版本,点击相应rpm包进行下载

复制下载地址链接
[root@caosm03 ~]#wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-9.3.5-ce.0.el6.x86_64.rpm
[root@caosm03 ~]#rpm -ivh  gitlab-ce-9.3.5-ce.0.el6.x86_64.rpm
[root@caosm03 ~]#gitlab-ctl reconfigure
  3.启动gitlab

[root@caosm03 ~]#gitlab-ctl reconfigure
  4.使用浏览器访问GitLab (这里访问你的服务器IP地址:80端口)
  首次访问GitLab,系统会让你重新设置管理员的密码,设置成功后会返回登录界面。
  默认的管理员账号是root,如果你想更改默认管理员账号,请输入上面设置的新密码登录系统后修改帐号名。

.上面的步骤执行完后应该就是可以使用了,可是因为我的服务器只有1G内存,所以浏览器访问的时候,时不时的会报502错误,这里我们需要增加服务器虚拟内存可以解决。 (对于502错误,也有可能是服务器端口占用的原因,不过我的服务器没有安装其他东西,所以不会出现端口占用的情况)
502
GitLab is not responding.
Please contact your GitLab administrator if this problem persists.
  5.增加服务器内存

我这里使用的事虚拟机 给虚拟机直接添加内存
另外一种方式增加swap分区
dd if=/dev/zero of=/var/swap bs=1024 count=2048000 #增加2G左右SWAP  
mkswap /var/swap #设置交换文件  
swapon /var/swap #激活启用交换分区
echo "/var/swap swap swap defaults 0 0"  >> /etc/fstab
  6.说明

缺点:这种方式虽然说简单方便,但是定制型很差,默认只能使用postgre和nginx
主配置文件:/etc/gitlab/gitlab.rb   //可以自定义一些邮件服务等
日志地址:/var/log/gitlab/    // 对应各服务
服务地址:/var/opt/gitlab/   // 对应各服务的主目录
仓库地址:/var/opt/gitlab/git-data //记录项目仓库等提交信息
重置配置:gitlab-ctl reconfigure    //不要乱用,会重置为最原始的配置的
重启服务:gitlab-ctl  stop/start/restart  //启动命令
默认安装:postgres、nginx、redis、unicorn ......
  gitlab客户端配置及基本使用
  1.客户端默认安装即可。
  2.创建密钥

$ ssh-keygen  -t rsa -C caoshouming@kanfanews.com
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/PM/.ssh/id_rsa):
/c/Users/PM/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/PM/.ssh/id_rsa.
Your public key has been saved in /c/Users/PM/.ssh/id_rsa.pub.
  3.拷贝密钥到gitlab 上面。
  打开路径拷贝id_rsa.pub

[root@caosm03 ~]# cat  ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApA9i1/CL6qcN3T+9jRH5BTgss7nlv3f7hj7n57N8a5M6EngZ0tfyTlpmiQdA6ghWv4jLKTar64TiIf2+CenTSt0qNu485zQ5TpP4vUuuZ5hrD31V+DWg5+ls9v9SF0hABzQPVbCkxjV6kbCY7sCpw/pM85bemw5CvuCL9gdZIkkF7h08qPOWvIbljxxExgs5eS22Ys4ZxANlSYzsHstp6jxq296PSzoloLgW+x5OlR5rHvgowuRuv3sQn3sCaEEvt0EYVUdBwEbOivAJkZjFNORl2EX+u7uIjU4r9Sg5vqSEOM6GWVRDjFIzt4/46fGhJAzScKeuHkEobA/yrNVoNQ== caoshouming@kanfanews.com
  4.配置服务端密钥
  登陆自己的用户,设置ssh密钥。密钥里面复制,标题写好自己标识。增加密钥即可。
  5.客户端进行下载测试
  创建测试目录 在git 客户端里面切换到目录里面

$ cd e:
PM@kanfa-caosm MINGW64 /e
$cd www
$ git clone git@gitlab.kanfanews.com:php/doc.git
Cloning into 'doc'...
remote: Counting objects: 1535, done.
remote: Compressing objects: 100% (429/429), done.
remote: Total 1535 (delta 365), reused 728 (delta 326)
Receiving objects: 100% (1535/1535), 1.96 MiB | 3.94 MiB/s, done.
Resolving deltas: 100% (787/787), done.
**注意: git 下载的路径可以从web 上面进行查询 下载整个项目,自己的账户需要有管理员的权限才能下载,否则下载失败提示没有权限**
  6.维护命令

查看状态
sudo gitlab-ctl status
/# 启动Gitlab所有组件
sudo gitlab-ctl start
/# 停止Gitlab所有组件
sudo gitlab-ctl stop
/# 重启Gitlab所有组件
sudo gitlab-ctl restart
  7.gitlab 数据备份和恢复

配置文件再/etc/gitlab/ 下面,将所有的配置用tar备份即可
[root@caosm03 init.d]# cd /etc/gitlab/
[root@localhost gitlab]# ls
gitlab.rb  gitlab-secrets.json  trusted-certs
  备份data (以包安装的方式)

[root@localhost ~]# sudo gitlab-rake gitlab:backup:create
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... [DONE]
done
Dumping repositories ..
备份目录在:
[root@caosm03 backups]# pwd
/var/opt/gitlab/backups
[root@caosm03 backups]# ls
1512644923_2017_12_07_9.3.5_gitlab_backup.tar # 这个是备份出来的文件
  恢复数据 (针对以包安装的方式)

[root@caosm03 ~]# sudo gitlab-ctl stop unicorn
[root@caosm03 ~]# sudo gitlab-ctl stop sidekiq
[root@caosm03 ~]# sudo gitlab-ctl status
[root@caosm03 ~]# sudo gitlab-rake gitlab:backup:restore 1512644923_2017_12_07
注意:这里的默认恢复指定的文件名称是1512644923_2017_12_07_9.3.5_gitlab_backup.tar
和默认格式不一致:这里需要对文件进行重命名不然恢复不成功!!!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-449530-1-1.html 上篇帖子: CentOS6.x安装event扩展 下篇帖子: CentOS7下搭建Kubernetes集群
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表