GitLab安装部署管理笔记
参考
1、安装部署html
参考
https://blog.csdn.net/qq_37143673/article/details/85044258node
http://www.javashuo.com/article/p-qmkjiqgj-t.htmlpython
https://www.cnblogs.com/wangrongwen/p/13709196.htmllinux
1、安装部署
1. 最小系统:centos7 x64,cpu4,4g,10gb
环境要求:https://docs.gitlab.com/ce/install/requirements.html 【社区版】nginx
2. 依赖包安装c++
# 安装经常使用工具 yum install vim gcc gcc-c++ wget net-tools lrzsz iotop lsof iotop bash-completion -y # 安装网络及发送邮件工具 yum install curl wget policycoreutils openssh-server openssh-clients postfix -y # 更换yum源为阿里云 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 刷新仓库 yum clean all && yum makecache # 配置epel仓库 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo # 关闭防火墙 systemctl disable firewalld # 关闭selinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config && sync && reboot # 修改主机hostname hostnamectl set-hostname gitlab.example.com # 设置postfix开机启动及重启,gitlab默认以postfix发送邮件 systemctl enable postfix && systemctl restart postfix # 重启主机 reboot
1. 开发语言:主ruby,部分go 2. 版本:CE社区办,EE企业版 3. Linux 4. Git代码管理【拥有wiki和issue跟踪功能】 5. Node.js 6. Redis 7. PostgreSQL 8. nginx 9. Unicorn 是一个为运行 Rack 应用的HTTP服务器
/etc/gitlab # 配置文件目录 /run/gitlab # 运行pid目录 /opt/gitlab # 安装目录 /var/opt/gitlab # 数据目录 /var/log/gitlab # 日志目录
gitlab-rails # 用于启动控制台进行特殊操做,如修改管理员密码,打开数据库控制台(gitlab-rails debconsole)等 gitlab-psql # 数据库命令行 gitlab-rake # 数据备份恢复等数据操做 gitlab-ctl # 客户端命令行操做行 gitlab-ctl stop/start/restar/status/ # 操做gitlab及查看组件运行状态 gitlab-ctl tail nginx # 查看某个组件的日志
4. 下载gitlab及安装git
#centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 #centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 # 选择本身合适的版本 wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.8.9-ce.0.el7.x86_64.rpm && rpm -i gitlab-ce-11.8.9-ce.0.el7.x86_64.rpm
5. 修改gitlab访问地址配置sql
vim /etc/gitlab/gitlab.rb # 修改此行 external_url 'http://localhost' # 变动为,服务器ip及自定义的端口号,默认8080 external_url 'http://192.168.0.152:8888' # 保存退出,并将gitlab配置刷新及重启 gitlab-ctl reconfigure && gitlab-ctl restart
6. 输入配置的地址访问gitlab,第一次须要重设密码,用户名为root数据库
# 常见问题解决 -出现502界面,查看组件状态 `gitlab-ctl status` 1. 端口被占,修改gitlab.rb中的配置便可,通常是gitlab端口被占或者Unicorn端口被占 external_url 'http://192.168.0.152:8888' 或者 unicorn['port'] = 9090
2、gitlab的配置与管理
1.配置发信功能即注册等其余事件,经过邮件通知vim
# 默认postfix发信,也能够用stmp发,默认stmp是开启的,二者只能开启一个,否则报错 # 官网参考 https://doc.gitlab.cc/omnibus/settings/smtp.html vim /etc/gitlab/gitlab.rb ### Email Settings # 方式一使用stmp,前提须要到对应的邮箱上配置开发第三方访问,如qq,163 gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "414534337@qq.com" gitlab_rails['smtp_password'] = "iotgzskuiqbtcbch" gitlab_rails['smtp_domain'] = "smtp.qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = '414534337@qq.com' # 保存重启 gitlab-ctl reconfigure && gitlab-ctl restart # 方式二使用postfix,关闭stmp,具体配置待研究 gitlab_rails['smtp_enable'] = true 改成 false
2.取消gitlab注册功能
3. 建立项目
能够直接建立项目,而后为项目添加成员
也能够建立组,而后向组里添加成员,而后将项目添加到组里,那么组成员就均可以根据本身的角色操做该项目文件了
4. 将某个用户添加到建立的组里,一个组能够有多个项目,能够配置每一个项目的成员等等
5. 将经过管理员建立的项目添加到组里,那么组成员就能够看到该项目了
6. git客户端克隆项目到本地
各成员通常都是经过git拉取代码的,能够直接经过http的方式,这种须要输入用户名和密码
也能够在本地ssh生成密钥,上传到gitlab用户配置里,那么拉取代码就不须要输入帐户信息了
7. 本地操做完提交到仓库
# 进入项目目录 [root@python-node01 gitlab-project-dir]# cd testproject01/ # 添加一个测试文件 [root@python-node01 testproject01]# echo "just test push something to gitlab" > first-test.txt # 将在本地工做区的修改提交到到缓存区 [root@python-node01 testproject01]# git add . # 将修改从缓存区提交到本地仓库 [root@python-node01 testproject01]# git commit -m "push init code" # 报以下错误,须要提交配置全局的用户email和用户名 *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got 'root@python-node01.(none)') # 配置邮箱和用户名 [root@python-node01 testproject01]# git config --global user.email 111112@qq.com [root@python-node01 testproject01]# git config --global user.name test01 [root@python-node01 testproject01]# cat ~/.gitconfig [user] email = 111112@qq.com name = test01 # 再次commit就ok了 [root@python-node01 testproject01]# git commit -m "push init code" [master 48a1e0a] push init code 1 file changed, 1 insertion(+) create mode 100644 first-test.txt # 注意!!若是你是开发者身份,默认是不容许直接推送代码到master分支的 [root@python-node01 testproject01]# git push
备注
关于gitlab用户角色的介绍参考:https://www.cnblogs.com/sunxiuwen/p/11155348.html