前言:
此篇是为了完结真实的物理隔离环境下、验证yum缓存的文件包安装配置是否成功,对上篇在线安装文章的补充。
1. 互联网电脑环境准备
1.1 电脑环境配置信息
IP:192.168.31.164
OS:CentOS Linux release 7.9.2009 (Core)
1.2 清除yum的rpm包缓存数据
包清除前的数据记录:
[root@bdlab 7]# pwd
/var/cache/yum/x86_64/7
[root@bdlab 7]# du -h
31M ./base/gen
0 ./base/packages
38M ./base
1.4M ./extras/gen
0 ./extras/packages
1.6M ./extras
245M ./updates/gen
603M ./updates/packages
881M ./updates
920M .
[root@bdlab 7]#
清除所有的缓存记录,
[root@bdlab /]# yum clean all
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors
[root@bdlab /]#
查看清理效果:
[root@bdlab /]# du -h /var/cache/yum/x86_64/7
0 /var/cache/yum/x86_64/7/base/gen
0 /var/cache/yum/x86_64/7/base/packages
0 /var/cache/yum/x86_64/7/base
0 /var/cache/yum/x86_64/7/extras/gen
0 /var/cache/yum/x86_64/7/extras/packages
0 /var/cache/yum/x86_64/7/extras
0 /var/cache/yum/x86_64/7/updates/gen
0 /var/cache/yum/x86_64/7/updates/packages
0 /var/cache/yum/x86_64/7/updates
4.0K /var/cache/yum/x86_64/7
[root@bdlab /]#
1.3 开启yum缓存功能
目的是为了后面可以导出rpm包备用,打开yum的缓存功能:vim /etc/yum.conf,如下图所示,将keepcache改为1
2. 在线下载安装包及各类服务组件
2.1 在线安装下载 python3
yum -y install python3
安装成功的组件,
在yum的缓存目录存在rpm包,
2.2 在线安装下载服务组件
yum -y install curl openssh-server openssh-clients postfix cronie python3-policycoreutils policycoreutils-python
继续查验yum的缓存目录的rpm包
2.3 Gitlab安装包web下载
http网页在线下载: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.1.2-ce.0.el7.x86_64.rpm
3. 离线安装上述安装包及服务
3.1 上述rpm包导出到指定文件目录
1)通过命令行或xftp工具导出安装包,临时存放在中转的电脑中,
2)通过工具将安装包导入到 /etc/data 目录中,
先将内网服务器与宿主机调整到同一网段内,进行数据包传输;或者通过刻录的光盘或者U盘、NFS方式加载传输。
3)登录内网服务器主机
该环境无法联通互联网。
3.2 离线安装rpm包及服务
rpm -ivh * --nodeps --force
gitlab离线安装完成,
开启并打开ssh功能,
[root@localhost ~]# find / -name sshd
/etc/pam.d/sshd
/etc/sysconfig/sshd
/var/empty/sshd
/usr/sbin/sshd
/opt/gitlab/embedded/service/gitlab-shell/internal/sshd
[root@localhost ~]#
[root@localhost ~]# systemctl enable sshd && systemctl start sshd
[root@localhost ~]#
4. 配置Gitlab及登录
下面过程和在线安装gitlab相同,有些地方加了可编辑的说明,方便理解。
4.1 备份配置文件
建议对需要修改的配置文件先备份:/etc/gitlab/gitlab.rb
[root@localhost Gitinstall]# cd /etc/gitlab
[root@localhost gitlab]# ls
gitlab.rb
[root@localhost gitlab]# cp gitlab.rb /home/gitconfbaks/
[root@localhost gitlab]#
[root@localhost gitlab]# vim gitlab.rb
将external_url 'http://gitlab.example.com'修改成 external_url‘http://192.168.37.129:8500’ 添加端口号:nginx['listen_port']=8500
4.2 配置并启动gitlab服务
配置服务:
[root@localhost gitlab]# gitlab-ctl reconfigure
.....
....
[2023-10-07T17:22:04+08:00] WARN: This release of Chef Infra Client became end of life (EOL) on May 1st 2023. Please update to a supported release to receive new features, bug fixes, and security updates.
gitlab Reconfigured!
[root@localhost gitlab]#
重启服务验证:
[root@localhost gitlab]# gitlab-ctl restart
ok: run: alertmanager: (pid 8992) 0s
ok: run: gitaly: (pid 9001) 1s
ok: run: gitlab-exporter: (pid 9019) 0s
ok: run: gitlab-kas: (pid 9021) 1s
ok: run: gitlab-workhorse: (pid 9032) 0s
ok: run: grafana: (pid 9040) 1s
ok: run: logrotate: (pid 9051) 0s
ok: run: nginx: (pid 9058) 1s
ok: run: node-exporter: (pid 9064) 0s
ok: run: postgres-exporter: (pid 9073) 0s
ok: run: postgresql: (pid 9088) 0s
ok: run: prometheus: (pid 9091) 0s
ok: run: puma: (pid 9227) 0s
ok: run: redis: (pid 9232) 1s
ok: run: redis-exporter: (pid 9238) 0s
ok: run: sidekiq: (pid 9249) 1s
[root@localhost gitlab]#
登录web页面验证是否正常,
4.3 设置系统防火墙
开启防火墙、及端口通讯
[root@localhost ~]# firewall-cmd --znotallow=public --add-port=8500/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --znotallow=public --list-ports
8500/tcp
[root@localhost ~]#
查看防火墙运行状态:正常
4.4 配置gitlab默认登录账户
[root@localhost ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 15.1.2 (ea7455c8292) FOSS
GitLab Shell: 14.7.4
PostgreSQL: 13.6
------------------------------------------------------------[ booted in 75.68s ]
Loading production environment (Rails 6.1.4.7)
irb(main):003:0> user=User.where(username:"root").first
# 输入>user=User.where(username:"root").first账号信息
=> #<User id:1 @root>
irb(main):004:0> user.password="rdc345!"
#设置账户登录密码
=> "rdc345!"
irb(main):005:0> user.save!
Traceback (most recent call last):
7: from (irb):5
6: from lib/gitlab/database/load_balancing/connection_proxy.rb:71:in `transaction'
5: from lib/gitlab/database/load_balancing/connection_proxy.rb:119:in `write_using_load_balancer'
4: from lib/gitlab/database/load_balancing/load_balancer.rb:111:in `read_write'
3: from lib/gitlab/database/load_balancing/load_balancer.rb:184:in `retry_with_backoff'
2: from lib/gitlab/database/load_balancing/load_balancer.rb:115:in `block in read_write'
1: from lib/gitlab/database/load_balancing/connection_proxy.rb:120:in `block in write_using_load_balancer'
ActiveRecord::RecordInvalid (Validation failed: Password is too short (minimum is 8 characters)) #口令设置存在不安全性,需要重新设置
irb(main):006:0> user.password="se4boro!"
=> "se4boro!"
irb(main):007:0> user.save!
=> true
irb(main):008:0> exit
[root@localhost ~]#
4.5 登录gitlab的web界面
输入账户root,测试口令:se4boro!
登录文本界面:http://192.168.37.129:8500
后续配置管理同前篇《CentOS环境:安装配置gitlab(适用于内网、外网环境)》,此处不再描述。
标签:run,CentOS,root,gitlab,离线,yum,ok,内网,localhost From: https://blog.51cto.com/u_13919832/7741381