首页 > 系统相关 >ubuntu安装gitlab并配置

ubuntu安装gitlab并配置

时间:2022-11-28 15:57:21浏览次数:72  
标签:git zhang -- 安装 gitlab devops ubuntu root

ubuntu系统版本信息

root@zhang-virtual-machine:~# lsb_release -a
No LSB modules are available.
Distributor ID:Ubuntu
Description:Ubuntu 18.04.6 LTS
Release:18.04
Codename:bionic

gitlab下载链接
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/bionic/main/g/gitlab-ce/
安装gitlab

root@zhang-virtual-machine:~# ls
gitlab-ce_11.11.8-ce.0_amd64.deb  snap
root@zhang-virtual-machine:~#
root@zhang-virtual-machine:~# dpkg -i gitlab-ce_11.11.8-ce.0_amd64.deb
正在选中未选择的软件包 gitlab-ce。
(正在读取数据库 ... 系统当前共安装有 131998 个文件和目录。)
正准备解包 gitlab-ce_11.11.8-ce.0_amd64.deb  ...
正在解包 gitlab-ce (11.11.8-ce.0) ...
正在设置 gitlab-ce (11.11.8-ce.0) ...

gitlab: GitLab now ships with a newer version of PostgreSQL (10.7), but it is not yet
gitlab: enabled by default. To upgrade, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl pg-upgrade

gitlab: Note: This command does not support Geo instances yet. So we don't
gitlab: recommend running this command on Geo nodes. It will be supported
gitlab: in GitLab 12.0.

gitlab: For more details, please see:
gitlab: https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server
gitlab:
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

修改gitlab配置

root@zhang-virtual-machine:~#vim /etc/gitlab/gitlab.rb
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
#external_url 'http://gitlab.example.com'
external_url 'http://192.168.160.128' #修改为机器IP

##邮件通知
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "你的QQ号@qq.com"
gitlab_rails['smtp_password'] = "QQ邮箱授权码"
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'] = "你的QQ号@qq.com"

配置组件

root@zhang-virtual-machine:~#gitlab-ctl reconfigure
查看服务状态
root@zhang-virtual-machine:~# gitlab-ctl status
run: alertmanager: (pid 38975) 14s; run: log: (pid 38522) 37s
run: gitaly: (pid 38752) 17s; run: log: (pid 37072) 132s
run: gitlab-monitor: (pid 38830) 16s; run: log: (pid 38246) 53s
run: gitlab-workhorse: (pid 38791) 17s; run: log: (pid 37909) 74s
run: logrotate: (pid 37991) 68s; run: log: (pid 38061) 65s
run: nginx: (pid 37906) 74s; run: log: (pid 37949) 73s
run: node-exporter: (pid 38817) 17s; run: log: (pid 38112) 61s
run: postgres-exporter: (pid 38994) 14s; run: log: (pid 38611) 31s
run: postgresql: (pid 37124) 129s; run: log: (pid 37165) 126s
run: prometheus: (pid 38937) 15s; run: log: (pid 38433) 41s
run: redis: (pid 36800) 141s; run: log: (pid 36836) 138s
run: redis-exporter: (pid 38841) 16s; run: log: (pid 38353) 47s
run: sidekiq: (pid 37797) 81s; run: log: (pid 37826) 80s
run: unicorn: (pid 37701) 87s; run: log: (pid 37780) 84s

访问gitlab

第一次登录需要更改密码,需要8位数

修改完成后进入登录界面

账号:root 密码:新设置的密码

登录之后全新的gitlab没有项目

点击扳手标志

groups:项目

project:服务

users:用户

创建用户

点击new user

创建完成


邮箱收到邮箱信息

点击click here to set your password去修改密码

后台修改密码

点击users----选择用户-----选择edit

关闭注册功能

root用户登录--点击左侧--最下面setting----sing up restrictions--取消掉sign-up enabled--然后保存

刷新页面后没有注册选项

创建groups

为用户添加组

登录zhangsan用户

创建项目-点击project---you project --选择组work--在work组中创建项目devops--点击创建

创建完成后可以在本地上传文件等

gitlab常用命令

gitlab-ctl start         #启动
gitlab-ctl status       #查看状态
gitlab-ctl restart      #重启
gitlab-ctl stop         #停止
gitlab-ctl tail nginx  #查看日志
设置全局用户和邮箱
root@zhang-virtual-machine:~/devops# git config --global user.name "user1"
root@zhang-virtual-machine:~/devops# git config --global user.email "[email protected]"
克隆项目
git clone http://192.168.160.128/work/devops.git
案例:
root@zhang-virtual-machine:~# git clone http://192.168.160.128/work/devops.git
正克隆到 'devops'...
Username for 'http://192.168.160.128': zhangsan
Password for 'http://[email protected]':
warning: 您似乎克隆了一个空仓库。
root@zhang-virtual-machine:~# ls
devops gitlab-ce_11.11.8-ce.0_amd64.deb snap

root@zhang-virtual-machine:~#添加 (./当前目录下代表全部)
root@zhang-virtual-machine:~/devops# git add ./
提交
root@zhang-virtual-machine:~/devops# git commit -m "v1"
推送到仓库
git push
更新代码到本地
git pull
案例:
root@zhang-virtual-machine:~/devops# ls
passwd  shadow
root@zhang-virtual-machine:~/devops# git add ./
root@zhang-virtual-machine:~/devops# git commit -m "v2"
[master 59f1543] v2
 1 file changed, 47 insertions(+)
 create mode 100644 shadow
root@zhang-virtual-machine:~/devops# git push
Username for 'http://192.168.160.128': zhangsan
Password for 'http://[email protected]':
对象计数中: 3, 完成.
Delta compression using up to 2 threads.
压缩对象中: 100% (3/3), 完成.
写入对象中: 100% (3/3), 752 bytes | 752.00 KiB/s, 完成.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.160.128/work/devops.git
   d3f873c..59f1543  master -> master
root@zhang-virtual-machine:~/devops

#查看本地工作区和暂存区的状态
git status
查看操作日志
git log 
#设置文件不上传到gitlab
vim .gitignore (把文件名称写入或者路径都可以)
版本回滚 head为当前版本,加一个^为上一版本,^^为上上一个版本
git reset --hard HEAD^^ 
获取每次提交的id, --hare 根据提交的id进行版本回滚
git reflog
回退到指定id的版本
git reset --hard 5ae4b06
查看当前分支
git branch
创建并切换到一个新到分支
git checkout -b devlop
切换分支
git checkout develop

分支合并
创建一个分支在mstaer下(develop)
在机器上将仓库克隆下来,修改代码然后提交
git clone -b develop http://192.168.160.128/work/devops.git
修改代码
git add ./
git commit -m "v9"
git push
合并代码
在原来机器上执行git pull 同步仓库
root@zhang-virtual-machine:~/devops# git pull
Username for 'http://192.168.160.128': zhangsan
Password for 'http://[email protected]':
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 2 (delta 0)
展开对象中: 100% (3/3), 完成.
来自 http://192.168.160.128/work/devops
 * [新分支]          develop    -> origin/develop
已经是最新的。

原仓库(devops)
root@zhang-virtual-machine:~/devops# ls -lh
总用量 16K
-rw-r--r-- 1 root root  307 11月 13 11:19 group
-rw-r--r-- 1 root root    0 11月 13 11:19 nas
-rw-r--r-- 1 root root 2.7K 11月 10 17:35 passwd
-rw-r----- 1 root root 1.5K 11月 10 17:38 shadow
-rw-r--r-- 1 root root   25 11月 10 18:45 test
新仓库(develop)
[root@localhost devops]# ls -l
insgesamt 16
-rw------- 1 root root 2242 13. Nov 14:56 anaconda-ks.cfg
-rw-r--r-- 1 root root  307 13. Nov 14:55 group
-rw-r--r-- 1 root root    0 13. Nov 14:55 nas
-rw-r--r-- 1 root root 2723 13. Nov 14:55 passwd
-rw-r--r-- 1 root root 1522 13. Nov 14:55 shadow
合并
root@zhang-virtual-machine:~/devops# git merge origin/develop
更新 86f35a0..65d30d1
Fast-forward
 anaconda-ks.cfg | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 anaconda-ks.cfg
 合并之后的仓库内容
 root@zhang-virtual-machine:~/devops# ls -lh
总用量 20K
-rw-r--r-- 1 root root 2.2K 11月 13 15:05 anaconda-ks.cfg
-rw-r--r-- 1 root root  307 11月 13 11:19 group
-rw-r--r-- 1 root root    0 11月 13 11:19 nas
-rw-r--r-- 1 root root 2.7K 11月 10 17:35 passwd
-rw-r----- 1 root root 1.5K 11月 10 17:38 shadow
-rw-r--r-- 1 root root   25 11月 10 18:45 test
root@zhang-virtual-machine:~/devops#
本地合并完成同步到仓库
root@zhang-virtual-machine:~/devops# git push
Username for 'http://192.168.160.128': zhangsan
Password for 'http://[email protected]':
Total 0 (delta 0), reused 0 (delta 0)
To http://192.168.160.128/work/devops.git
   86f35a0..65d30d1  master -> master
root@zhang-virtual-machine:~/devops#
root@zhang-virtual-machine:~/devops# git reset --hard HEAD^
HEAD 现在位于 bab9179 v7
root@zhang-virtual-machine:~/devops# git reset --hard HEAD^
HEAD 现在位于 d36c9fb v6
root@zhang-virtual-machine:~/devops# ls
group  passwd  shadow  test

root@zhang-virtual-machine:~/devops# git reflog
86f35a0 (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: pull: Fast-forward
d36c9fb HEAD@{1}: reset: moving to HEAD^
bab9179 HEAD@{2}: reset: moving to HEAD^
86f35a0 (HEAD -> master, origin/master, origin/HEAD) HEAD@{3}: commit: v8
bab9179 HEAD@{4}: commit: v7
d36c9fb HEAD@{5}: commit: v6
5fd05ec HEAD@{6}: commit: v5
af65000 HEAD@{7}: commit: v4
56a1ec7 HEAD@{8}: commit: v3
59f1543 HEAD@{9}: commit: v2
d3f873c HEAD@{10}: clone: from http://192.168.160.128/work/devops.git

root@zhang-virtual-machine:~/devops# git reset --hard af65000
HEAD 现在位于 af65000 v4
root@zhang-virtual-machine:~/devops#

标签:git,zhang,--,安装,gitlab,devops,ubuntu,root
From: https://www.cnblogs.com/xiaozhang1995/p/16932395.html

相关文章

  • windows 安装Tomcat
    Windows:1.安装tomcat,建议8.0,进入官网https://tomcat.apache.org/download-80.cgi,找到左侧中的Download找到对应版本的tomcat,上传到百度网盘的8.5.31版本。链接:https:......
  • centos安装python以及配置完整流程
    1.centos安装python环境及服务postgresql112.Centos安装Redis3.安装nginx4.ubuntu18.04(centos)安装多版本python及管理5.Linux安装uwsgi6.python安装虚拟环境virtua......
  • CentOS下php安装mcrypt扩展
    参考文章安装可能出现的问题......
  • kooder安装及本地搜索git仓库代码
    kooder安装及本地搜索git仓库代码需求背景:如果需要从Git代码仓库查询某个配置项做批量的更新替换,如果一个一个找不合适且容易遗漏,需要借助第三方工具来模糊查询来实现。1......
  • WSS V3下载和安装图解
    WindowsSharePointServicesV3Beta2x86English​​http://download.microsoft.com/download/a/7/7/a7780e67-f21a-4265-a445-8ef1f19d223f/SharePoint_setup.exe​​Win......
  • mysql,在win10上绿色安装5.7版本
    1.下载地址,选择5.7的zip包https://downloads.mysql.com/archives/community/2.解压到自定义路径下我这里选择的路径D:\mysql手动创建了文件my.inimy.ini内容点击查......
  • 安装 IronPython
    2006年9月8号IronPython1.0发布了IronPython是Python编程语言在.NET平台上的实现。它支持一个可交互的控制台,该控制台支持完全的动态编译,并且可以让Py......
  • 解决域用户安装软件权限问题
    ......
  • 安装SCCM前的准备(一)
    软件更新点(SUP)和分发点(DP)一、创建系统管理容器在SYSTEM容器创建SystemManagement系统管理容器首先,我们将创建“系统管理”容器,并为其分配SCCM服务器的......
  • 安装SCCM2203主站点(二)
    1、下载地址:https://www.microsoft.com/zh-cn/evalcenter/download-microsoft-endpoint-configuration-manager  2、打开SCCM2203安装包3、现在单击安装。......