软件开发最初是由两个团队共同组成:(没有采用DevOps之前)
没有采用DevOps的缺点:
采用DevOps的优点?
整体的软件开发流程:
为了保证整体流程可以高效的完成,各个阶段都有比较常见的工具,如下图:
Code阶段步骤:
在Windows环境下编写好代码,然后将代码上传到Linux环境下的GitLab上。
步骤:
1:新建一个服务器(2核4G内存+60G硬盘),IP设置成192.168.184.70,主机名设置成centos7-gitlab,专门用来运行GitLab。
2:安装Docker容器。(如果已经安装过了就可以跳过这一步)
3:在这台新的GitLab的服务器上使用Docker的方式运行GitLab。
创建新的虚拟机过程省略!!!
vi /etc/sysconfig/network-scripts/ifcfg-ens33
找到 IPADDR 字段并将IP修改成192.168.184.70即可:
然后重启网络:
systemctl restart network
查看IP是否修改成功:(可以看到ens33已经修改成功了。)
[root@centos7-clear ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.184.70 netmask 255.255.255.0 broadcast 192.168.184.255
inet6 fe80::9ce3:a607:cc1b:e87 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:f5:97:d0 txqueuelen 1000 (Ethernet)
RX packets 550 bytes 56363 (55.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 487 bytes 71677 (69.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
hostnamectl set-hostname centos7-gitlab
systemctl stop firewalld
systemctl disable firewalld
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum -y install docker-ce-3:20.10.8-3.el7.x86_64 docker-ce-cli-3:20.10.8-3.el7.x86_64 containerd.io
配置镜像加速器方法。
针对Docker客户端版本大于 1.10.0 的用户,可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
mkdir -p /etc/docker
cat <<EOF> /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors": [
"https://u01jo9qv.mirror.aliyuncs.com",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
],
"live-restore": true,
"log-driver":"json-file",
"log-opts": {"max-size":"500m", "max-file":"3"},
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"storage-driver": "overlay2"
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
最后就接入阿里云容器镜像加速器成功啦。
[root@centos7-clear ~]# sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
[root@centos7-clear ~]# docker search gitlab-ce
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
gitlab/gitlab-ce GitLab Community Edition docker image based … 3642 [OK]
[root@centos7-gitlab gitlab]# docker pull gitlab/gitlab-ce:latest
latest: Pulling from gitlab/gitlab-ce
7b1a6ab2e44d: Pull complete
6c37b8f20a77: Pull complete
f50912690f18: Pull complete
bb6bfd78fa06: Pull complete
2c03ae575fcd: Pull complete
839c111a7d43: Pull complete
4989fee924bc: Pull complete
666a7fb30a46: Pull complete
Digest: sha256:5a0b03f09ab2f2634ecc6bfeb41521d19329cf4c9bbf330227117c048e7b5163
Status: Downloaded newer image for gitlab/gitlab-ce:latest
docker.io/gitlab/gitlab-ce:latest
[root@centos7-gitlab gitlab]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab/gitlab-ce latest 46cd6954564a 6 months ago 2.36GB
创建文件夹:
[root@centos7-clear ~]# mkdir gitlab && cd gitlab
创建文件:
vi docker-compose.yml
文件内容如下:(记得修改external_url的ip地址为你的gitlab的服务器地址,我们的是192.168.184.70)
version: '3.1'
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://192.168.184.70: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'
[root@centos7-gitlab gitlab]# docker-compose up -d
[root@centos7-gitlab gitlab]# docker exec -it gitlab cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: 6PHFewZSOcvt5rQD65mlCP5Tr5i8MRYTadwa3VGvkPo=
# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
步骤:
1:新建一个服务器(2核4G内存+60G硬盘),IP设置成192.168.184.80,主机名设置成centos7-jenkins。
2:安装Docker容器。(如果已经安装过了就可以跳过这一步)
创建新的虚拟机过程省略!!!
vi /etc/sysconfig/network-scripts/ifcfg-ens33
找到 IPADDR 字段并将IP修改成192.168.184.80即可:
然后重启网络:
systemctl restart network
查看IP是否修改成功:(可以看到ens33已经修改成功了。)
[root@centos7-clear ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.184.80 netmask 255.255.255.0 broadcast 192.168.184.255
inet6 fe80::9aa7:2f1d:4559:d9c8 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:63:69:7f txqueuelen 1000 (Ethernet)
RX packets 136 bytes 17161 (16.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 157 bytes 20956 (20.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX
hostnamectl set-hostname centos7-jenkins
systemctl stop firewalld
systemctl disable firewalld
[root@centos7-jenkins ~]# pwd
/root
2:使用XFTP把刚刚下载好的两个包上传上去:
3:查看上传好的包:
[root@centos7-jenkins ~]# ls
anaconda-ks.cfg apache-maven-3.8.6-bin.tar.gz jdk-8u333-linux-x64.tar.gz
tar -zxvf jdk-8u333-linux-x64.tar.gz -C /usr/local
tar -zxvf apache-maven-3.8.6-bin.tar.gz -C /usr/local
cd /usr/local
mv jdk1.8.0_333 jdk
mv apache-maven-3.8.6 maven
[root@centos7-jenkins local]# ls
bin etc games include jdk lib lib64 libexec maven sbin share src
cd maven/conf
[root@centos7-jenkins conf]# vi settings.xml
插入内容如下:(插入到 mirrors > 这个标签上面即可),先不用保存退出
<mirror>
<id>nexus-aliyunid>
<mirrorOf>centralmirrorOf>
<name>Nexus aliyunname>
<url>http://maven.aliyun.com/nexus/content/groups/publicurl>
mirror>
插入内容如下:(插入到 < /profiles > 标签上面即可)
<profile>
<id>jdk8id>
<activation>
<activeByDefault>trueactiveByDefault>
<jdk>1.8jdk>
activation>
<properties>
<maven.compiler.source>1.8maven.compiler.source>
<maven.compiler.target>1.8maven.compiler.target>
<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
properties>
profile>
并插入如下内容:(用于开启上面的jdk配置,插入到最下面的< /settings >标签上面即可),然后保存退出
<activeProfiles>
<activeProfile>jdk8activeProfile>
activeProfiles>
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum -y install docker-ce-3:20.10.8-3.el7.x86_64 docker-ce-cli-3:20.10.8-3.el7.x86_64 containerd.io
配置镜像加速器方法。
针对Docker客户端版本大于 1.10.0 的用户,可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
mkdir -p /etc/docker
cat <<EOF> /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"registry-mirrors": [
"https://u01jo9qv.mirror.aliyuncs.com",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
],
"live-restore": true,
"log-driver":"json-file",
"log-opts": {"max-size":"500m", "max-file":"3"},
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"storage-driver": "overlay2"
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
最后就接入阿里云容器镜像加速器成功啦。
sudo systemctl enable docker
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
[root@centos7-jenkins conf]# docker-compose --version
Docker Compose version v2.4.1