hb120973135 发表于 2018-1-11 11:30:36

gitlab的安装和基本维护

基本介绍
  GitLab是一个自托管的Git项目仓库,可以自己搭建个人代码管理的仓库,功能与github类似。

安装
  操作系统:CentOS6.5

gitlab官网下载安装地址:https://about.gitlab.com/downloads/#centos6
  1.安装依赖的包
  

yum install curl openssh-server openssh-clients postfix cronie  
service postfix start
  
chkconfig postfix on
  
lokkit
-s http -s ssh  


2.使用gitlab官网的脚本安装
  

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


或者使用gitlab的rpm安装gitlab
  

curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/6/gitlab-ce-XXX.rpm/download  
rpm -i gitlab-ce-XXX.rpm
  

  如果一切顺利,gitlab将安装完成!
  3.这里我先修改下配置文件(将访问地址改为主机的ip地址),默认为主机名访问(http://hostname 默认的访问地址)
  修改结果如下:
  

# grep -n "^" /etc/gitlab/gitlab.rb  

  

11:external_url 'http://10.10.100.38'  

  4.配置并启动gitlab
  

gitlab-ctl reconfigure  


5.安装完毕后,使用Web登录
  打开浏览器输入http://10.10.100.38   #10.10.100.38为我的gitlab主机ip地址.
  第一次登录要求设置root密码
  登录成功之后,是这样的
https://images2015.cnblogs.com/blog/830887/201702/830887-20170206172308791-2005663778.png
  至此,gitlab的安装访问正常...

安装完gitlab后的运维操作:

初次配置服务
  

sudo gitlab-ctl reconfigure  


启动服务
  

sudo gitlab-ctl start  

  


停止服务
  

sudo gitlab-ctl stop  

  


重启服务
  

sudo gitlab-ctl restart  

  


检查服务状态
  

sudo gitlab-ctl status  

  一般服务状态显示信息
  显示格式:
  状态 : 进程名称:(进程ID)运行时间(秒);进程的日志服务进程和运行时间
  

# gitlab-ctl status  
run: gitlab-workhorse: (pid 14584) 3325s; down: log: 0s, normally up, want up
  
run: logrotate: (pid 14593) 3324s; run: log: (pid 31243) 612s
  
run: nginx: (pid 14602) 3323s; down: log: 0s, normally up, want up
  
run: postgresql: (pid 11749) 3741s, want down; down: log: 3721s, normally up, want up
  
run: redis: (pid 14613) 3322s; down: log: 0s, normally up, want up
  
run: sidekiq: (pid 8677) 4118s, got TERM; down: log: 0s, normally up, want up
  
run: unicorn: (pid 14619) 3322s; run: log: (pid 7844) 4153s
  

  


状态
说明
run
运行状态
down
服务停止


检查服务的日志信息
  

# 检查redis的日志  
sudo gitlab-ctl tail redis
  

  
# 检查postgresql的日志
  
sudo gitlab-ctl tail postgresql
  
# 检查gitlab-workhorse的日志
  
sudo gitlab-ctl tail gitlab-workhorse
  
# 检查logrotate的日志
  
sudo gitlab-ctl tail logrotate
  
# 检查nginx的日志
  
sudo gitlab-ctl tail nginx
  
# 检查sidekiq的日志
  
sudo gitlab-ctl tail sidekiq
  
# 检查unicorn的日志
  
sudo gitlab-ctl tail unicorn
  

  


gitlab管理员密码忘记,怎么重置密码
  Gitlab 修改root用户密码
  使用rails工具打开终端
  

sudo gitlab-rails console production  

  

  查询用户的email,用户名,密码等信息,id:1 表示root账号
  

user = User.where(id: 1).first  

  

  重新设置密码
  

user.password = '新密码'  
user.password_confirmation = '新密码' 
  

  

  保存密码
  

user.save!  

  

  完整的操作ruby脚本
  

user = User.where(id: 1).first  
user.password = '新密码'
  
user.password_confirmation = '新密码'
  
user.save!
  

  

  然后使用重置过的密码重新登录。
  Git 图形界面操作工具


[*]SourceTree https://www.sourcetreeapp.com/
[*]TortoiseGit https://code.google.com/p/tortoisegit/wiki/Download?tm=2 
  参考文档:
  http://www.cnblogs.com/stevendes/p/6218928.html 
  http://www.cnblogs.com/yangliheng/p/5760185.html 
  https://about.gitlab.com/downloads/#centos6
  http://www.tuicool.com/articles/mEbAZbE
页: [1]
查看完整版本: gitlab的安装和基本维护