两个gitlab用户和一个github用户,同一个gitlab系统中的不同用户邮箱地址是不一样的
ID | 平台 | username | ssh密钥 passphrase | |
---|---|---|---|---|
1 | gitlab | user1 | password1 | user1@163.com |
2 | gitlab | user2 | password2 | user2@163.com |
3 | github | user3 | password3 | user3@163.com |
使用下面命令创建gitlab平台用户user1的密钥
ssh-keygen -t rsa -C "gitlabuser1@163.com" -b 4096
详细过程
lyj91@DESKTOP-4SS3LVE MINGW64 ~
$ ssh-keygen -t rsa -C "gitlabuser1@163.com" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/lyj91/.ssh/id_rsa): /c/Users/lyj91/.ssh/id_rsa_gitlabuser1
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/lyj91/.ssh/id_rsa_gitlabuser1.
Your public key has been saved in /c/Users/lyj91/.ssh/id_rsa_gitlabuser1.pub.
The key fingerprint is:
SHA256:25kdjm9vb9CiYVlPuscvZE4gFq1mfi0vFRyvORjCppQ lyj9172@163.com
The key's randomart image is:
+---[RSA 4096]----+
| . |
| . . . |
| o o . o |
| E X o + o|
| .SB o.B O |
| .o.*B.& o|
| . =oo@ * |
| .+ * +|
| ..++=+|
+----[SHA256]-----+
使用上面同样的方法生成三套ssh密钥
ID | username | ssh私钥 | ssh公钥 |
---|---|---|---|
1 | user1 | /c/Users/lyj91/.ssh/id_rsa_gitlabuser1 | /c/Users/lyj91/.ssh/id_rsa_gitlabuser1.pub |
2 | user2 | /c/Users/lyj91/.ssh/id_rsa_gitlabuser2 | /c/Users/lyj91/.ssh/id_rsa_gitlabuser2.pub |
3 | user3 | /c/Users/lyj91/.ssh/id_rsa_githubuser3 | /c/Users/lyj91/.ssh/id_rsa_githubuser3.pub |
使用下面命令复制公钥内容到复制面板
cat ~/.ssh/id_rsa_gitlabuser1.pub | clip
使用下面命令复制公钥内容到粘贴到gitlab或github的SSH Keys
在本地~/.ssh 目录下创建config文件,该文件用于配置私钥对应的服务器
Host 10.10.10.10 #ssh匹配项自定义名,一般配置gitlab的IP或者域名,如果是同一个gitlab有多个用户要配置时,可以在再加上用户名做标识
HostName 10.10.10.10 #必须配置gitlab的IP或者域名
IdentityFile ~/.ssh/id_rsa_gitlabuser1
PreferredAuthentications publickey
User user1
Host 10.10.10.10.user2 #避免与第一个冲突,配置配置gitlab的IP加.用户名
HostName 10.10.10.10
IdentityFile ~/.ssh/id_rsa_gitlabuser2
PreferredAuthentications publickey
User user2
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_githubuser3
PreferredAuthentications publickey
User user3
从平台获取项目的ssh链接如下
git@10.10.10.10.10:MMtools/perf_collectdata.git
@与:之间的IP或域名使用config文件中的Host参数值替换 比如使用user1来clone的项目,使用如下git命令
git clone git@10.10.10.10.10:MMtools/perf_collectdata.git
使用user2来clone的项目,使用如下git命令
git clone git@10.10.10.10.10.user2:MMtools/perf_collectdata.git
gitlab和github在统计提交的时候,会判断邮箱是否跟github的登陆邮箱匹配,不匹配则不计算活跃度,即不生成小绿块。
需要配置正确的user.name/usere.mail
git config user.name user1
git config user.email user1@163.com
git config --global user.name user1
git config --global user.email user1@163.com
git config user.name user1
git config user.email user1@163.com
现在可以做git push了
lsb_release -a
ifconfig
或
ip a
systemd-resolve --status
Ubuntu Server 18.04 采用netplan作为网络配置管理,配置文件/etc/netplan/50-cloud-init.yaml,使用命令netplan apply使配置生效
root@gitser:/etc/netplan# vi /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens33:
addresses:
- 192.168.3.184/24
dhcp4: false
gateway4: 192.168.3.1
nameservers:
addresses:
- 192.168.3.1
search: []
version: 2
如果对一个网卡配置多个IP可以如下
network:
ethernets:
ens33:
addresses:
- 192.168.3.184/24
- 192.168.3.183/24
dhcp4: false
gateway4: 192.168.3.1
nameservers:
addresses:
- 192.168.3.1
search: []
version: 2
ens33:网卡名 addresses:为配置静态IP
ens33:
addresses:
- 192.168.3.184/24
gateway4:为IPv4的网关
gateway4: 192.168.3.1
其中nameserverss配置为DNS
nameservers:
addresses:
- 192.168.3.1
search: []
使用新方法,您必须使用netplan重新启动网络。因此,一旦配置好了接口,就使用以下命令:
netplan apply
上述命令将重新启动网络并应用新的配置。如果网络无法正常工作,您可以输入以下命令:
netplan --debug apply
以上操作均在root用户下进行,如在普通用户,请自行加上sudo。
这里有几点需要注意:
上传deb软件包到服务器上,使用dpkg -i XXX.deb安装软件包,如
root@gitser:~/lyjtmp# dpkg -i lrzsz_0.12.21-8build1_amd64.deb
Selecting previously unselected package lrzsz.
(Reading database ... 66574 files and directories currently installed.)
Preparing to unpack lrzsz_0.12.21-8build1_amd64.deb ...
Unpacking lrzsz (0.12.21-8build1) ...
Setting up lrzsz (0.12.21-8build1) ...
Processing triggers for man-db (2.8.3-2) ...
root@gitser:~/lyjtmp#
1.使用命令dpkg安装
root@gitser:~/gitpkg# dpkg -i gitlab-ce_11.1.4-ce.0_amd64.deb
Selecting previously unselected package gitlab-ce.
(Reading database ... 66595 files and directories currently installed.)
Preparing to unpack gitlab-ce_11.1.4-ce.0_amd64.deb ...
Unpacking gitlab-ce (11.1.4-ce.0) ...
Setting up gitlab-ce (11.1.4-ce.0) ...
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
root@gitser:~/gitpkg#
2.初始配置
root@gitser:~/gitpkg# gitlab-ctl reconfigure
执行结束时有类似如下结果
Running handlers:
Running handlers complete
Chef Client finished, 430/611 resources updated in 03 minutes 25 seconds
gitlab Reconfigured!
3.检查GitLab运行状态
root@gitser:~/gitpkg# gitlab-ctl status
run: alertmanager: (pid 13611) 125s; run: log: (pid 13643) 124s
run: gitaly: (pid 13540) 127s; run: log: (pid 13552) 127s
run: gitlab-monitor: (pid 13559) 127s; run: log: (pid 13562) 126s
run: gitlab-workhorse: (pid 13521) 128s; run: log: (pid 13531) 127s
run: logrotate: (pid 13048) 200s; run: log: (pid 13580) 126s
run: nginx: (pid 13026) 206s; run: log: (pid 13532) 127s
run: node-exporter: (pid 13205) 188s; run: log: (pid 13551) 127s
run: postgres-exporter: (pid 13632) 125s; run: log: (pid 13640) 125s
run: postgresql: (pid 12740) 297s; run: log: (pid 13512) 128s
run: prometheus: (pid 13587) 126s; run: log: (pid 13641) 124s
run: redis: (pid 12658) 308s; run: log: (pid 13511) 128s
run: redis-exporter: (pid 13249) 176s; run: log: (pid 13563) 126s
run: sidekiq: (pid 12991) 214s; run: log: (pid 13513) 128s
run: unicorn: (pid 12954) 220s; run: log: (pid 13517) 128s
root@gitser:~/gitpkg#
4.修改创建项目后git地址gitlab.example.com为ip地址
root@gitser:~/gitpkg# vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
host: localhost中将localhost改为主机的IP即可
5.更改访问ip(出现502错误时或主动更改ip)
root@gitser:~# vi /etc/gitlab/gitlab.rb
把文件中的 external_url ‘http://gitlab.example.com’ 改为: externa_url ‘http://192.168.3.184:9988’
root@gitser:~# vi /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
把文件中的 listen “127.0.0.1:8080” 改为: listen “192.168.3.184:9988”
其中192.168.3.184为服务器访问IP
6.使用上面修改生效
root@gitser:~# gitlab-ctl reconfigure
执行结束时有类似如下结果
Running handlers:
Running handlers complete
Chef Client finished, 12/557 resources updated in 43 seconds
gitlab Reconfigured!
7.首次访问GitLab,默认用户为root,强制修改密码
重置root密码
使用root用户登录
尽情使用GitLab吧
sudo gitlab-ctl stop停止
sudo gitlab-ctl start开启
sudo gitlab-ctl restart重启
sudo gitlab-ctl status查看状态
sudo gitlab-ctl reconfigure确认配置(修改配置后,必须执行)
sudo gitlab-ctl tail 查看日志
执行如下四步:
sudo gitlab-ctl uninstall
sudo dpkg -r gitlab-ce
sudo rpm -e gitlab-ce
reboot(重启)
在写博客时,会发现在Jekyll默认不支持图表功能,如果要在Jekyll中使用图表,可以使用Mermaid来创建图表。
<script src="/js/mermaid.min.js"></script>
<div class="mermaid">
CHART DEFINITION GOES HERE
</div>
流程图源码
<script src="/js/mermaid.min.js"></script>
<div class="mermaid">
graph TD
A(Java)
B(Java se)
C(Java ee)
D(Java me)
A-.->B
A-.->C
A-.->D
classDef className fill:#f9f,stroke:#333,stroke-width:4px;
class B,C,D className;
style A fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5
</div>
流程图效果图
序列图源码
<div class="mermaid">
sequenceDiagram
Alice->>Bob: Hello Bob, how are you?
alt is sick
Bob->>Alice: Not so good :(
else is well
Bob->>Alice: Feeling fresh like a daisy
end
opt Extra response
Bob->>Alice: Thanks for asking
end
</div>
序列图效果图
具体请参考【Mermaid指南】