Gitlab-Runner安装

文章目录

  • helm方式安装在K8S上
  • 参考
    • gitlab CI/CD 文件变量
    • 缓存服务器
      • K8S部署
    • docker镜像
      • maven
      • docker
        • 安装docker buildx
      • minio
      • node
      • helm
      • kubectl
      • sonar-scanner-cli
    • 问题
      • 清除cache
      • helm执行时无权限
    • 下载镜像失败
      • 下载gitlab-runner镜像失败
    • Gitlab-ci中使用
      • java
      • 前端

helm方式安装在K8S上

1、下载charts

helm pull gitlab/gitlab-runner
tar -zxvf gitlab-runner-0.27.0.tgz#解压后内容:CHANGELOG.mdChart.yaml    #CONTRIBUTING.mdLICENSEMakefileNOTICEREADME.mdtemplates    #values.yaml  #

2、修改 values.yaml,templates 等资源

values.yaml

gitlabUrl: https://gitlab.example.com/  #修改为gitlab地址
runnerRegistrationToken: ""             #修改为gitlab runner token,可从 /admin/runners 查看
rbac:create: trueclusterWideAccess: trueserviceAccountName: gitlab-runner-gitlab-runner
runners:tags: ""  serviceAccountName: gitlab-runner-gitlab-runner

templates/configmap.yaml

主要用于maven,docker绑定本地目录,修改 entrypoint key。增加 config.toml 配置。

    #以下一段是增加的内容cat >>/home/gitlab-runner/.gitlab-runner/config.toml <<EOF[[runners.kubernetes.volumes.host_path]]name = "maven"mount_path = "/root/.m2"read_only = falsehost_path = "/root/.m2"[[runners.kubernetes.volumes.host_path]]name = "docker"mount_path = "/var/run/docker.sock"read_only = truehost_path = "/var/run/docker.sock"EOF# Start the runnerexec /entrypoint run --user=gitlab-runner \--working-directory=/home/gitlab-runner

新的方式可以通过values.yamlrunners 段设置属性不能同时以上面和下面2种方式,不然会重复

runners:config: |[[runners]][runners.kubernetes]image = "ubuntu:16.04"[[runners.kubernetes.volumes.host_path]]name = "maven"mount_path = "/root/.m2"read_only = falsehost_path = "/root/.m2"[[runners.kubernetes.volumes.host_path]]name = "docker"mount_path = "/var/run/docker.sock"read_only = truehost_path = "/var/run/docker.sock"

_cache.tpl

里面CACHE_S3_INSECURE 参数 是固定值,导致 values 配置无效。

{{-       if .Values.runners.cache.s3CacheInsecure }}
- name: CACHE_S3_INSECUREvalue: "true"
{{-       end }}{{ default "" .Values.runners.cache.s3BucketLocation | quote }}#-----   修改为:- name: CACHE_S3_INSECUREvalue: {{ default "true" .Values.runners.cache.s3CacheInsecure | quote }}

3、添加 helm 仓库

helm repo add gitlab https://charts.gitlab.io

4、创建namespace、等资源

kubectl create ns gitlab
---
apiVersion: v1
data:accesskey: bWluaW8=     #base64 编码secretkey:     #base64 编码
kind: Secret
metadata:name: minio-secrets
type: Opaque

5、启动 gitlab-runner

# 安装仓库中的chart
$ helm install   gitlab-runner   --namespace gitlab    -f values.yaml gitlab/gitlab-runner  
#安装本地的chart
helm install   gitlab-runner  ./   --namespace gitlab#更新配置--通过本地chart更新helm upgrade --install   gitlab-runner    ./gitlab-runner  --namespace gitlab #卸载
helm uninstall gitlab-runner --namespace gitlab

如果没有修改gitlabUrl,则会提示更新配置

#############################################################################################
## WARNING: You did not specify an gitlabUrl in your 'helm install' call.                  ##
#############################################################################################This deployment will be incomplete until you provide the URL that your
GitLab instance is reachable at:helm upgrade gitlab-runner \--set gitlabUrl=http://gitlab.your-domain.com,runnerRegistrationToken=your-registration-token \gitlab/gitlab-runner#也可以使用命令:helm upgrade 

参考

安装:https://docs.gitlab.com/runner/install/

https://docs.gitlab.com/runner/

执行器参数:https://docs.gitlab.com/runner/executors/kubernetes.html

cache secret : https://blog.csdn.net/xichenguan/article/details/101436883

gitlab runner配置(toml配置项):https://docs.gitlab.com/runner/configuration/advanced-configuration.html

gitlab CI/CD 文件变量

新的版本支持,比较旧的不支持。

但是可以通过base64 编解码来实现

echo $(cat ~/.kube/config | base64) | tr -d " "
deploy_k8s_job:image: registry.cn-hangzhou.aliyuncs.com/haoshuwei24/kubectl:1.16.6stage: deploy_k8stags:- k8s-runnerscript:- mkdir -p /etc/deploy- echo $kube_config |base64 -d > $KUBECONFIG- sed -i "s/IMAGE_TAG/$CI_PIPELINE_ID/g" deployment.yaml- cat deployment.yaml- kubectl apply -f deployment.yaml

缓存服务器

使用minio作为缓存服务器。配置如下:

  cache:## General settings## DEPRECATED: See https://docs.gitlab.com/runner/install/kubernetes.html#additional-configuration and https://docs.gitlab.com/runner/install/kubernetes.html#using-cache-with-configuration-templatecacheType: s3cachePath: "gitlab_runner"cacheShared: true## S3 settings## DEPRECATED: See https://docs.gitlab.com/runner/install/kubernetes.html#additional-configuration and https://docs.gitlab.com/runner/install/kubernetes.html#using-cache-with-configuration-templates3ServerAddress: s3.amazonaws.coms3BucketName: "gitlabrunner"          #Minio buckets3BucketLocation:        #minio时区。s3CacheInsecure: false   #是否在不安全模式。true:使用http;false使用https,不设置则默认为false。## S3 the name of the secret.secretName: minio-secrets     #minio 对应的secret

**注意:**很多博客或者什么资料,把s3CacheInsecure解释为是否使用https,正确的解释应该是是否在不安全模式。意思刚好相反。

最终的文件内容可以在/home/gitlabrunner/.gitlabrunner/config.toml 文件查看。值为false时不会出现在config.toml中

以上方式是废弃的方式,新的方式采用template。对应的template为_cache.yaml

runners:config: |[[runners]][runners.kubernetes]image = "ubuntu:16.04"[runners.cache]Type = "s3"Path = "gitlab_runner"Shared = true[runners.cache.s3]ServerAddress = "s3.amazonaws.com"BucketName = "gitlabrunner"BucketLocation = "eu-west-1"Insecure = true#AccessKey = "access"   #SecretKey = "secret123456"cache:secretName: minio-secrets

以上使用到了一个secret。通过以下语句创建secret 或者通过yaml创建。

kubectl create secret generic minio \
--from-literal=accesskey="access" \
--from-literal=secretkey="secret123456" -n gitlab

参考:https://docs.gitlab.com/runner/install/kubernetes.html#using-cache-with-configuration-template

K8S部署

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:name: miniofinalizers:- kubernetes.io/pvc-protection
spec:accessModes:- ReadWriteOnceresources:requests:storage: 5GistorageClassName: rook-cephfsvolumeMode: Filesystem---
apiVersion: v1
kind: Service
metadata:labels:app: minioname: miniospec:ports:- name: 9000-tcpport: 9000protocol: TCPtargetPort: 9000selector:app: miniosessionAffinity: Nonetype: ClusterIP---
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: minioname: miniospec:replicas: 1revisionHistoryLimit: 10selector:matchLabels:app: miniotemplate:metadata:labels:app: miniospec:containers:- image: minio/minio:RELEASE.2019-02-26T19-51-46ZimagePullPolicy: Alwaysenv:- name: MINIO_ACCESS_KEYvalue: minio- name: MINIO_SECRET_KEY  value: sssscommand:- minio- server- /dataname: minioports:- containerPort: 9000protocol: TCPterminationMessagePath: /dev/termination-logterminationMessagePolicy: FilevolumeMounts:- mountPath: /dataname: volume-datadnsPolicy: ClusterFirstrestartPolicy: AlwaysschedulerName: default-schedulerimagePullSecrets:- name: harbor-key   #注意docker 仓库 keysecurityContext: {}terminationGracePeriodSeconds: 30volumes:- name: volume-datapersistentVolumeClaim:claimName: minio
kubectl apply -f minio.single.yaml -n gitlab

docker镜像

maven

maven:3.6.3-openjdk-8: https://registry.hub.docker.com/_/maven

maven的setting.xml 可以通过configmap解决,(没验证过)

        [[runners.kubernetes.volumes.config_map]]name = "gitlab-runner-maven"mount_path = "/usr/share/maven/configmap/"

也可以通过mount path解决(见前面内容)

[[runners.kubernetes.volumes.host_path]]

docker

docker :https://registry.hub.docker.com/_/docker 。版本:(20.10.2)

需要在/root/.docker/config.json 中增加auth 凭据。

FROM docker
MAINTAINER lihz
ADD  config.json  /root/.docker/config.json

config.json

主要是增加访问凭据

{"auths": {"192.168.1.X": {"auth": "?????????????"},"docker-registry-default.cloud.com": {"auth": "YWRtaW46TEpWUUhYX2g3MGFabGYtUlJLdDc1RlBmRW5LeFRXXXXXXXXXXX"}},"experimental": true
}
安装docker buildx

如果需要支持多平台打包,则需要安装docker buildx (github.com/docker/buildx v0.10.5 86bdced),下载

wget -O docker-buildx  https://github.com/docker/buildx/releases/download/v0.10.5/buildx-v0.10.5.linux-amd64
mkdir -p /usr/libexec/docker/cli-plugins/docker-buildx
mv docker-buildx /usr/libexec/docker/cli-plugins/docker-buildx
chmod +x /usr/libexec/docker/cli-plugins/docker-buildxdocker buildx version

docker客户端需要开启实验室功能

$ cat ~/.docker/config.json
{"experimental": "enabled"
}# 确认实验室性能开启。
$ docker version

构造docker 打包的镜像,包含buildx

FROM docker:20.10.2
MAINTAINER lihz
ADD  config.json  /root/.docker/config.json
RUN mkdir -p /usr/libexec/docker/cli-plugins/  && mkdir -p /etc/docker
COPY docker-buildx /usr/libexec/docker/cli-plugins/docker-buildx
COPY daemon.json buildkitd.toml  /etc/docker/
RUN chmod +x /usr/libexec/docker/cli-plugins/docker-buildx
ENV IMAGE_BUILDKIT=192.168.1.X/GROUP/buildkit:buildx-stable-1
  • buildkitd.toml
debug = true
# insecure-entitlements allows insecure entitlements, disabled by default.
insecure-entitlements = [ "network.host", "security.insecure" ]# 如果不加这些,就会默认使用https请求。
# optionally mirror configuration can be done by defining it as a registry.
[registry."192.168.1.XX"]http = trueinsecure = true
  • 打包

minio

minio/minio:RELEASE.2019-02-26T19-51-46Z : https://registry.hub.docker.com/r/minio/minio

node

node:14.7.0 : https://registry.hub.docker.com/_/node

FROM node:14.7.0
RUN npm config set registry https://registry.npm.taobao.org

helm

alpine/helm:3.5.0:https://registry.hub.docker.com/r/alpine/helm

Dockerfile:

From 192.168.1.X/GROUP/helm:3.5.0
#增加K8S的凭据
ADD config /etc/deploy/config

config:

K8S的凭据

apiVersion: v1
clusters:
- cluster:certificate-authority-data: ........server: https://lb.kubesphere.local:6443name: cluster.local
contexts:
- context:cluster: cluster.localnamespace: demouser: kubernetes-adminname: ctx-demo
- context:cluster: cluster.localuser: kubernetes-adminname: kubernetes-admin@cluster.local
current-context: ctx-demo
kind: Config
preferences: {}
users:
- name: kubernetes-adminuser:client-certificate-data: ..........client-key-data: ..........

kubectl

将业务镜像部署到k8s上

sonar-scanner-cli

用于扫描前端代码。参考:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/

sonarsource/sonar-scanner-cli:4.6:https://registry.hub.docker.com/r/sonarsource/sonar-scanner-cli

Dockerfile:

From sonarsource/sonar-scanner-cli:4.6
#登录凭据
ENV SONAR_HOST_URL=http://192.168.1.XXX:9000 SONAR_LOGIN=a34d8e475e19faa108404fec82cd058493XXXXXX
ENTRYPOINT [""]

绑定目录:

docker run --rm -v $PWD:/usr/src

问题

https://docs.gitlab.com/ee/ci/docker/using_docker_build.html

清除cache

cache是没有过期时间的,而且每一次新的push触发的pipeline,都会重新生成cache,重新生成的cache的名字为“-”,其中num是随着push数量递增的。如果不去清除cache,cache会永久保留在Runner上,日积月累会填满存储空间的,因此最好隔一段时间进行一次清除,清除方法请参考https://docs.gitlab.com/ee/ci/caching/#clearing-the-cache,或者使用clear_volumes.sh 这个简单脚本来处理它, 清除cache的原理是将相关的volume移除,当然,docker也有自带的清除命令,推荐将docker system prune -f --volumes加入到定时任务中。

helm执行时无权限

Executing "step_script" stage of the job script
$ sed -i "s/IMAGE_TAG/$DOCKER_TAG/g;s/CI_PROJECT_NAME/$CI_PROJECT_NAME/g;s/SVC_PORT/${SVC_PORT}/g;" ${MODULE_NAME}/src/main/charts/values.yaml
$ sed -i "s/CI_PROJECT_NAME/$CI_PROJECT_NAME/g" ${MODULE_NAME}/src/main/charts/Chart.yaml
$ helm upgrade --install $CI_PROJECT_NAME ${MODULE_NAME}/src/main/charts -n $K8S_NS
Release "sample" does not exist. Installing it now.
Error: rendered manifests contain a resource that already exists. Unable to continue with install: could not get information about the resource: deployments.apps "sample" is forbidden: User "system:serviceaccount:gitlab:gitlab-runner-gitlab-runner" cannot get resource "deployments" in API group "apps" in the namespace "release"
ERROR: Job failed: command terminated with exit code 1

是由于 gitlab runner的权限问题

执行以下语句:

kubectl create clusterrolebinding gitlab-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts

下载镜像失败

Job failed (system failure): prepare environment: image pull failed

临时解决方法,在K8S节点 docker pull <IMAGE> 把镜像下载下来

根本性解决:

打开以下选项,并设置docker仓库的secret。

## Specifying ImagePullSecrets on a Pod (设置在gitlab-runner中)
## Kubernetes supports specifying container image registry keys on a Pod.
## ref: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
##
imagePullSecrets:- name: "harbor-key"## For RBAC support:
rbac:create: true## Specify one or more imagePullSecrets used for pulling the runner image#### ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account##imagePullSecrets: ["harbor-key"]## Configuration for the Pods that the runner launches for each new job
##
runners:## Specify one or more imagePullSecrets  (用于拉取image)#### ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#### DEPRECATED: See https://docs.gitlab.com/runner/install/kubernetes.html#additional-configurationimagePullSecrets: ["harbor-key"]## Run all containers with the privileged flag enabled## This will allow the docker:dind image to run if you need to run Docker## commands. Please read the docs before turning this on:## ref: https://docs.gitlab.com/runner/executors/kubernetes.html#using-dockerdind#### DEPRECATED: See https://docs.gitlab.com/runner/install/kubernetes.html#additional-configuration#privileged: true   

下载gitlab-runner镜像失败

在K8S部署环境中,会下载以下镜像,可能会导致失败,最好重新tag在本地仓库

# helm配置(helpers.tpl中)为:
printf "192.168.1.X/GROUP/gitlab-runner:alpine-%s" $appVersion
#tag为:
192.168.1.x/GROUP/gitlab-runner:alpine-v13.8.0# 最后一部分是 CI_RUNNER_VERSION,对应的版本的 sha256ID,参考:https://gitlab.com/gitlab-org/gitlab-runner/-/tags?sort=updated_desc&search=13.8.0
gitlab/gitlab-runner-helper:x86_64-775dd39d
docker tag gitlab/gitlab-runner-helper:x86_64-775dd39d   192.168.1.X/GROUP/gitlab-runner-helper:x86_64-775dd39d
docker push 192.168.1.X/GROUP/gitlab-runner-helper:x86_64-775dd39d

修改配置:

      [[runners]][runners.kubernetes]image = "ubuntu:22.04"# 由上文可知helper_image = "192.168.1.X/GROUP/gitlab-runner-helper:x86_64-775dd39d"

Gitlab-ci中使用

java

variables:DOCKER_TAG: "3.0.0-RELEASE"MODULE_NAME: "project-biz"SONAR_PROJECT_KEY: "project"stages:- package- docker_buildmvn_build_job:image: ${DEPOSITORY}/mavenstage: packagescript:- mvn clean verify sonar:sonar -DskipTests -DskipDocker -Dsonar.projectVersion=master -Dsonar.projectKey=$SONAR_PROJECT_KEY  -Dsonar.host.url=${SONAR_URL} -Dsonar.login=${SONAR_TOKEN}- mvn deploy -B -DskipTests -DskipDockerartifacts:paths:- ${MODULE_NAME}/target/*.jaronly:- master- /^.*-dev$/when: manualmvn_build_release_job:image: ${DEPOSITORY}/mavenstage: packagescript:- mvn deploy -B -DskipTests -DskipDockerartifacts:paths:- ${MODULE_NAME}/target/*.jaronly:- /^.*-RELEASE$/- /^.*-release/- /^.*-hotfix$/docker_build_release_job:image: ${DEPOSITORY}/dockerstage: docker_buildscript:- cp ${MODULE_NAME}/target/*.jar ${MODULE_NAME}/src/main/docker- docker build -t ${DEPOSITORY}/${MODULE_NAME}:${DOCKER_TAG} ${MODULE_NAME}/src/main/docker- docker push ${DEPOSITORY}/${MODULE_NAME}:${DOCKER_TAG}only:- /^.*-RELEASE$/- /^.*-release/

前端

variables:DOCKER_TAG: "dev"MODULE_NAME: "biz-web"stages:- package- docker_build- deploy npm_build_job:image: maven:3.6.3-openjdk-8stage: packagecache:paths:- node_modules/artifacts:paths:- distscript:- npm install- npm run buildonly:- master- /^.*-dev$/when: manual  docker_build_job:image: dockerstage: docker_buildscript:- docker build -t ${DEPOSITORY}/${MODULE_NAME}:${DOCKER_TAG} ./dependencies:- npm_build_jobonly:- master- /^.*-dev$/when: manualdocker_build_release_job:image: dockerstage: docker_buildscript:- docker build -t ${DEPOSITORY}/${MODULE_NAME}:${DOCKER_TAG} ./dependencies:- npm_build_job  only:- /^.*-RELEASE$/- /^.*-release/- /^.*-hotfix$/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/diannao/84522.shtml
繁体地址,请注明出处:http://hk.pswp.cn/diannao/84522.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在 Ubuntu linux系统中设置时区的方案

查看时区 在 Ubuntu 系统中&#xff0c;可以通过以下方法查看当前时区设置&#xff1a; 1. 使用 timedatectl 命令&#xff08;推荐&#xff09; 在终端运行以下命令&#xff1a; timedatectl输出示例&#xff1a; Local time: Sun 2025-05-25 10:30:00 CST Universal t…

YOLOv8模型剪枝笔记(DepGraph和Network Slimming网络瘦身)

文章目录 一、DepGraph剪枝(1)项目准备1)剪枝基础知识2)DepGraph剪枝论文解读12)DepGraph剪枝论文解读23)YOLO目标检测系列发展史4)YOLO网络架构(2)项目实战(YOLOv8应用DepGraph剪枝+finetune)1)安装软件环境(基础环境、Pytorch、YOLOv8)Windows1)安装软件环境(…

MySQL:11_事务

事务 一.CURD不加控制&#xff0c;会有什么问题&#xff1f; 二.什么是事务&#xff1f; 事务就是一组DML语句组成&#xff0c;这些语句在逻辑上存在相关性&#xff0c;这一组DML语句要么全部成功&#xff0c;要么全部失败&#xff0c;是一个整体。MySQL提供一种机制&#xf…

【notepad++如何设置成中文界面呢?】

“Notepad”是一款非常强大的文本编辑软件&#xff0c;将其界面设置成中文的方法如下&#xff1a; 一、工具&#xff0f;原料&#xff1a; 华为 Matebook 15、Windows 10、Notepad 8.4.6。 二 、具体步骤&#xff1a; 1、找到任意一个文本文件&#xff0c;比如 txt 格式的文…

职坐标嵌入式MCU/DSP与RTOS开发精讲

嵌入式系统开发作为现代智能设备与工业控制的核心技术领域&#xff0c;其架构设计与实现逻辑直接影响系统性能与可靠性。本课程以嵌入式系统架构为切入点&#xff0c;系统化梳理从硬件选型到软件调度的全链路知识体系&#xff0c;重点聚焦微控制器&#xff08;MCU&#xff09;与…

双深度Q网络(Double DQN)基础解析与python实例:训练稳定倒立摆

目录 1. 前言 2. Double DQN的核心思想 3. Double DQN 实例&#xff1a;倒立摆 4. Double DQN的关键改进点 5. 双重网络更新策略 6. 总结 1. 前言 在强化学习领域&#xff0c;深度Q网络&#xff08;DQN&#xff09;开启了利用深度学习解决复杂决策问题的新篇章。然而&am…

使用KubeKey快速部署k8s v1.31.8集群

实战环境涉及软件版本信息&#xff1a; 使用kubekey部署k8s 1. 操作系统基础配置 设置主机名、DNS解析、时钟同步、防火墙关闭、ssh免密登录等等系统基本设置 dnf install -y curl socat conntrack ebtables ipset ipvsadm 2. 安装部署 K8s 2.1 下载 KubeKey ###地址 https…

SQL:窗口函数(Window Functions)

目录 什么是窗口函数&#xff1f; 基本语法结构 为什么要用窗口函数&#xff1f; 常见的窗口函数分类 1️⃣ 排名类函数 2️⃣ 聚合类函数&#xff08;不影响原始行&#xff09; 3️⃣ 值访问函数 窗口范围说明&#xff08;ROWS / RANGE&#xff09; 什么是窗口函数&a…

相机内参 opencv

视场角定相机内参 import numpy as np import cv2 import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3Ddef calculate_camera_intrinsics(image_width640, image_height480, fov55, is_horizontalTrue):"""计算相机内参矩阵参数:image_w…

MATLAB 各个工具箱 功能说明

​ 想必大家在安装MATLAB时&#xff0c;或多或少会疑惑应该安装哪些工具箱。笔者遇到了两种情况——只安装了MATLAB主程序&#xff0c;老师让用MATLAB的时候却发现没有安装对应安装包&#xff1b;第二次安装学聪明了&#xff0c;全选安装&#xff0c;嗯……占用了20多个G。 ​…

学习日记-day14-5.23

完成目标&#xff1a; 学习java下半段课程 知识点&#xff1a; 1.多态转型 知识点 核心内容 重点 多态转型 向上转型&#xff08;父类引用指向子类对象&#xff09; 与向下转型&#xff08;强制类型转换&#xff09;的机制与区别 向上转型自动完成&#xff0c;向下转型需…

【编程语言】【Java】一篇文章学习java,复习完善知识体系

第一章 Java基础 1.1 变量与数据类型 1.1.1 基本数据类型 1.1.1.1 整数类型&#xff08;byte、short、int、long&#xff09; 在 Java 中&#xff0c;整数类型用于表示没有小数部分的数字&#xff0c;不同的整数类型有不同的取值范围和占用的存储空间&#xff1a; byte&am…

汇量科技前端面试题及参考答案

数组去重的方法有哪些&#xff1f; 在 JavaScript 中&#xff0c;数组去重是一个常见的操作&#xff0c;有多种方法可以实现这一目标。每种方法都有其适用场景和性能特点&#xff0c;下面将详细介绍几种主要的去重方法。 使用 Set 数据结构 Set 是 ES6 引入的一种新数据结构&a…

Git实战演练,模拟日常使用,快速掌握命令

01 引言 上一期借助Idea&#xff0c;完成了Git仓库的建立、配置、代码提交等操作&#xff0c;初步入门了Git的使用。然而日常开发中经常面临各种各样的问题&#xff0c;入门级的命令远远不够使用。 这一期&#xff0c;我们将展开介绍Git的日常处理命令&#xff0c;解决日常问…

wordpress主题开发中常用的12个模板文件

在WordPress主题开发中&#xff0c;有多种常用的模板文件&#xff0c;它们负责控制网站不同部分的显示内容和布局&#xff0c;以下是一些常见的模板文件&#xff1a; 1.index.php 这是WordPress主题的核心模板文件。当没有其他更具体的模板文件匹配当前页面时&#xff0c;Wor…

数据库blog5_数据库软件架构介绍(以Mysql为例)

&#x1f33f;软件的架构 &#x1f342;分类 软件架构总结为两种主要类型&#xff1a;一体式架构和分布式架构 ● 一体化架构 一体式架构是一种将所有功能集成到一个单一的、不可分割的应用程序中的架构模式。这种架构通常是一个大型的、复杂的单一应用程序&#xff0c;包含所…

离线服务器算法部署环境配置

本文将详细记录我如何为一台全新的离线服务器配置必要的运行环境&#xff0c;包括基础编译工具、NVIDIA显卡驱动以及NVIDIA-Docker&#xff0c;以便顺利部署深度学习算法。 前提条件&#xff1a; 目标离线服务器已安装操作系统&#xff08;本文以Ubuntu 18.04为例&#xff09…

chromedp -—— 基于 go 的自动化操作浏览器库

chromedp chromedp 是一个用于 Chrome 浏览器的自动化测试工具&#xff0c;基于 Go 语言开发&#xff0c;专门用于控制和操作 Chrome 浏览器实例。 chromedp 安装 go get -u github.com/chromedp/chromedp基于chromedp 实现的的简易学习通刷课系统 目前实现的功能&#xff…

高级特性实战:死信队列、延迟队列与优先级队列(三)

四、优先级队列&#xff1a;优先处理重要任务 4.1 优先级队列概念解析 优先级队列&#xff08;Priority Queue&#xff09;是一种特殊的队列数据结构&#xff0c;它与普通队列的主要区别在于&#xff0c;普通队列遵循先进先出&#xff08;FIFO&#xff09;的原则&#xff0c;…

python打卡day34

GPU训练及类的call方法 知识点回归&#xff1a; CPU性能的查看&#xff1a;看架构代际、核心数、线程数GPU性能的查看&#xff1a;看显存、看级别、看架构代际GPU训练的方法&#xff1a;数据和模型移动到GPU device上类的call方法&#xff1a;为什么定义前向传播时可以直接写作…