In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you the relevant knowledge points about the method of Gitlab CI-CD automation deployment SpringBoot project. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
I. Overview
This article focuses on how to automatically deploy the SpringBoot project jar package through Gitlab CI/CD.
II. Preparation in advance
Prepare three CentOS7 servers and deploy the following services:
Serial number system IP service 1CentOS7192.168.56.10Gitlab2CentOS7192.168.56.11Runner (install Docker) 3CentOS7192.168.56.12SpringBoot project jar package (install jdk, maven, etc.)
The above services can also be deployed on the same machine with only one CentOS7, but it is recommended to deploy them separately.
III. Overall architecture diagram
Description:
Gitlab Server is used to deploy Gitlab remote warehouse, which requires high CPU and memory. It is recommended to have more than 4 cores of CPU,4GB memory.
Runner Server is used to deploy and execute the stage (phase) defined in the. gitlab-ci.yml file; you need to have access to the Gitlab repository, you can download the code and gitlab-runner register it.
Your Laptop Server users deploy your application. Here is the jar package of SpringBoot. You need to install JDK and Maven in advance and configure the environment variables.
Fourth, environmental construction 1, environmental preparation (optional)
The three servers execute the following command:
Yum-y upgradeyum-y install wgetyum-y install vim2, Gitlab installation
Reference address:
Https://about.gitlab.com/install/#centos-7
Https://www.xieniao.com/article/188877.htm
(1) install and configure the necessary dependencies
Sudo yum install-y curl policycoreutils-python openssh-serversudo systemctl enable sshdsudo systemctl start sshdsudo firewall-cmd-permanent-add-service=httpsudo firewall-cmd-permanent-add-service=httpssudo systemctl reload firewalld
(2) install mail service
Sudo yum install postfixsudo systemctl enable postfixsudo systemctl start postfix
(3) add gitlab image
Wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.4.0-ce.0.el7.x86_64.rpm
(4) install gitlab installation command
Rpm-I gitlab-ce-13.4.0-ce.0.el7.x86_64.rpm-- nodeps-- force
Picture after successful installation:
(5) modify gitlab configuration file to specify server ip and custom port
Vim / etc/gitlab/gitlab.rb
(6) reset and start GitLab
Gitlab-ctl reconfiguregitlab-ctl restart
The prompt "ok: run:" indicates that the startup is successful
(7) visit the GitLab page
If reported 502, wait for a period of time and then refresh try, generally 1-2 minutes or so.
The account set up in this article is root, and the new password is 11112222
3. Install Runner
(1) download a binary file
Sudo curl-L-output / usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
(2) modify the execution permission
Sudo chmod axix / usr/local/bin/gitlab-runner
(3) create GitLab CI users
Sudo useradd-- comment 'GitLab Runner'-- create-home gitlab-runner-- shell / bin/bash
(4) install and run as a service
Sudo gitlab-runner install-user=gitlab-runner-working-directory=/home/gitlab-runnersudo gitlab-runner start
If you encounter the prompt sudo: gitlab-runner: command not found, switch to the root user, you can remove sudo and execute the above command.
(5) register for Runner
Reference address: https://docs.gitlab.com/runner/register/index.html
Execute the gitlab-runner register command:
[root@localhost bin] # gitlab-runner registerRuntime platform arch=amd64 os=linux pid=21527 revision=4e1f20da version=13.4.0Running in system-mode.Please enter the gitlab-ci coordinator URL (e.g. Https://gitlab.com/):http://192.168.56.10/Please enter the gitlab-ci token for this runner:PwF1sZPX_zsB-xChSKjHPlease enter the gitlab-ci description for this runner: [localhost.localdomain]: test ci cd descPlease enter the gitlab-ci tags for this runner (comma separated): my-tag Other-tagRegistering runner... Succeeded runner=PwF1sZPXPlease enter the executor: ssh, virtualbox, parallels, shell, docker-ssh, docker+machine, docker-ssh+machine, kubernetes, custom, docker:dockerPlease enter the default Docker image (e.g. Ruby:2.6): maven:3.3.9-jdk-8Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Note: docker is chosen here, so additional installation of docker is required on the server.
#! / bin/bash# removes the old version sudo yum remove docker\ docker-client\ docker-client-latest\ docker-common\ docker-latest\ docker-latest-logrotate\ docker-logrotate\ docker-selinux\ Docker-engine-selinux\ docker-engine# removes all old data sudo rm-rf / var/lib/docker# installation dependency package sudo yum install-y yum-utils\ device-mapper-persistent-data\ lvm2# add source Use Ali cloud mirror sudo yum-config-manager\-- add-repo\ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# configuration cache sudo yum makecache fast# to install the latest stable version of dockersudo yum install-y docker-ce# configuration image accelerator sudo mkdir-p / etc/dockersudo tee / etc/docker/daemon.json
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.