【RabbitMQ实战】3分钟在Linux上安装RabbitMQ

news2024/11/17 5:45:42

本节采用docker安装RabbitMQ。采用的是bitnami的镜像。Bitnami是一个提供各种流行应用的Docker镜像和软件包的公司。采用docker的方式3分钟就可以把我们想安装的程序运行起来,不得不说真的很方便啊,好了,开搞。使用前提:Linux虚拟机,安装好了docker环境。如果没有安装docker的话,请参考这里,先把docker先安装上。

一、搜索镜像

[root@localhost ~]# docker search rabbitmq
NAME                                      DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
rabbitmq                                  RabbitMQ is an open source multi-protocol me…   4887      [OK]       
bitnami/rabbitmq                          Bitnami Docker Image for RabbitMQ                103                  [OK]

这里我们选择bitname/rabbitmq

二、下载镜像

[root@localhost ~]# docker pull bitnami/rabbitmq
Using default tag: latest
latest: Pulling from bitnami/rabbitmq

三、把RabbitMQ镜像跑起来

docker run -d --name rabbitmq \
-e RABBITMQ_USERNAME=admin \
-e RABBITMQ_PASSWORD=admin \
-p 15672:15672 -p 5672:5672 -p 25672:25672 -p 61613:61613 -p 1883:1883 bitnami/rabbitmq

其中RABBITMQ_USERNAME是用户名
RABBITMQ_PASSWORD是密码
关于更多环境变量的说明,见文末

四、查看运行效果

看一下docker容器是否成功启动了,下面可以看到正在运行

[root@localhost ~]# docker ps | grep rabbit
0d5cb60e3a06   bitnami/rabbitmq       "/opt/bitnami/script…"   22 seconds ago   Up 20 seconds   4369/tcp, 5551-5552/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp, 0.0.0.0:25672->25672/tcp, :::25672->25672/tcp, 0.0.0.0:61613->61613/tcp, :::61613->61613/tcp, 15671/tcp   rabbitmq

输入地址访问一下控制台
http://192.168.56.201:15672/#/
用户名:admin,密码admin
登录成功
在这里插入图片描述
到此为止,我们就可以愉快地和RabbitMQ玩耍了

五、关于环境变量的说明

(来源于官网)

RABBITMQ_VHOST: RabbitMQ application vhost. Default: /
RABBITMQ_VHOSTS: List of additional virtual host (vhost), separated by space. E.g.: /shared /prioritized /tasks
RABBITMQ_USERNAME: RabbitMQ application username. Default: user
RABBITMQ_PASSWORD: RabbitMQ application password. Default: bitnami
RABBITMQ_SECURE_PASSWORD: Whether to set the RabbitMQ password securely. This is incompatible with loading external RabbitMQ definitions. Default: no
RABBITMQ_LOAD_DEFINITIONS: Whether to load external RabbitMQ definitions. This is incompatible with setting the RabbitMQ password securely. Default: no.
RABBITMQ_ERL_COOKIE: Erlang cookie to determine whether different nodes are allowed to communicate with each other.
RABBITMQ_NODE_TYPE: Node Type. Valid values: stats, queue-ram or queue-disc. Default: stats
RABBITMQ_NODE_NAME: Node name and host. E.g.: node@hostname or node (localhost won't work in cluster topology). Default rabbit@localhost. If using this variable, ensure that you specify a valid host name as the container wil fail to start otherwise. If using a fully qualified domain name, RABBITMQ_USE_LONGNAME needs to be set to true as well.
RABBITMQ_USE_LONGNAME: When set to true this will cause RabbitMQ to use fully qualified names to identify nodes. Default: false
RABBITMQ_FORCE_BOOT: Force a node to start even if it was not the last to shut down. Default: no
RABBITMQ_CLUSTER_NODE_NAME: Node name to cluster with. E.g.: clusternode@hostname
RABBITMQ_CLUSTER_PARTITION_HANDLING: Cluster partition recovery mechanism. Default: ignore
RABBITMQ_NODE_PORT_NUMBER: Node port. Default: 5672
RABBITMQ_NODE_SSL_PORT_NUMBER: RabbitMQ node port number for SSL connections. Default: 5671
RABBITMQ_SSL_CACERTFILE: Path to the RabbitMQ server SSL CA certificate file. No defaults.
RABBITMQ_SSL_CERTFILE: Path to the RabbitMQ server SSL certificate file. No defaults.
RABBITMQ_SSL_KEYFILE: Path to the RabbitMQ server SSL certificate key file. No defaults.
RABBITMQ_COMBINED_CERT_PATH: Cert- and keyfile are combined automatically into one combined file at this file path. If you are using a combined certificate anyways, mount it to the container and set this path to the mounted file. Default: /tmp/rabbitmq_combined_keys.pem
RABBITMQ_SSL_DEPTH: Maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid certification path. No defaults.
RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT: Whether to reject TLS connections if client fails to provide a certificate. Default: verify_none
RABBITMQ_SSL_VERIFY: Whether to enable peer SSL certificate verification. Default: no
RABBITMQ_PLUGINS: Comma, semi-colon or space separated list of plugins to enable during the initialization. No defaults.
RABBITMQ_COMMUNITY_PLUGINS: Comma, semi-colon or space separated list of URLs where to download custom plugins during the initialization. No defaults.
Management server configuration
RABBITMQ_MANAGEMENT_BIND_IP: RabbitMQ management server bind IP address. Default: 0.0.0.0
RABBITMQ_MANAGEMENT_PORT_NUMBER: RabbitMQ management server port number. Default: 15672
RABBITMQ_MANAGEMENT_SSL_PORT_NUMBER: RabbitMQ management server port number for SSL/TLS connections. No defaults.
RABBITMQ_MANAGEMENT_SSL_CACERTFILE: Path to the RabbitMQ management server SSL CA certificate file. No defaults.
RABBITMQ_MANAGEMENT_SSL_CERTFILE: Path to the RabbitMQ management server SSL certificate file. No defaults.
RABBITMQ_MANAGEMENT_SSL_KEYFILE: Path to the RabbitMQ management server SSL certificate key file. No defaults.
RABBITMQ_MANAGEMENT_SSL_DEPTH: Maximum number of non-self-issued intermediate certificates that may follow the peer certificate in a valid certification path, for the RabbitMQ management server. No defaults.
RABBITMQ_MANAGEMENT_SSL_FAIL_IF_NO_PEER_CERT: Whether to reject TLS connections if client fails to provide a certificate for the RabbitMQ management server. Default: yes
RABBITMQ_MANAGEMENT_SSL_VERIFY: Whether to enable peer SSL certificate verification for the RabbitMQ management server. Default: verify_peer
LDAP configuration
RABBITMQ_ENABLE_LDAP: Enable the LDAP configuration. Defaults: no
RABBITMQ_LDAP_TLS: Enable secure LDAP configuration. Defaults: no
RABBITMQ_LDAP_SERVERS: Comma, semi-colon or space separated list of LDAP server hostnames. No defaults.
RABBITMQ_LDAP_SERVERS_PORT: LDAP servers port. Defaults: 389
RABBITMQ_LDAP_USER_DN_PATTERN: DN used to bind to LDAP in the form cn=$${username},dc=example,dc=org. No defaults.
Memory and disk configuration
RABBITMQ_VM_MEMORY_HIGH_WATERMARK: High memory watermark for RabbitMQ to block publishers and prevent new messages from being enqueued. Can be specified as an absolute or relative value (as percentage or value between 0 and 1). No defaults.
RABBITMQ_DISK_FREE_RELATIVE_LIMIT: Disk relative free space limit of the partition on which RabbitMQ is storing data. Default: 1.0
RABBITMQ_DISK_FREE_ABSOLUTE_LIMIT: Disk absolute free space limit of the partition on which RabbitMQ is storing data (takes precedence over the relative limit). No defaults.
RABBITMQ_ULIMIT_NOFILES: Resources limits: maximum number of open file descriptors. Default: 65536

六、进入RabbitMQ容器一探究竟

首先进入容器

[root@localhost ~]# docker exec -it rabbitmq bin/bash

rabbitmq是依赖erlang环境的,所以查看一下erlang是否安装成功
输入 erl,可以看到如下输出


```bash
I have no name!@0d5cb60e3a06:/$ erl
Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit]

Eshell V12.2  (abort with ^G)
1> 

bitnami的镜像,软件一般安装在opt/bitnami目录下

I have no name!@0d5cb60e3a06:/$ cd opt/bitnami/
I have no name!@0d5cb60e3a06:/opt/bitnami$ ls -al
total 4
drwxrwxr-x. 1 root root  22 Jan  4  2022 .
drwxrwxr-x. 1 root root  21 Jan  4  2022 ..
-rw-r--r--. 1 root root 659 Jan  4  2022 .bitnami_components.json
drwxr-xr-x. 4 root root  33 Aug 17  2021 common
drwxr-xr-x. 5 root root  44 Dec 15  2021 erlang
drwxrwxr-x. 2 root root  26 Jan  4  2022 licenses
drwxr-xr-x. 1 root root  45 Jan  4  2022 rabbitmq
drwxrwxr-x. 1 root root  82 Jan  4  2022 scripts

查看rabbitmq是否正常启动
rabbitmqctl status可以输出很多rabbitmq的信息
包括版本信息,安装的插件,数据安装目录,还有一些指标信息。

I have no name!@0d5cb60e3a06:/opt/bitnami$ rabbitmqctl status
Status of node rabbit@localhost ...
Runtime

OS PID: 213
OS: Linux
Uptime (seconds): 816
Is under maintenance?: false
RabbitMQ version: 3.9.11
Node name: rabbit@localhost
Erlang configuration: Erlang/OTP 24 [erts-12.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit]
Erlang processes: 378 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60

Plugins

Enabled plugin file: /opt/bitnami/rabbitmq/etc/rabbitmq/enabled_plugins
Enabled plugins:

 * rabbitmq_management
 * amqp_client
 * rabbitmq_web_dispatch
 * cowboy
 * cowlib
 * rabbitmq_management_agent

Data directory

Node data directory: /bitnami/rabbitmq/mnesia/rabbit@localhost
Raft data directory: /bitnami/rabbitmq/mnesia/rabbit@localhost/quorum/rabbit@localhost

Config files

 * /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq.conf

Log file(s)

 * /opt/bitnami/rabbitmq/var/log/rabbitmq/rabbit@localhost_upgrade.log
 * <stdout>

Alarms

(none)

Memory

Total memory used: 0.1509 gb
Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 1.1548 gb

reserved_unallocated: 0.0833 gb (55.2 %)
code: 0.0347 gb (22.97 %)
other_system: 0.0238 gb (15.78 %)
other_proc: 0.0192 gb (12.7 %)
other_ets: 0.0032 gb (2.09 %)
atom: 0.0014 gb (0.94 %)
plugins: 0.0014 gb (0.9 %)
binary: 5.0e-4 gb (0.31 %)
mgmt_db: 2.0e-4 gb (0.15 %)
connection_other: 1.0e-4 gb (0.09 %)
mnesia: 1.0e-4 gb (0.07 %)
metrics: 1.0e-4 gb (0.05 %)
msg_index: 1.0e-4 gb (0.04 %)
connection_readers: 0.0 gb (0.03 %)
queue_procs: 0.0 gb (0.02 %)
quorum_ets: 0.0 gb (0.0 %)
connection_channels: 0.0 gb (0.0 %)
stream_queue_procs: 0.0 gb (0.0 %)
stream_queue_replica_reader_procs: 0.0 gb (0.0 %)
connection_writers: 0.0 gb (0.0 %)
allocated_unused: 0.0 gb (0.0 %)
queue_slave_procs: 0.0 gb (0.0 %)
quorum_queue_procs: 0.0 gb (0.0 %)
stream_queue_coordinator_procs: 0.0 gb (0.0 %)

File Descriptors

Total: 6, limit: 1048479
Sockets: 1, limit: 943629

Free Disk Space

Low free disk space watermark: 2.8869 gb
Free disk space: 10.2966 gb

Totals

Connection count: 1
Queue count: 1
Virtual host count: 2

Listeners

Interface: [::], port: 15672, protocol: http, purpose: HTTP API
Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0

更多rabbitmq的操作,可以通过rabbitmqctl --help来查看

I have no name!@0d5cb60e3a06:/opt/bitnami$ rabbitmqctl --help

七、扩展阅读

在玩容器的时候,一般搜索镜像的时候,会发现bitnami仓库的镜像,star都比较高。发现确实好用!
这里附上
官网链接:https://bitnami.com/stacks
在bitnami的官网,可以看到很多打包好的应用,链接进去是github的链接,是相关的镜像的说明
在这里插入图片描述

其中RabbitMQ镜像的git链接:https://github.com/bitnami/containers/tree/main/bitnami/rabbitmq

八、扩展:用docker-compose安装RabbitMQ集群

参考链接:https://github.com/bitnami/containers/tree/main/bitnami/rabbitmq#setting-up-a-cluster
这是最简单的方式安装一个RabbitMQ集群
docker-compose.yml如下:

version: '2'

services:
  stats:
    image: bitnami/rabbitmq
    environment:
      - RABBITMQ_NODE_TYPE=stats
      - RABBITMQ_NODE_NAME=rabbit@stats
      - RABBITMQ_ERL_COOKIE=s3cr3tc00ki3
    ports:
      - '15672:15672'
    volumes:
      - 'rabbitmqstats_data:/bitnami/rabbitmq/mnesia'
  queue-disc1:
    image: bitnami/rabbitmq
    environment:
      - RABBITMQ_NODE_TYPE=queue-disc
      - RABBITMQ_NODE_NAME=rabbit@queue-disc1
      - RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
      - RABBITMQ_ERL_COOKIE=s3cr3tc00ki3
    volumes:
      - 'rabbitmqdisc1_data:/bitnami/rabbitmq/mnesia'
  queue-ram1:
    image: bitnami/rabbitmq
    environment:
      - RABBITMQ_NODE_TYPE=queue-ram
      - RABBITMQ_NODE_NAME=rabbit@queue-ram1
      - RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
      - RABBITMQ_ERL_COOKIE=s3cr3tc00ki3
    volumes:
      - 'rabbitmqram1_data:/bitnami/rabbitmq/mnesia'

volumes:
  rabbitmqstats_data:
    driver: local
  rabbitmqdisc1_data:
    driver: local
  rabbitmqram1_data:
    driver: local

首先建好一个docker-compose.yml文件

用cat命令,输出到docker-compose.yml

[root@localhost mycompose]# cat >> docker-compose.yml << EOF
> version: '2'
> 
> services:
>   stats:
>     image: bitnami/rabbitmq
>     environment:
>       - RABBITMQ_NODE_TYPE=stats
>       - RABBITMQ_NODE_NAME=rabbit@stats
>       - RABBITMQ_ERL_COOKIE=s3cr3tc00ki3
>     ports:
>       - '15672:15672'
>     volumes:
>       - 'rabbitmqstats_data:/bitnami/rabbitmq/mnesia'
>   queue-disc1:
>     image: bitnami/rabbitmq
>     environment:
>       - RABBITMQ_NODE_TYPE=queue-disc
>       - RABBITMQ_NODE_NAME=rabbit@queue-disc1
>       - RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
>       - RABBITMQ_ERL_COOKIE=s3cr3tc00ki3
>     volumes:
>       - 'rabbitmqdisc1_data:/bitnami/rabbitmq/mnesia'
>   queue-ram1:
>     image: bitnami/rabbitmq
>     environment:
>       - RABBITMQ_NODE_TYPE=queue-ram
>       - RABBITMQ_NODE_NAME=rabbit@queue-ram1
>       - RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
>       - RABBITMQ_ERL_COOKIE=s3cr3tc00ki3
>     volumes:
>       - 'rabbitmqram1_data:/bitnami/rabbitmq/mnesia'
> 
> volumes:
>   rabbitmqstats_data:
>     driver: local
>   rabbitmqdisc1_data:
>     driver: local
>   rabbitmqram1_data:
>     driver: local
> EOF
[root@localhost mycompose]# ls -al
总用量 4
drwxr-xr-x. 2 root root   32 924 21:26 .
dr-xr-x---. 6 root root  254 924 21:23 ..
-rw-r--r--. 1 root root 1017 924 21:26 docker-compose.yml

然后执行docker-compose up

[root@localhost mycompose]# docker-compose up

执行效果如下:
在这里插入图片描述
启动完成后,发现确实是启了三个RabbitMQ的容器

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE              COMMAND                   CREATED         STATUS         PORTS                                                                                                         NAMES
a8abe421a79a   bitnami/rabbitmq   "/opt/bitnami/script…"   2 minutes ago   Up 2 minutes   4369/tcp, 5551-5552/tcp, 5671-5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp   mycompose-stats-1
d797db9bbbbb   bitnami/rabbitmq   "/opt/bitnami/script…"   2 minutes ago   Up 2 minutes   4369/tcp, 5551-5552/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp                                            mycompose-queue-ram1-1
7ed4e7406553   bitnami/rabbitmq   "/opt/bitnami/script…"   2 minutes ago   Up 2 minutes   4369/tcp, 5551-5552/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp                                            mycompose-queue-disc1-1

进入其中一个容器

如上面所示,我们进入ID为a8abe421a79a的容器。

[root@localhost ~]# docker exec -it a8a /bin/bash

查看集群状态

I have no name!@a8abe421a79a:/$ rabbitmqctl cluster_status
Cluster status of node rabbit@stats ...
Basics

Cluster name: rabbit@a8abe421a79a

Disk Nodes

rabbit@queue-disc1
rabbit@stats

RAM Nodes

rabbit@queue-ram1

Running Nodes

rabbit@queue-disc1
rabbit@queue-ram1
rabbit@stats

Versions

rabbit@queue-disc1: RabbitMQ 3.9.11 on Erlang 24.2
rabbit@queue-ram1: RabbitMQ 3.9.11 on Erlang 24.2
rabbit@stats: RabbitMQ 3.9.11 on Erlang 24.2

Maintenance status

Node: rabbit@queue-disc1, status: not under maintenance
Node: rabbit@queue-ram1, status: not under maintenance
Node: rabbit@stats, status: not under maintenance

Alarms

(none)

Network Partitions

(none)

Listeners

Node: rabbit@queue-disc1, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@queue-disc1, interface: [::], port: 15692, protocol: http/prometheus, purpose: Prometheus exporter API over HTTP
Node: rabbit@queue-disc1, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Node: rabbit@queue-ram1, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@queue-ram1, interface: [::], port: 15692, protocol: http/prometheus, purpose: Prometheus exporter API over HTTP
Node: rabbit@queue-ram1, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Node: rabbit@stats, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@stats, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@stats, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0

Feature flags

Flag: drop_unroutable_metric, state: enabled
Flag: empty_basic_get_metric, state: enabled
Flag: implicit_default_bindings, state: enabled
Flag: maintenance_mode_status, state: enabled
Flag: quorum_queue, state: enabled
Flag: stream_queue, state: enabled
Flag: user_limits, state: enabled
Flag: virtual_host_metadata, state: enabled

进入控制台:http://192.168.56.201:15672/#/
账号默认是:用户名:user,密码:bitnami
在这里插入图片描述

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

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

相关文章

3D设计软件Rhinoceros 6 mac 犀牛6中文版功能特征

Rhinoceros Mac中文版是一款3D设计软件“犀牛”&#xff0c;在众多三维建模软件中&#xff0c;Rhinoceros mac因为其体积小、功能强大、对硬件要求低而广受欢迎&#xff0c;对于专业的3D设计人员来说它是一款非常不错的3D建模软件&#xff0c;Rhinoceros Mac中文版能轻易整合3D…

苹果手机短信删除了怎么恢复?3种有效方法介绍

手机短信是一种即时通信方式&#xff0c;人们可以使用短信来达到快速传递信息的目的。在没有网络或者网络不稳定的时候&#xff0c;短信仍然可以做到发送和接收&#xff0c;这弥补了其他网络通信软件的缺点。 所以说&#xff0c;手机短信仍然是我们生活中不可缺少的一部分。当…

【rtp】mid 扩展: RtpMid 字符串扩展的解析和写入

mid 是uint8_t 类型? 扩展填写的是字符串,读取字符串后atoi 转 uint8_t : webrtc 看起来是个字符串:写入 扩展的值是改变了: 这里是更新扩展的长度: 新的大小小于原来的,没有缩减内存,而是对于多余的置位0了:if (len < current_len) {memset(

基于SSM的高校图书馆个性化服务的设计与实现(有报告)。Javaee项目。

演示视频&#xff1a; 基于SSM的高校图书馆个性化服务的设计与实现&#xff08;有报告&#xff09;。Javaee项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;三层体系结构&#xff0c;通过S…

如何在低代码平台中应用可视化编程

可视化编程&#xff0c;亦即可视化程序设计&#xff1a;以“所见即所得”的编程思想为原则&#xff0c;力图实现编程工作的可视化&#xff0c;即随时可以看到结果&#xff0c;程序与结果的调整同步。可视化编程的理念来源于可视化技术&#xff0c;它指的是一种把计算机程序中的…

深度学习在视频直播美颜sdk中的应用

视频直播美颜SDK是一类用于实时视频美颜处理的工具包&#xff0c;它们利用深度学习算法来提高视频直播中的主播和观众的外观吸引力。本文将深入探讨深度学习在视频直播美颜sdk中的应用&#xff0c;以及这些应用对直播行业的重要性。 一、人脸检测与关键点定位 通过卷积神经网…

Centos7安装go解释器

Centos7安装go解释器 下载解压go压缩包编辑go变量结果验证 下载解压go压缩包 # 下载 wget -c https://go.dev/dl/go1.20.2.linux-amd64.tar.gz# 解压到指定目录 tar xvf go1.20.2.linux-amd64.tar.gz -C /usr/local/编辑go变量 /etc/profile.d/go.sh # 指定go执行程序位置 e…

多线程进阶:常见的锁策略、CAS

之前我们所了解的属于多线程的初阶内容。今天开始&#xff0c;我们进入多线程进阶的学习。 锁的策略 乐观锁 悲观锁 这不是两把具体的锁&#xff0c;应该叫做“两类锁” 乐观锁&#xff1a;预测锁竞争不是很激烈&#xff08;这里做的工作可能就会少一些&#xff09; 悲观锁…

【操作系统笔记六】内存分配

内存对齐 问题&#xff1a;为什么需要内存对齐呢&#xff1f; 主要原因是为了兼容&#xff0c;为了让程序可以运行在不同的处理器中&#xff0c;有很多处理器在访问内存的时候&#xff0c;只能从特定的内存地址读取数据。换个说法就是处理器每次只能从内存取出特定个数字节的数…

WKB近似

WKB方法用于研究一种特定类型的微分方程的全局性质 很有用这种特定的微分方程形如&#xff1a; 经过一些不是特别复杂的推导&#xff0c;我们可以得到他的WKB近似解。 该近似解的选择取决于函数和参数的性质同时&#xff0c;我们默认函数的定义域为当恒大于零,时&#xff1a; 当…

淘宝/天猫获得淘宝商品详情(关键词搜索,店铺所有商品)API接口返回值说明

淘宝API接口&#xff0c;简单而言&#xff0c;就是一套工具&#xff0c;可以帮助你与淘宝平台的数据与功能进行智能对接。它能够让你的店铺信息、商品信息、用户数据等信息实现高效流通&#xff0c;帮助你更好地理解客户需求 我们深知数据安全的重要性&#xff0c;因此&#x…

【MySQL】MySQL中的复制技术是什么?它有哪些组成部分?

什么是复制&#xff08;Replication&#xff09;MySQL复制架构感谢 &#x1f496; 什么是复制&#xff08;Replication&#xff09; 复制技术是MySQL高级特性的基础。它可以将数据从一个 MySQL 实例复制到另一个实例&#xff0c;从而实现数据的同步和备份。 MySQL复制架构 以…

Ansys Zemax | 如何设计光谱仪——理论依据

光谱学是一种无创性技术&#xff0c;是研究组织、等离子体和材料的最强大工具之一。本文介绍了如何利用近轴元件建立透镜—光栅—透镜(LGL)光谱仪模型&#xff0c;使用OpticStudio的多重结构( Multiple Configurations )、评价函数 ( Merit Functions )和ZPL宏等先进功能完成了…

八、伯努利朴素贝叶斯算法(Bernoulli NB,Bernoulli Naive Bayes)(有监督学习)

Bernoulli Naive Bayes&#xff1a;用于多元伯努利模型的Naive Bayes分类器 一、算法思路 与多项式分类器一样&#xff0c;该分类器也适用于离散数据。不同之处在于&#xff0c;多项式分类器适用于出现次数&#xff0c;而伯努利分类器则适用于二进制/布尔特征。 二、官网API…

Unity当中的灯光类型

文章目录 前言一、Directional平行光二、Point点灯三、Spot 聚光灯四、Area面光灯&#xff0c;只用于烘培 前言 Unity当中的灯光类型 一、Directional平行光 Unity当中最重要的灯管类型&#xff0c;类似现实中的太阳光 二、Point点灯 类似现实中的灯泡&#xff0c;萤火虫&a…

Celery结合flask完成异步任务与定时任务

Celery 常用于 web 异步任务、定时任务等。 使用 redis 作为 Celery的「消息代理 / 消息中间件」。 这里通过Flask-Mail使用qq邮箱延时发送邮件作为示例 pip install celery pip install redis pip install Flask-Mail1、使用flask发送邮件 使用 Flask-Mail 发送邮件需要进行…

1688-阿里巴巴批发网(获取优惠券信息)

item_get_app-获取1688app上原数据 为了进行电商平台 的API开发&#xff0c;首先我们需要做下面几件事情。 1&#xff09;开发者注册一个账号 2&#xff09;然后为每个1688 应用注册一个应用程序键&#xff08;App Key) 。 3&#xff09;下载1688 API的SDK并掌握基本的API基…

惠普P1108激光打印机报错光束探测错误检修

在使用打印机的过程中&#xff0c;有时候会遇到光束探测错误的问题&#xff0c;导致打印机无法正常工作。这个问题可能是由多种原因引起的&#xff0c;包括硬件故障、驱动程序错误、操作系统问题等。在这里&#xff0c;我将为您提供一些解决光束探测错误的方法。 故障描述&…

SpringBoot 学习(七)Swagger

7. Swagger 7.1 简介 便于前后端集成联调RestFul Api 文档在线生成工具 > Api 文档与 Api 定义同步更新直接运行&#xff0c;在线测试 Api 接口 7.2 springboot 集成 swagger (1) 导入依赖 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger…

清华用7个ChatGPT模拟《狼人杀》,结果出乎意料!

为了验证大语言模型的沟通、规划、反思等拟人化能力&#xff0c;清华研究团队发布了一篇名为“探索大语言模型在交流游戏中的应用&#xff1a;《狼人杀》实验”的研究论文。 结果显示&#xff0c;通过ChatGPT&#xff08;GPT -turbo-0301&#xff09;构建的7个玩家&#xff0c…