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
英文地址,請注明出處:http://en.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;為什么定義前向傳播時可以直接寫作…