linux上构建任意版本的rocketmq多架构x86 arm镜像——筑梦之路

现状

目前市面上和官方均只有rocketmq x86架构下的docker镜像,而随着国产化和信创适配的需求越来越多,显然现有的x86架构下的docker镜像不能满足多样化的需求,因此我们需要根据官方发布的版本制作满足需求的多架构镜像,以在不同cpu架构下部署使用。

 rocketmq官方网站:RocketMQ · 官方网站 | RocketMQ

关于rocketmq的介绍请阅读官方文档,这里就不做过多赘述。

前提条件

1. 构建镜像的机器需要能访问互联网,拥有良好的网络环境

2. 构建之前请搭建好私有仓库,比如harbor、registry这种,以便将多架构镜像推送到镜像仓库中

3. 需要安装docker,版本要求19.03以上,并支持buildx插件

准备工作

 1. 编写Dockerfile文件

# 多阶段构建方式
cat  Dockerfile-centos################################################################################
# Build stage 1 `builder`:
# Download and extract RocketMQ
################################################################################
FROM eclipse-temurin:8-jdk-centos7 AS builderARG versionRUN set -eux \&& yum -y update \&& yum -y install curl gnupg unzip \&& yum clean all -yRUN curl -L https://archive.apache.org/dist/rocketmq/${version}/rocketmq-all-${version}-bin-release.zip -o rocketmq.zip \&& curl -L https://archive.apache.org/dist/rocketmq/${version}/rocketmq-all-${version}-bin-release.zip.asc -o rocketmq.zip.asc \&& curl -L https://www.apache.org/dist/rocketmq/KEYS -o KEYS \&& gpg --import KEYS \&& gpg --batch --verify rocketmq.zip.asc rocketmq.zipRUN unzip rocketmq.zip \&& mkdir -p /tmp/rocketmq-${version} \&& mv rocketmq*/* /tmp/rocketmq-${version}################################################################################
# Build stage 2:
# Make the actual RocketMQ docker image
################################################################################
FROM eclipse-temurin:8-jdk-centos7ARG user=rocketmq
ARG group=rocketmq
ARG uid=3000
ARG gid=3000ARG version# Rocketmq version
ENV ROCKETMQ_VERSION ${version}# Rocketmq home
ENV ROCKETMQ_HOME  /home/rocketmq/rocketmq-${ROCKETMQ_VERSION}# expose namesrv port
EXPOSE 9876# expose broker ports
EXPOSE 10909 10911 10912# RocketMQ is run with user `rocketmq`, uid = 3000
# If you bind mount a volume from the host or a data container,
# ensure you use the same uid
RUN groupadd -g ${gid} ${group} \&& useradd -l -u ${uid} -g ${gid} -m -s /bin/bash ${user} \&& yum -y update \&& yum -y install less openssl which bash wget curl tzdata \&& yum clean all -y && rm -rf /var/cache/yum # Copy customized scripts
COPY scripts/ ${ROCKETMQ_HOME}/bin/# Copy RocketMQ artifact from builder
COPY --from=builder --chown=${uid}:${gid} /tmp/rocketmq-${version}/ ${ROCKETMQ_HOME}# Override customized scripts for namesrv
# Override customized scripts for broker
# Export Java options
# Add ${JAVA_HOME}/lib/ext as java.ext.dirs
RUN mv ${ROCKETMQ_HOME}/bin/runserver-customize.sh ${ROCKETMQ_HOME}/bin/runserver.sh \&& mv ${ROCKETMQ_HOME}/bin/runbroker-customize.sh ${ROCKETMQ_HOME}/bin/runbroker.sh \&& chmod -R a+x ${ROCKETMQ_HOME}/bin/ \&& export JAVA_OPT=" -Duser.home=/opt" \&& sed -i 's/${JAVA_HOME}\/jre\/lib\/ext/${JAVA_HOME}\/jre\/lib\/ext:${JAVA_HOME}\/lib\/ext/' ${ROCKETMQ_HOME}/bin/tools.sh \&& chown -R ${uid}:${gid} ${ROCKETMQ_HOME} \&& localedef -i en_US -f UTF-8 en_US.UTF-8 \&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \&& export LANG=C.UTF-8USER ${user}WORKDIR ${ROCKETMQ_HOME}/binENTRYPOINT ["./docker-entrypoint.sh"]
# Dummy overridable parameter parsed by entrypoint
CMD ["dummy"]

2. 编写需要的脚本文件

# 脚本文件docker-entrypoint.sh
cat  docker-entrypoint.sh#!/bin/bash
set -e# Allow user specify custom CMD, maybe run /bin/bash to check the image
if [[ "$1" == "nameserver" || "${NODE_ROLE}" == "nameserver" ]]; thenshiftexec ./mqnamesrv "${@}"
elif [[ "$1" == "broker" || "${NODE_ROLE}" == "broker" ]]; thenshiftexec ./mqbroker "${@}"
elif [[ "$1" == "controller" || "${NODE_ROLE}" == "controller" ]]; thenshiftexec ./mqcontroller "${@}"
else# Run whatever command the user wantsexec "$@"
fi
# 脚本文件 runbroker-customize.sh#!/bin/bash# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#===========================================================================================
# Java Environment Setting
#===========================================================================================
error_exit ()
{echo "ERROR: $1 !!"exit 1
}find_java_home()
{case "`uname`" inDarwin)JAVA_HOME=$(/usr/libexec/java_home);;*)JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))));;esac
}find_java_home[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"export JAVA_HOME
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}#===========================================================================================
# JVM Configuration
#===========================================================================================
calculate_heap_sizes()
{case "`uname`" inLinux)system_memory_in_mb=`free -m| sed -n '2p' | awk '{print $2}'`system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`;;FreeBSD)system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`;;SunOS)system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`system_cpu_cores=`psrinfo | wc -l`;;Darwin)system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`;;*)# assume reasonable defaults for e.g. a modern desktop or# cheap serversystem_memory_in_mb="2048"system_cpu_cores="2";;esac# some systems like the raspberry pi don't report cores, use at least 1if [ "$system_cpu_cores" -lt "1" ]thensystem_cpu_cores="1"fi# set max heap size based on the following# max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))# calculate 1/2 ram and cap to 1024MB# calculate 1/4 ram and cap to 8192MB# pick the maxhalf_system_memory_in_mb=`expr $system_memory_in_mb / 2`quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2`if [ "$half_system_memory_in_mb" -gt "1024" ]thenhalf_system_memory_in_mb="1024"fiif [ "$quarter_system_memory_in_mb" -gt "8192" ]thenquarter_system_memory_in_mb="8192"fiif [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ]thenmax_heap_size_in_mb="$half_system_memory_in_mb"elsemax_heap_size_in_mb="$quarter_system_memory_in_mb"fiMAX_HEAP_SIZE="${max_heap_size_in_mb}M"# Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size)max_sensible_yg_per_core_in_mb="100"max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores`desired_yg_in_mb=`expr $max_heap_size_in_mb / 4`if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ]thenHEAP_NEWSIZE="${max_sensible_yg_in_mb}M"elseHEAP_NEWSIZE="${desired_yg_in_mb}M"fi
}calculate_heap_sizes# Dynamically calculate parameters, for reference.
Xms=$MAX_HEAP_SIZE
Xmx=$MAX_HEAP_SIZE
Xmn=$HEAP_NEWSIZE
MaxDirectMemorySize=$MAX_HEAP_SIZE
# Set for `JAVA_OPT`.
JAVA_OPT="${JAVA_OPT} -server -Xms${Xms} -Xmx${Xmx} -Xmn${Xmn}"
JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/mq_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=${MaxDirectMemorySize}"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"numactl --interleave=all pwd > /dev/null 2>&1
if [ $? -eq 0 ]
thenif [ -z "$RMQ_NUMA_NODE" ] ; thennumactl --interleave=all $JAVA ${JAVA_OPT} $@elsenumactl --cpunodebind=$RMQ_NUMA_NODE --membind=$RMQ_NUMA_NODE $JAVA ${JAVA_OPT} $@fi
else$JAVA ${JAVA_OPT} $@
fi
# 脚本文件 runserver-customize.sh#!/bin/bash# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#===========================================================================================
# Java Environment Setting
#===========================================================================================
error_exit ()
{echo "ERROR: $1 !!"exit 1
}find_java_home()
{case "`uname`" inDarwin)JAVA_HOME=$(/usr/libexec/java_home);;*)JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))));;esac
}find_java_home[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"export JAVA_HOME
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}#===========================================================================================
# JVM Configuration
#===========================================================================================
calculate_heap_sizes()
{case "`uname`" inLinux)system_memory_in_mb=`free -m| sed -n '2p' | awk '{print $2}'`system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`;;FreeBSD)system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`;;SunOS)system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`system_cpu_cores=`psrinfo | wc -l`;;Darwin)system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`;;*)# assume reasonable defaults for e.g. a modern desktop or# cheap serversystem_memory_in_mb="2048"system_cpu_cores="2";;esac# some systems like the raspberry pi don't report cores, use at least 1if [ "$system_cpu_cores" -lt "1" ]thensystem_cpu_cores="1"fi# set max heap size based on the following# max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB))# calculate 1/2 ram and cap to 1024MB# calculate 1/4 ram and cap to 8192MB# pick the maxhalf_system_memory_in_mb=`expr $system_memory_in_mb / 2`quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2`if [ "$half_system_memory_in_mb" -gt "1024" ]thenhalf_system_memory_in_mb="1024"fiif [ "$quarter_system_memory_in_mb" -gt "8192" ]thenquarter_system_memory_in_mb="8192"fiif [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ]thenmax_heap_size_in_mb="$half_system_memory_in_mb"elsemax_heap_size_in_mb="$quarter_system_memory_in_mb"fiMAX_HEAP_SIZE="${max_heap_size_in_mb}M"# Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size)max_sensible_yg_per_core_in_mb="100"max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores`desired_yg_in_mb=`expr $max_heap_size_in_mb / 4`if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ]thenHEAP_NEWSIZE="${max_sensible_yg_in_mb}M"elseHEAP_NEWSIZE="${desired_yg_in_mb}M"fi
}calculate_heap_sizes# Dynamically calculate parameters, for reference.
Xms=$MAX_HEAP_SIZE
Xmx=$MAX_HEAP_SIZE
Xmn=$HEAP_NEWSIZE
# Set for `JAVA_OPT`.
JAVA_OPT="${JAVA_OPT} -server -Xms${Xms} -Xmx${Xmx} -Xmn${Xmn}"
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8  -XX:-UseParNewGC"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX:+PrintGCDetails"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT}  -XX:-UseLargePages"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"$JAVA ${JAVA_OPT} $@

编写构建脚本build-image.sh

# 构建镜像的脚本#!/usr/bin/env bashcheckVersion() {echo "Version = $1"echo $1 |grep -E "^[0-9]+\.[0-9]+\.[0-9]+" > /dev/nullif [ $? = 0 ]; thenreturn 1fiecho "Version $1 illegal, it should be X.X.X format(e.g. 4.5.0), please check released versions in 'https://archive.apache.org/dist/rocketmq/'"exit -1
}if [ $# -lt 2 ]; thenecho -e "Usage: sh $0 Version BaseImage"exit -1
fiROCKETMQ_VERSION=$1BASE_IMAGE=centoscheckVersion $ROCKETMQ_VERSION# Build rocketmq
case "${BASE_IMAGE}" incentos)docker run --privileged --rm harbor.codemiracle.com.cn/baseapp/binfmt:latest --install alldocker buildx create --use --name=mybuilder-rocketmq --driver docker-container --driver-opt image=harbor.codemiracle.com.cn/baseapp/buildkit:masterdocker buildx build --no-cache -f Dockerfile-centos --platform=linux/amd64,linux/arm64 -t harbor.codemiracle.com.cn/baseapp/rocketmq:${ROCKETMQ_VERSION} --build-arg version=${ROCKETMQ_VERSION} . --pushdocker buildx rm mybuilder-rocketmq;;*)echo "${BASE_IMAGE} is not supported, supported base images: centos"exit -1;;
esac

如何构建

# 如何使用脚本构建呢?1. 创建相关目录,将文件放到对应目录下mkdir  scriptsmv docker-entrypoint.sh scripts/mv runbroker-customize.sh scripts/mv runserver-customize.sh scripts/2. 登陆harbordocker login harbor.codemiracle.com.cn3. 执行构建脚本sh  build-image.sh [rocketmq版本号]eg: sh  build-image.sh 4.5.2

参考资料:

GitHub - apache/rocketmq-docker: Apache RocketMQ Docker

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

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

相关文章

Ubuntu的Python从2.x升级到3.x

我的Ubuntu系统默认是2.7,我想升级为3.5 升级python3.5 下载python sudo apt-get install python3查看 刚才下载的Python程序被安装在usr/local/lib/python3.5 中 cd usr/local/lib备份一下 sudo cp /usr/bin/python /usr/bin/python_bak删除python的旧关联 sudo rm -rf py…

Linux网络编程系列之网络编程基础

Linux网络编程系列 (够吃,管饱) 1、Linux网络编程系列之网络编程基础 2、Linux网络编程系列之TCP协议编程 3、Linux网络编程系列之UDP协议编程 4、Linux网络编程系列之UDP广播 5、Linux网络编程系列之UDP组播 6、Linux网络编程系列之服务器编…

如何降低海康、大华等网络摄像头调用的高延迟问题(二)

目录 1.RTSP介绍 2.解决办法1 3.解决办法2 1.RTSP介绍 RTSP(Real-time Streaming Protocol)是一种用于实时流媒体传输的网络协议。它被设计用于在服务器和客户端之间传输音频、视频以及其他流媒体数据。 RTSP协议允许客户端通过与服务器建立RTSP会话…

Easysearch压缩模式深度比较:ZSTD+source_reuse的优势分析

引言 在使用 Easysearch 时,如何在存储和查询性能之间找到平衡是一个常见的挑战。Easysearch 具备多种压缩模式,各有千秋。本文将重点探讨一种特别的压缩模式:zstd source_reuse,我们最近重新优化了 source_reuse,使得它在吞吐量…

【linux】日志和journalctl 管理查看日志

目录 既看即用 简略介绍 linux的日志类型 系统日志 介绍 区别的简单说明 区别的详细说明 journalctl是什么?(查看系统日志的工具) 详细内容 linux的日志类型 systemd日志(systemd-journald) 放在哪个目录 …

Linux系统编程详解

Linux 多线程编程 什么是线程? 与线程类似,线程是允许应用程序并发执行多个任务的一种机制 线程是轻量级的进程(LWP:Light Weight Process),在 Linux 环境下线程的本 质仍是进程。 一个进程可以包含多个线…

D. Divide and Equalize--Codeforces Round 903 (Div. 3)

D. Divide and Equalize 题意:让一组数中的一个数除以一个因子,一个数除以一个因子,假如经过若干次操作后能够使数组所有数相等,那么输出YES,否则输出NO。 分析:乘除因子,那么实际上就是因子的…

[ROS2系列] ubuntu 20.04测试rtabmap 3D建图(二)

接上文我们继续 如果我们要在仿真环境中进行测试&#xff0c;需要将摄像头配置成功。 一、配置位置 sudo vim /opt/ros/foxy/share/turtlebot3_gazebo/models/turtlebot3_waffle/model.sdf 二、修改 <joint name"camera_rgb_optical_joint" type"fixed&…

【Rust笔记】Rust与Java交互-JNI模块编写-实践总结

近期工作中有Rust和Java互相调用需求&#xff0c;这篇文章主要介绍如何用Rust通过JNI和Java进行交互&#xff0c;还有记录一下开发过程中遇到的一些坑。 JNI简单来说是一套Java与其他语言互相调用的标准&#xff0c;主要是C语言&#xff0c;官方也提供了基于C的C接口。 既然是C…

介绍6种解决电脑找不到vcomp140.dll,无法继续执行代码的方法。

在编程和软件开发领域&#xff0c;我们经常会遇到各种错误和问题。其中&#xff0c;找不到vcomp140.dll文件导致无法继续执行代码是一个非常常见的问题。这个问题可能会影响到软件的正常运行&#xff0c;甚至导致整个项目延期。因此&#xff0c;我们需要找到解决方案来解决这个…

【07】基础知识:React中的事件处理

React 中 通过 onXxx 属性指定事件处理函数&#xff08;注意大小写&#xff09;&#xff0c;通过 event.target 得到发生事件的 DOM 元素对象 不要过度使用 ref &#xff08;比如&#xff0c;元素获取自身属性时&#xff0c;通过 event 对象&#xff0c;而不是 ref&#xff09…

如何导出带有材质的GLB模型?

1、为什么要使用 GLB 模型? GLB格式&#xff08;GLTF Binary&#xff09;是一种用于存储和传输3D模型及相关数据的文件格式&#xff0c;具有以下优点和作用&#xff1a; 统一性&#xff1a;GLB是一种开放标准的3D文件格式&#xff0c;由Khronos Group制定和维护。它融合了GL…

C# 图解教程 第5版 —— 第6章 方法

文章目录 6.1 方法的结构6.2 方法体内部的代码执行6.3 局部变量6.3.1 类型推断和 var 关键字6.3.2 嵌套块中的局部变量 6.4 局部常量6.5 控制流6.6 方法调用&#xff08;*&#xff09;6.7 返回值&#xff08;*&#xff09;6.8 返回语句和 void 方法6.9 局部函数6.10 参数&#…

Vue3 条件语句

条件判断 v-if 条件判断使用 v-if 指令&#xff0c;指令的表达式返回 true 时才会显示&#xff1a; <div id"app"><p v-if"seen">现在你看到我了</p> </div><script> const app {data() {return {seen: true /* 改为fal…

mysql面试题50:500台数据库,如何在最快时间之内重启

该文章专注于面试,面试只要回答关键点即可,不需要对框架有非常深入的回答,如果你想应付面试,是足够了,抓住关键点 面试官:500台db,如何在最快时间之内重启呢? 如果需要在最快时间内重启500台数据库,可以考虑采用并行化和自动化的方法来提高效率。比如: 编写自动化脚…

vh、vw、vmin、vmax

1、分别是什么&#xff1f; vh:指屏幕可见视窗的高&#xff0c; vw:指屏幕可见视窗的宽&#xff0c; vmin:vh和vw之间选较小的值&#xff0c; vmax:vh和vw之间选较大的值。 2、和百分比的区别 百分比时基于父元素的宽高&#xff0c;而vh\vw\vmin\vmax基于屏幕可见视图的宽…

protobuf 插件(option)使用

protobuf的option使用 一、需求 来源于工作中的一个需求&#xff1a;在传递message时需要对message中不同的字段进行不同的处理&#xff0c;而处理方式通过注释标注在了每个字段的定义后。 类似于有下面这样一个消息&#xff1a; 其中字段1是始终需要的&#xff0c;字段2和3…

Mall脚手架总结(五) —— SpringBoot整合MinIO实现文件管理

前言 在项目中我们经常有资源的上传和下载的功能需求&#xff0c;比如用户头像、产品图片、配置文件等等&#xff0c;大数据量的文件存储无疑需要更高性能的数据存储服务&#xff0c;对于无需对结构实现复杂查询的文件对象来说&#xff0c;对象存储服务无疑是一个较好的选择&am…

uniapp编译到小程序Component is not found in path “components/energy/illumination“

Component is not found in path "components/energy/illumination" 直接清除缓存重新编译

Ubuntu下怎么配置vsftpd

2023年10月12日&#xff0c;周四中午 目录 首先要添加一个系统用户然后设置这个系统用户的密码给新创建的系统用户创建主目录启动vsftpd服务查看vsftpd服务的状态打开外界访问vsftpd服务所需的端口获取服务器的IP地址大功告成 首先要添加一个系统用户 useradd 用户名然后设置…