Article directory
1. Introduction to DevOps
Software development initially consisted of two teams:
- The development plan consists of
开发团队
the design and construction of the overall system from scratch. The system requires constant iterative updates. 运维团队
Test the code of the development team and deploy it online. Hope the system runs stably and safely.
It seems that two teams with different goals need to work together to complete the development of a software. After 开发团队
specifying the plan and completing the coding, you need to provide it 运维团队
. The operation and maintenance team reports the bugs that need to be fixed and some tasks that need to be reworked to the development team.
At this time, the development team often needs to wait for feedback from the operation and maintenance team. This undoubtedly prolongs the event and delays the entire software development cycle.
There will be a way to 在开发团队等待的时候,让开发团队转移到下一个项目中。
wait for the ops team to provide feedback on previous code. But this means that a complete project requires a longer cycle to develop the final code.
Based on the current Internet status, agile development is more popular, which leads to faster iteration of the project. However, due to the communication problem between the development team and the operation and maintenance team, the time cost for the new version to go online is very high. This again defeats the original purpose of agile development.
So 如果让开发团队和运维团队整合到成一个团队,协同应对一套软件呢?这就被称为DevOps。
DevOps
, which literally means the abbreviation of Development & Operations, that is, development & operations. Although the literal meaning only involves the development team and the operation and maintenance team, it QA测试团队
is actually involved.
DevOps |
---|
This shows that DevOps is a process of continuous improvement in efficiency and continuous work.
DevOps
The way that companies can respond to updates and market development changes faster, development can be delivered quickly, and deployments are more stable. The core is to simplify the process between Dev and Ops teams and make the overall software development process faster.
The overall software development process includes:
- PLAN: The development team develops a development plan based on the client's goals
- CODE: To start the coding process according to the PLAN, different versions of the code need to be stored in a library.
- BUILD: After coding is complete, the code needs to be built and run.
- TEST: After successfully building the project, you need to test the code for bugs or errors.
- DEPLOY: After the code has been manually tested and automated, it is determined that the code is ready for deployment and handed over to the operation and maintenance team.
- OPERATE: The operations team deploys the code to production.
- MONITOR: After the project is deployed and launched, it is necessary to continuously monitor the product.
- INTEGRATE: The feedback received in the monitoring phase is then sent back to the PLAN phase. The overall iterative process is the core of DevOps , namely continuous integration and continuous deployment.
In order to ensure that the overall process can be completed efficiently, there are more common tools at each stage, as shown below:
Software development process & tools involved |
---|
Ultimately , the DevOps
next definition can be given: DevOps emphasizes how efficient organizational teams can collaborate and communicate with each other through automated tools to complete software lifecycle management, thereby delivering more stable software faster and more frequently.
Automated tools for collaboration and communication to complete software lifecycle management.
Second, the Code stage tools
In the code
stage, we need to store different versions of the code in a warehouse, the common version control tool is SVN
or Git
, here we use Git as the version control tool and GitLab as the remote warehouse.
2.1 Git installation
https://git-scm.com/
2.2 GitLab installation
Prepare the server separately, using the Docker
installation
Check out GitLab
the mirror:
docker search gitlab
Pull the GitLab
image:
docker pull gitlab/gitlab-ce
Prepare docker-compose.yml
documents:
version: '3.1'
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.11.11:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports:
- '8929:8929'
- '2224:2224'
volumes:
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
Start the container:
docker-compose up -d
Visit GitLab
the home page:
front page |
---|
View the initial password of the root user:
docker exec -it gitlab cat /etc/gitlab/initial_root_password
initial password |
---|
Login as root user:
Jump to the page after successful login |
---|
After the first login, you need to change the password:
change Password |
---|
Once done, you can use it like Gitee and GitHub.
3. Build stage tools
Tools for building Java projects generally have two choices, one is Maven
and the other is Gradle
. Here we choose Maven as the compilation tool for the project.
Maven installation and configuration process:
- Install Maven
- Configure environment variables
- Configure local repository
- Configure mirroring
- Configure JDK
The specific installation and configuration process will be explained in detail later. Here, you must ensure that the Maven repository private server and the JDK compiled version are configured.
Fourth, the Operate stage tool
During the deployment process, Docker will be used for deployment. For the time being, only Docker will be installed, and Kubenetes will need to be installed in the future.
4.1 Docker installation
Prepare test environment & production environment
Download Docker dependencies:
yum -y install yum-utils device-mapper-persistent-data lvm2
Set the image source for downloading Docker to Alibaba Cloud:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Install the Docker service:
yum -y install docker-ce
After the installation is successful, start Docker and set the boot to start automatically:
# 启动Docker服务
systemctl start docker
# 设置开机自动启动
systemctl enable docker
The test installation was successful:
docker version
Effect |
---|
4.2 Docker-Compose installation
Download Docker/Compose:https://github.com/docker/compose
Move the downloaded docker-compose-Linux-x86_64
file to the Linux operating system: …
Set docker-compose-Linux-x86_64
file permissions and move into the $PATH directory:
# 设置文件权限
chmod a+x docker-compose-Linux-x86_64
# 移动到/usr/bin目录下,并重命名为docker-compose
mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
The test installation was successful:
docker-compose version
Effect |
---|