GitLab搭建
安装环境
安装需要的依赖
ssh,postfix(邮件通知),wget
设置开机自动启动命令 systemctl enable xxx
启动某些服务命令:systemctl start xxx
1.安装ssh
sudo yum install -y curl policycoreutils-pythonopenssh-server
2.安装wget(一般都会安装)
yum -y install wget
3.安装postfix
yum -y install postfix
启动postfix服务
systemctl start postfix
发现报错
[root@iZ2ze5y0zrhwsd8mdofyapZ /]# systemctl start postfix
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
[root@iZ2ze5y0zrhwsd8mdofyapZ /]# systemctl status postfix.service
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2021-05-27 20:27:25 CST; 24s ago
Process: 9196 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
Process: 9194 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
Process: 9191 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=75)
May 27 20:27:23 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Starting Postfix Mail Transport Agent...
May 27 20:27:23 iZ2ze5y0zrhwsd8mdofyapZ aliasesdb[9191]: /usr/sbin/postconf: fatal: parameter inet_interfaces: n... ::1
May 27 20:27:24 iZ2ze5y0zrhwsd8mdofyapZ aliasesdb[9191]: newaliases: fatal: parameter inet_interfaces: no local ... ::1
May 27 20:27:24 iZ2ze5y0zrhwsd8mdofyapZ postfix[9196]: fatal: parameter inet_interfaces: no local interface foun... ::1
May 27 20:27:25 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: postfix.service: control process exited, code=exited status=1
May 27 20:27:25 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Failed to start Postfix Mail Transport Agent.
May 27 20:27:25 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Unit postfix.service entered failed state.
May 27 20:27:25 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: postfix.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ2ze5y0zrhwsd8mdofyapZ /]# journalctl -xe
-- Subject: Unit session-7522.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-7522.scope has finished starting up.
--
-- The start-up result is done.
May 27 20:20:01 iZ2ze5y0zrhwsd8mdofyapZ CROND[9111]: (root) CMD (/usr/lib64/sa/sa1 1 1)
May 27 20:21:32 iZ2ze5y0zrhwsd8mdofyapZ useradd[9132]: failed adding user 'postfix', exit code: 9
May 27 20:21:32 iZ2ze5y0zrhwsd8mdofyapZ postfix[9134]: fatal: parameter inet_interfaces: no local interface found for :
May 27 20:21:33 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Reloading.
May 27 20:21:33 iZ2ze5y0zrhwsd8mdofyapZ yum[9115]: Updated: 2:postfix-2.10.1-9.el7.x86_64
May 27 20:21:33 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Reloading.
May 27 20:21:57 iZ2ze5y0zrhwsd8mdofyapZ polkitd[522]: Registered Authentication Agent for unix-process:9167:384182458 (
May 27 20:21:57 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Reloading.
May 27 20:21:57 iZ2ze5y0zrhwsd8mdofyapZ polkitd[522]: Unregistered Authentication Agent for unix-process:9167:384182458
May 27 20:27:23 iZ2ze5y0zrhwsd8mdofyapZ polkitd[522]: Registered Authentication Agent for unix-process:9185:384215121 (
May 27 20:27:23 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Starting Postfix Mail Transport Agent...
-- Subject: Unit postfix.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postfix.service has begun starting up.
May 27 20:27:23 iZ2ze5y0zrhwsd8mdofyapZ aliasesdb[9191]: /usr/sbin/postconf: fatal: parameter inet_interfaces: no local
May 27 20:27:24 iZ2ze5y0zrhwsd8mdofyapZ postfix/sendmail[9193]: fatal: parameter inet_interfaces: no local interface fo
May 27 20:27:24 iZ2ze5y0zrhwsd8mdofyapZ aliasesdb[9191]: newaliases: fatal: parameter inet_interfaces: no local interfa
May 27 20:27:24 iZ2ze5y0zrhwsd8mdofyapZ postfix[9196]: fatal: parameter inet_interfaces: no local interface found for :
May 27 20:27:25 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: postfix.service: control process exited, code=exited status=1
May 27 20:27:25 iZ2ze5y0zrhwsd8mdofyapZ systemd[1]: Failed to start Postfix Mail Transport Agent.
处理
vi /etc/postfix/main.cf
发现配置为:
inet_interfaces = localhost
inet_protocols = all
改成:
inet_interfaces = all
inet_protocols = all
重启即可
下载并安装
下载gitlab镜像
[root@iZ2ze5y0zrhwsd8mdofyapZ /]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
--2021-05-27 20:35:45-- https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 359519811 (343M) [application/x-redhat-package-manager]
Saving to: ‘gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm’
100%[===========================================================================================================================================================================>] 359,519,811 2.43MB/s in 76s
2021-05-27 20:37:01 (4.53 MB/s) - ‘gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm’ saved [359519811/359519811]
安装gitlab
[root@iZ2ze5y0zrhwsd8mdofyapZ /]# rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
warning: gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
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配置文件的服务器ip和自定义端口
vim /etc/gitlab/gitlab.rb
external_url 'http://ip:端口'
重置配置文件并重启
gitlab-ctl reconfigure
[root@iZ2ze5y0zrhwsd8mdofyapZ /]# gitlab-ctl restart
ok: run: gitaly: (pid 10953) 0s
ok: run: gitlab-monitor: (pid 10962) 0s
ok: run: gitlab-workhorse: (pid 10973) 0s
ok: run: logrotate: (pid 10980) 0s
ok: run: nginx: (pid 11021) 1s
ok: run: node-exporter: (pid 11027) 0s
ok: run: postgres-exporter: (pid 11033) 1s
ok: run: postgresql: (pid 11041) 0s
ok: run: prometheus: (pid 11050) 1s
ok: run: redis: (pid 11059) 0s
ok: run: redis-exporter: (pid 11063) 0s
ok: run: sidekiq: (pid 11068) 0s
ok: run: unicorn: (pid 11078) 1s
阿里云开启防火墙
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-d4NSnKGs-1622267850872)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20210527204739602.png)]
访问
gitlab
设置初始化密码后登录
默认账户root
新建项目
上传代码到服务器
cd existing_folder
git init
git remote add origin http://xx.xx.xx.xx:1111/root/helloword-springboot.git
git add .
git commit -m "Initial commit"
git push -u origin master