highlight: a11y-dark
theme: juejin
101
查看gitlab服务状态 gitlab-ctl status run: alertmanager: (pid 1216) 1836s; run: log: (pid 1173) 1838s run: gitaly: (pid 1256) 1836s; run: log: (pid 1180) 1837s run: gitlab-monitor: (pid 1164) 1838s; run: log: (pid 1158) 1838s run: gitlab-workhorse: (pid 1196) 1837s; run: log: (pid 1159) 1838s run: logrotate: (pid 1195) 1837s; run: log: (pid 1156) 1838s run: nginx: (pid 1197) 1837s; run: log: (pid 1160) 1838s run: node-exporter: (pid 1214) 1836s; run: log: (pid 1171) 1838s run: postgres-exporter: (pid 1163) 1838s; run: log: (pid 1149) 1838s run: postgresql: (pid 1257) 1836s; run: log: (pid 1170) 1838s run: prometheus: (pid 1255) 1836s; run: log: (pid 1172) 1838s run: redis: (pid 1242) 1836s; run: log: (pid 1179) 1837s run: redis-exporter: (pid 1215) 1836s; run: log: (pid 1157) 1838s run: sidekiq: (pid 1177) 1837s; run: log: (pid 1162) 1838s run: unicorn: (pid 1243) 1836s; run: log: (pid 1174) 1838s
gitlab相关目录
- /etc/gitlab 配置文件目录
- /run/gitlab 运行pid目录
- /opt/gitlab 安装目录
- /var/opt/gitlab 数据目录
- /var/log/gitlab 日志目录
gitlab常用命令
查看文件占用空间 du -sh /*
列出当前gitlab有那些组件
gitlab-ctl service-list alertmanager* gitaly* gitlab-monitor* gitlab-workhorse* logrotate* nginx* node-exporter* postgres-exporter* postgresql* prometheus* redis* redis-exporter* sidekiq* unicorn*
重启gitlab所有服务 gitlab-ctl restart ok: run: alertmanager: (pid 6617) 1s ok: run: gitaly: (pid 6630) 1s ok: run: gitlab-monitor: (pid 6653) 0s ok: run: gitlab-workhorse: (pid 6669) 0s ok: run: logrotate: (pid 6680) 1s ok: run: nginx: (pid 6691) 0s ok: run: node-exporter: (pid 6774) 1s ok: run: postgres-exporter: (pid 6780) 0s ok: run: postgresql: (pid 6790) 1s ok: run: prometheus: (pid 6798) 0s ok: run: redis: (pid 6808) 0s ok: run: redis-exporter: (pid 6813) 1s ok: run: sidekiq: (pid 6822) 1s ok: run: unicorn: (pid 6834) 0s
也可以指定重启
某个服务 gitlab-ctl restart nginx ok: run: nginx: (pid 7044) 0s
指定停止
某个服务 gitlab-ctl stop nginx ok: down: nginx: 0s, normally up
指定启动
某个服务 gitlab-ctl start nginx ok: run: nginx: (pid 7221) 1s
gitlab-rails 用户启动控制台进行特殊操作,比如修改管理员密码、打开数据库控制台(gitlab-rails dbconsole)等。 ``` gitlab-rails dbconsole psql (9.6.11) Type "help" for help.
gitlabhqproduction=> \db List of tablespaces Name | Owner | Location ------------+-------------+---------- pgdefault | gitlab-psql | pg_global | gitlab-psql | (2 rows)
gitlabhq_production=> \quit gitlab-psql 数据库命令
gitlab-psql psql (9.6.11) Type "help" for help.
gitlabhqproduction=# \db List of tablespaces Name | Owner | Location ------------+-------------+---------- pgdefault | gitlab-psql | pg_global | gitlab-psql | (2 rows)
gitlabhq_production=# \quit `` 去掉Gitlab注册功能
不要设置错`
退出后在登录、发现注册功能没有了
gitlab-rake 数据备份等数据操作
gitlab克隆 ```
当前所在目录
pwd /opt
git clone http://192.168.37.101/linux01/web1.git Cloning into 'web1'... Username for 'http://192.168.37.101': zhangsan <--账号 Password for 'http://zhangsan@192.168.37.101': <--密码:1234.com remote: Enumerating objects: 14, done. remote: Counting objects: 100% (14/14), done. remote: Compressing objects: 100% (6/6), done. remote: Total 14 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (14/14), done. ``` 创建项目
修改网页信息 ``` vim web1/index.html
Linux01 web1 v1
``````
查看当前所在目录
pwd /opt/web1
添加文件
git add index.html
全景设置
git config --global user.email "1480765@qq.com" git config --global user.name "zhangsan"
备注
git commit -m "v1"
git push Username for 'http://192.168.37.101': zhangsan <--账号 Password for 'http://zhangsan@192.168.37.101': <--密码:1234.com Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 354 bytes | 354.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To http://192.168.37.101/linux01/web1.git eb692c8..596de4c master -> master ``` 查看文件是否发生变化
如果创建目录 ``` mkdir app vim app/index.html
Linux01 app
把本地所有文件提交一下
git add ./*
备注
git commit -m "v2"
提交
git push Username for 'http://192.168.37.101': zhangsan <--账号 Password for 'http://zhangsan@192.168.37.101': <--密码:1234.com Counting objects: 4, done. Delta compression using up to 2 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 421 bytes | 421.00 KiB/s, done. Total 4 (delta 0), reused 0 (delta 0) To http://192.168.37.101/linux01/web1.git 596de4c..53bb431 master -> master ```
列出用户全景设置 git config --global --list user.email=1480765@qq.com <-- user.name=zhangsan <--
修改配置文件 vim index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Linux01 项目1</title> </head> <body> <h1>Linux01 web1 v2</h1> </body> </html>
git add index.html
git commit -m "v3"
查看操作日志 ``` git log commit 513e72b2b90ebafb78219ae9ecbaba8ce2279cf4 (HEAD -> master) Author: zhangsan 1480765@qq.com Date: Sat Feb 11 21:51:11 2023 +0800
v3
commit 53bb4317581696b46d8b31e493a34b9213246591 (origin/master, origin/HEAD) Author: zhangsan 1480765@qq.com Date: Sat Feb 11 16:44:31 2023 +0800
v2
commit 596de4cc285ba04dc8f24df70a240b6448dcb76e Author: zhangsan 1480765@qq.com Date: Sat Feb 11 16:34:10 2023 +0800
v1
按'回车'下面还有(此处省略) 获取每次提交的ID,可以使用--hard根据提交的ID进行版本回滚
git reflog 513e72b (HEAD -> master) HEAD@{0}: commit: v3 53bb431 (origin/master, origin/HEAD) HEAD@{1}: commit: v2 596de4c HEAD@{2}: commit: v1 eb692c8 HEAD@{3}: clone: from http://192.168.37.101/linux01/web1.git ```
回滚 ``` cat index.html
Linux01 web1 v2
git 版本回滚,HEAD为当前版本,加一个^为上一个,^^为上上个版本
git reset --hard HEAD^ HEAD is now at 53bb431 v2 <--
回滚后变化
cat index.html
Linux01 web1 v1
<-- 也可以跨版本回滚
git reflog 513e72b (HEAD -> master) HEAD@{0}: commit: v3 53bb431 (origin/master, origin/HEAD) HEAD@{1}: commit: v2 596de4c HEAD@{2}: commit: v1 eb692c8 HEAD@{3}: clone: from http://192.168.37.101/linux01/web1.git
回滚到某次
git reset --hard eb692c8 HEAD is now at eb692c8 Update index.html
cat index.html
ABC123
123ABC
查看当前所处的分支
git branch * master ``` 创建新的分支
102
指定分支名称 ``` cd /opt
删除旧的
rm web1/ -rf
再次克隆
git clone -b develop http://192.168.37.101/linux01/web1.git Cloning into 'web1'... Username for 'http://192.168.37.101': zhangsan <--账号 Password for 'http://zhangsan@192.168.37.101': <--密码:1234.com remote: Enumerating objects: 21, done. remote: Counting objects: 100% (21/21), done. remote: Compressing objects: 100% (11/11), done. remote: Total 21 (delta 2), reused 0 (delta 0) Unpacking objects: 100% (21/21), done. 修改网页信息
cd web1/
vim index.html
Linux01 web1 v3
<--
git add ./* git commit -m "v4" ```
git push Username for 'http://192.168.37.101': zhangsan <-- Password for 'http://zhangsan@192.168.37.101': <--密码:1234.com
develop 信息发生改变
master 不变
切换分支 ``` git checkout develop Already on 'develop' Your branch is up to date with 'origin/develop'.
git checkout Your branch is up to date with 'origin/develop'. ```
``` git checkout master Branch 'master' set up to track remote branch 'master' from 'origin'. Switched to a new branch 'master'
git checkout Your branch is up to date with 'origin/master'. ```