概述
目录
1.安装依赖环境
2.安装gitlab
3.修改root密码
4.常用操作命令
5.卸载gitlab
6.docker安装gitlab
官方说明文档:Download and install GitLab|GitLab
1.安装依赖环境
[root@iZm5e452n3se0jvpdlgbdpZ src]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-09-08 12:50:40 CST; 42min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 998 (sshd)
CGroup: /system.slice/sshd.service
└─998 /usr/sbin/sshd -D
Sep 08 12:50:40 iZm5e452n3se0jvpdlgbdpZ systemd[1]: Starting OpenSSH server daemon...
Sep 08 12:50:40 iZm5e452n3se0jvpdlgbdpZ sshd[998]: Server listening on 0.0.0.0 port 22.
Sep 08 12:50:40 iZm5e452n3se0jvpdlgbdpZ systemd[1]: Started OpenSSH server daemon.
Sep 08 12:51:18 iZm5e452n3se0jvpdlgbdpZ sshd[1506]: Accepted password for root from 39.89.136.122 port 61301 ssh2
Sep 08 13:10:24 iZm5e452n3se0jvpdlgbdpZ sshd[2743]: Accepted password for root from 27.193.250.128 port 55235 ssh2
Sep 08 13:13:27 iZm5e452n3se0jvpdlgbdpZ sshd[2923]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh rus...r=root
Sep 08 13:13:27 iZm5e452n3se0jvpdlgbdpZ sshd[2923]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root"
Sep 08 13:13:29 iZm5e452n3se0jvpdlgbdpZ sshd[2923]: Failed password for root from 182.254.156.93 port 56434 ssh2
Sep 08 13:13:29 iZm5e452n3se0jvpdlgbdpZ sshd[2923]: Connection closed by 182.254.156.93 port 56434 [preauth]
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZm5e452n3se0jvpdlgbdpZ src]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
安装postfix
[root@iZm5e452n3se0jvpdlgbdpZ src]# yum install postfix
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/2): epel/x86_64/primary_db | 7.0 MB 00:00:00
Package 2:postfix-2.10.1-9.el7.x86_64 already installed and latest version
Nothing to do
我这边提示已经安装了postfix
[root@iZm5e452n3se0jvpdlgbdpZ src]# sudo systemctl enable postfix
sudo systemctl start postfix
[root@iZm5e452n3se0jvpdlgbdpZ src]# sudo systemctl start postfix
2.安装gitlab
安装包仓库
[root@iZm5e452n3se0jvpdlgbdpZ src]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
......
Installed:
yum-utils.noarch 0:1.1.31-54.el7_8
Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7.5 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7
Complete!
Generating yum cache for gitlab_gitlab-ee...
Importing GPG key 0x51312F3F:
Userid : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
Fingerprint: f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
From : https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey
Generating yum cache for gitlab_gitlab-ee-source...
The repository is setup! You can now install packages.
去官网下载对应的安装包:gitlab/gitlab-ce - Packages · packages.gitlab.com
我安装的是这个版本,右下角可以直接复制wget的链接
[root@iZm5e452n3se0jvpdlgbdpZ local]# wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-14.0.10-ce.0.el7.x86_64.rpm/download.rpm
显示下载完成,执行:
[root@iZm5e452n3se0jvpdlgbdpZ local]# rpm -ivh gitlab-ce-14.0.10-ce.0.el7.x86_64.rpm
warning: gitlab-ce-14.0.10-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
error: Failed dependencies:
policycoreutils-python is needed by gitlab-ce-14.0.10-ce.0.el7.x86_64
提示报错,policycoreutils-python is needed
执行
yum install policycoreutils-python
再重新执行rpm的安装
显示安装成功
[root@iZm5e452n3se0jvpdlgbdpZ local]# whereis gitlab
gitlab: /etc/gitlab
[root@iZm5e452n3se0jvpdlgbdpZ local]# vim /etc/gitlab/gitlab.rb
设置external_url ‘http://ip地址’,保存
修改puma端口号puma['port'] = xxxx,默认为8080,不修改可能会有端口冲突导致gitlab报502
执行:
[root@bd ~]# gitlab-ctl reconfigure// 可能会打印许多信息
#最后提示成功信息语句
Recipe: monitoring::alertmanager
* runit_service[alertmanager] action restart (up to date)
Recipe: monitoring::postgres-exporter
* runit_service[postgres-exporter] action restart (up to date)
Recipe: monitoring::grafana
* runit_service[grafana] action restart (up to date)
Running handlers:
Running handlers complete
Chef Infra Client finished, 572/1516 resources updated in 04 minutes 33 seconds
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
gitlab Reconfigured!
如果reconfigure卡在ruby_block[wait for logrotate service socket]
执行systemctl restart gitlab-runsvdir
[root@bd ~]# gitlab-ctl restart
[root@bd ~]# gitlab-ctl status //查看状态
-------------------------------------------------------------
run: alertmanager: (pid 8494) 31s; run: log: (pid 7854) 154s
run: gitaly: (pid 8503) 29s; run: log: (pid 7254) 285s
run: gitlab-exporter: (pid 8525) 29s; run: log: (pid 7779) 172s
run: gitlab-workhorse: (pid 8527) 29s; run: log: (pid 7688) 188s
run: grafana: (pid 8542) 28s; run: log: (pid 8149) 92s
run: logrotate: (pid 8553) 28s; run: log: (pid 7166) 298s
run: nginx: (pid 8559) 27s; run: log: (pid 7718) 183s
run: node-exporter: (pid 8565) 27s; run: log: (pid 7756) 177s
run: postgres-exporter: (pid 8571) 26s; run: log: (pid 7882) 148s
run: postgresql: (pid 8659) 26s; run: log: (pid 7396) 273s
run: prometheus: (pid 8661) 26s; run: log: (pid 7827) 160s
run: puma: (pid 8680) 25s; run: log: (pid 7621) 204s
run: redis: (pid 8685) 25s; run: log: (pid 7206) 290s
run: redis-exporter: (pid 8691) 24s; run: log: (pid 7801) 166s
run: sidekiq: (pid 8701) 22s; run: log: (pid 7652) 196s
#启动成功
输入刚才设置的ip和端口号,输入访问页面,正常
如果出现问题可使用tail命令查看日志定位问题,看看是否有端口占用的情况
gitlab-ctl tail
如果gitlab报错502,不仅要看external_url的端口,同时要看puma和unicorn的端口占用情况
3.修改root密码
’root初始密码在下面这个文件中,24小时候会自动删除,root账号登陆后需要尽快修改密码
/etc/gitlab/initial_root_password
4.常用操作命令
#配置重新加载
gitlab-ctl reconfigure
# 启动gitlab
gitlab-ctl start
# 停止gitlab
gitlab-ctl stop
# 查看gitlab命令
gitlab-ctl --help
#查看gitlab日志
gitlab-ctl tail [process name] #[process name可选]
5.卸载gitlab
#先杀死进程
kill -9 xxx
#卸载gitlab(ce是社区版)
rpm -e gitlab-ce
#最后删除文件
find / -name gitlab | xargs rm -rf
6.docker安装gitlab
# 拉取社区版镜像
docker pull gitlab/gitlab-ce
新建宿主机映射文件夹
mkdir -p /home/docker/gitlab/etc
mkdir -p /home/docker/gitlab/logs
mkdir -p /home/docker/gitlab/data
启动gitlab的docker镜像
docker run
-d #后台运行,全称:detach
-p 8443:443 #将容器内部端口向外映射
-p 8061:80 #将容器内80端口映射至宿主机8090端口,这是访问gitlab的端口
-p 8022:22 #将容器内22端口映射至宿主机8022端口,这是访问ssh的端口
--restart always #容器自启动
--name my-gitlab #设置容器名称为my-gitlab
-v /home/docker/gitlab/etc:/etc/gitlab #将容器/etc/gitlab目录挂载到宿主机/home/docker/gitlab/etc目录下,若宿主机内此目录不存在将会自动创建
-v /home/docker/gitlab/log:/var/log/gitlab #与上面一样
-v /home/docker/gitlab/data:/var/opt/gitlab #与上面一样
--privileged=true #让容器获取宿主机root权限
gitlab/gitlab-ce #镜像的名称,这里也可以写镜像ID
修改配置文件
vim /home/docker/gitlab/etc/gitlab.rb
需修改的内容同linux直接安装一样,调整为docker映射过后的宿主机的对应配置(需注意docker容器需要映射宿主机端口,这里external_url ‘http://ip地址’,不需要额外填写端口号)
然后进入容器
docker exec -it my-gitlab bash
修改配置文件
cd /opt/gitlab/embedded/service/gitlab-rails/config
//打开编辑gitlab.yml文件
vim gitlab.yml
修改此处为之前对应配置的ip+port
# 重启gitlab
gitlab-ctl restart
# 退出容器
exit
使用docker安装gitlab安装完毕!
最后
以上就是自由小馒头为你收集整理的linux centos7安装自己的gitlab私有库的全部内容,希望文章能够帮你解决linux centos7安装自己的gitlab私有库所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复