Redis单例部署

news2024/10/6 22:30:40

目录

  • 1. 概述
  • 2. 参考
  • 3. 环境
  • 4. 部署
    • 4.1 操作系统
      • 4.1.1 修改系统参数
      • 4.1.2 关闭透明大页内存
      • 4.1.3 修改系统限制
    • 4.2 安装Redis
      • 4.2.1 下载Redis
      • 4.2.2 创建redis账号
      • 4.2.3 添加Redis环境变量
      • 4.2.4 创建Redis使用目录
      • 4.2.5 安装Redis
      • 4.2.6 手动修改配置文件(**可跳过,直接使用4.2.7命令修改**)
      • 4.2.7 命令修改配置文件
      • 4.2.8 Redis使用目录赋权
      • 4.2.9 启动Redis验证
      • 4.2.10 目录结构
    • 4.3 配置systemd管理
      • 4.3.1 编译安装时未使用systemd
      • 4.3.2 编译安装时使用了systemd方式
      • 4.3.3 加载并验证服务
    • 4.3 部署常见问题
      • 4.3.1 编译时环境问题
      • 4.3.2 编译时缺少文件

1. 概述

之前一直使用Redis,最近遇到一些问题,整理Redis的单例安装部署过程,记录如下。

2. 参考

  1. 链接: Install Redis
  2. 链接: github-Redis
  3. 链接: gitcode-Redis

3. 环境

  • 虚机Virtual-Machine-203
  • Ubuntu 22.04(Centos7.9也可以)
  • Redis 7.2.5

4. 部署

4.1 操作系统

4.1.1 修改系统参数

  • 添加以下系统参数(必须)
cat >> /etc/sysctl.conf << EOF
# Redis 必须使用参数
#定义了系统中每一个端口最大的监听队列的长度,默认4096 可调整到8192/16384/32768
net.core.somaxconn = 32768

# Redis 必须使用参数
# 1表示内核允许分配所有的物理内存,而不管当前的内存状态如何,默认0。
vm.overcommit_memory = 1

# Redis 建议使用参数
# 物理内存使用90%,才开始使用swap,默认60,也可以设置为0,优先使用100%物理内存
vm.swappiness = 10

# 大于100将更积极的回收cache,默认100,
vm.vfs_cache_pressure = 100

EOF
  • 添加以下系统参数(可选)
cat >> /etc/sysctl.conf << EOF
# 系统调优参数
# 允许存在time_wait状态的最大数值,超过则立刻被清除并且警告 
# 默认是262144, ubuntu默认8192,防止过多的time_wait导致端口资源被耗尽
net.ipv4.tcp_max_tw_buckets = 30000

# 开启SYN Cookies,当出现SYN 等待队列溢出时,启用cookies 来处理。
net.ipv4.tcp_syncookies = 1

# 该参数决定了,每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目,默认1000
net.core.netdev_max_backlog = 32768

# 表示SYN队列的长度,默认2048
net.ipv4.tcp_max_syn_backlog = 32768

# 建立连接syn+ack 与syn 包重试次数
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

EOF
  • 参数生效
sysctl -p

4.1.2 关闭透明大页内存

  • 关闭透明大页内存动态分配,需要关闭让 redis 或 mongo 负责内存管理
cat >> /etc/rc.local << EOF
# Redis Mongo建议参数
# Disable Transparent Huge Pages, redis and mongo configure
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
EOF
  • 加载生效
source /etc/rc.local

4.1.3 修改系统限制

cp /etc/security/limits.conf /etc/security/limits.conf.bak
cat>>/etc/security/limits.conf <<EOF
* soft nproc 655350
* hard nproc 655350
* soft nofile 655350
* hard nofile 655350

# ubuntu 需要针对账号设置
root soft nproc 655350
root hard nproc 655350
root soft nofile 655350
root hard nofile 655350
EOF
  • 重启或重新登录生效
  • 修改当前设置生效
ulimit -n 655350 
ulimit -u 655350 

4.2 安装Redis

4.2.1 下载Redis

  • 从官网或 github下载,需要看一下版本,选择没有重大安全问题的版本
    • https://github.com/redis/redis/releases
    • http://download.redis.io/releases/redis-7.2.5.tar.gz
wget http://download.redis.io/releases/redis-7.2.5.tar.gz

4.2.2 创建redis账号

useradd -s /sbin/nologin redis

4.2.3 添加Redis环境变量

  • 确定Redis安装路径,例如/usr/local/redis7.2.5
  • 增加环境变量 REDIS_HOME ,不要与已有路径冲突
cat >>/etc/profile<<EOF

export REDIS_HOME=/usr/local/redis7.2.5
PATH=\$REDIS_HOME/bin:\$PATH
export PATH
EOF
  • 加载生效,查看路径
source /etc/profile && echo $PATH

4.2.4 创建Redis使用目录

  • 创建Redis使用目录
    • /usr/local/redis7.2.5(REDIS_HOME):程序存放目录
    • /var/log/redis:日志存放目录
    • /var/run/redis:服务PID存放目录
    • /etc/redis:配置文件存放目录(可选),当前默认存放在“程序存放目录”下
mkdir -p ${REDIS_HOME} && chown -R redis:redis ${REDIS_HOME}
mkdir -p /var/log/redis && chown redis:redis /var/log/redis
mkdir -p /var/run/redis && chown -R redis:redis /var/run/redis
# mkdir -p /etc/redis && chown -R redis:redis /etc/redis

4.2.5 安装Redis

安装可以根据Redis服务启动管理,选择安装方式。可提供以下几种方式,供选择:

  1. 使用systemctl命令管理(Centos7、Ubuntu),编译安装时指定 USE_SYSTEMD=yes 选项,配置systemd服务管理文件时Type使用notify
  2. 使用systemctl命令管理(Centos7、Ubuntu),编译安装,配置systemd服务管理文件时Type使用simple
  3. 使用service命令管理(Centos6),编译安装,配置/etc/init.d下启动文件
  • Ubuntu支持systemd方式编译安装,能够支持Type=notify
    • PREFIX 指定安装路径
    • USE_SYSTEMD 支持systemd
# Ubuntu 安装
tar -zxvf redis-7.2.5.tar.gz && cd redis-7.2.5
# 安装依赖包
apt install -y libsystemd-dev pkg-config
# 可以使用支持systemd方式编译安装,能够支持Type=notify
make PREFIX=${REDIS_HOME} USE_SYSTEMD=yes install
  • Centos支持systemd方式编译安装,能够支持Type=notify
    • PREFIX 指定安装路径
    • USE_SYSTEMD 支持systemd
# Centos 安装
tar -zxvf redis-7.2.5.tar.gz && cd redis-7.2.5
# 安装依赖包
yum install -y systemd-notify-devel 
# 可以使用支持systemd方式编译安装,能够支持Type=notify
make PREFIX=${REDIS_HOME} USE_SYSTEMD=yes install
  • 其他编译安装,可用于service命令(如Centos6)或systemd的simple
    • PREFIX 指定安装路径
tar -zxvf redis-6.2.9.tar.gz && cd redis-6.2.9
make PREFIX=${REDIS_HOME} install
  • 验证安装版本
${REDIS_HOME}/bin/redis-server --version

4.2.6 手动修改配置文件(可跳过,直接使用4.2.7命令修改

  • 拷贝配置文件到安装路径下并修改。
cp ./redis.conf ${REDIS_HOME}/ && cd ${REDIS_HOME}
  • 修改监听地址,IPv4和IPv6均监听
#bind 127.0.0.1 -::1
bind * -::*
  • 根据需要修改监听端口
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
  • 修改监听队列长度,小于sysctl.conf文件中的somaxconn 设置
# In high requests-per-second environments you need a high backlog in order
# to avoid slow clients connection issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
#tcp-backlog 511
tcp-backlog 4096
  • timeout保持不变,配合应用程序保持长连接。
    注意它不是超时连接,它是空闲后等待多久后关闭。
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
  • tcp-keepalive保持不变
    服务端于探测客户端的检测时间周期。可根据需要调整
tcp-keepalive 300
  • 启动后台运行
#daemonize no
daemonize yes
  • 修改pid文件路径
#pidfile /var/run/redis_6379.pid
pidfile /var/run/redis/redis_6379.pid
  • 修改日志文件路径
#logfile ""
logfile "/var/log/redis/redis_6379.log"
  • 修改snapshotting配置
    需要综合考虑数据是否允许丢失和写入rdb的频率。
    这里是允许数据丢失的,而且变更的频次不高,所以只修改了900秒内有500个变更的值
################################ SNAPSHOTTING  ################################

# Save the DB to disk.
#
# You can set these explicitly by uncommenting the following line.
#
# save 3600 1 300 100 60 10000
save 3600 1 900 500 60 10000
  • 修改了dump.rdb的文件名称
# The filename where to dump the DB
 dbfilename dump_6379.rdb
  • 修改了dump.rdb的存储路径
    注意路径是否有足够的磁盘空间。最合理方式应该存储在单独的数据分区,创建目录并给redis账号赋权
# dir ./
dir /usr/local/redis/
  • 修改连接密码
# requirepass foobared
 requirepass yourpassword
  • 重命名危险命令
    • config命令使用别名
    • 其它命令被禁用
# rename-command CONFIG ""
 rename-command CONFIG "kkconfig"
 rename-command FLUSHALL ""
 rename-command FLUSHDB ""
 rename-command DEBUG ""
  • 修改最大客户端连接数
# maxclients 10000
maxclients 50000
  • 修改最大内存限制
    如果是redis专用服务器,建议不超过物理内存的3/4
# maxmemory <bytes>
maxmemory 32GB
  • 保持淘汰策略不变-不淘汰
    通常情况下应该选择一个淘汰策略,而不是不淘汰
# maxmemory-policy noeviction
  • 打开异步操作,防止单线程阻塞
    • lazyfree-lazy-eviction:表示当 Redis 运行内存超过 maxmeory 时,是否开启 lazy free 机制删除;
    • lazyfree-lazy-expire:表示设置了过期时间的键值,当过期之后是否开启 lazy free 机制删除;
    • lazyfree-lazy-server-del:有些指令在处理已存在的键时,会带有一个隐式的 del 键的操作,比如 rename 命令,当目标键已存在,Redis 会先删除目标键,如果这些目标键是一个 big key,就会造成阻塞删除的问题,此配置表示在这种场景中是否开启 lazy free 机制删除;
    • slave-lazy-flush:针对 slave(从节点) 进行全量数据同步,slave 在加载 master 的 RDB 文件前,会运行 flushall 来清理自己的数据,它表示此时是否开启 lazy free 机制删除。
    • lazyfree-lazy-user-del:表示是否将 DEL 指令的默认行为替换成 lazy free 机制删除,效果就跟 UNLINK 一样。
############################# LAZY FREEING ####################################
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes
replica-lazy-flush yes
lazyfree-lazy-user-del yes
  • 修改慢查询日志设置
################################## SLOW LOG ###################################
# 修改为20000微秒,默认是10000微秒
slowlog-log-slower-than 20000
# 修改为保存1000条记录,默认128条
slowlog-max-len 1000

4.2.7 命令修改配置文件

  • 拷贝配置文件到安装路径下并修改。
cp ./redis.conf ${REDIS_HOME}/ && cd ${REDIS_HOME}
  • 先定义以下变量
    • PORT: Redis服务监听端口
    • MAXMEMORY:Redis服务最大内存限制
    • YPWD:Redis服务密码
cd ${REDIS_HOME}
PORT=6379
MAXMEMORY='32GB'
YPWD='yourpassword'
sed -i "s|bind 127.0.0.1 -::1| bind * -::* |" ./redis.conf \
&& sed -i "s|port 6379| port ${PORT}|" ./redis.conf \
&& sed -i "s|tcp-backlog 511| tcp-backlog 4096|" ./redis.conf \
&& sed -i "s|daemonize no| daemonize yes|" ./redis.conf \
&& sed -i "s|pidfile /var/run/redis_6379.pid| pidfile /var/run/redis/redis_${PORT}.pid|" ./redis.conf \
&& sed -i "s|logfile \"\"| logfile \"/var/log/redis/redis_${PORT}.log\"|" ./redis.conf \
&& sed -i "s|# save 3600 1 300 100 60 10000| save 3600 1 900 500 60 10000|" ./redis.conf \
&& sed -i "s|# save 3600 1| save 3600 1|" ./redis.conf \
&& sed -i "s|# save 300 100| save 900 500|" ./redis.conf \
&& sed -i "s|# save 60 10000| save 60 10000|" ./redis.conf \
&& sed -i "s|dbfilename dump.rdb| dbfilename dump_${PORT}.rdb|" ./redis.conf \
&& sed -i "s|dir ./| dir ${REDIS_HOME}/|" ./redis.conf \
&& sed -i "s|# requirepass foobared| requirepass ${YPWD}|" ./redis.conf \
&& sed -i "/# rename-command CONFIG \"\"/ a\\ rename-command CONFIG 'xkconfig'\n rename-command FLUSHALL ''\n rename-command FLUSHDB ''\n rename-command DEBUG ''\n"  ./redis.conf \
&& sed -i "s|# maxclients 10000| maxclients 50000|" ./redis.conf \
&& sed -i "s|# maxmemory <bytes>| maxmemory ${MAXMEMORY}|" ./redis.conf \
&& sed -i "s|lazyfree-lazy-eviction no| lazyfree-lazy-eviction yes|" ./redis.conf \
&& sed -i "s|lazyfree-lazy-expire no| lazyfree-lazy-expire yes|" ./redis.conf \
&& sed -i "s|lazyfree-lazy-server-del no| lazyfree-lazy-server-del yes|" ./redis.conf \
&& sed -i "s|replica-lazy-flush no| replica-lazy-flush yes|" ./redis.conf \
&& sed -i "s|lazyfree-lazy-user-del no| lazyfree-lazy-user-del yes|" ./redis.conf \
&& sed -i "s|slowlog-log-slower-than 10000| slowlog-log-slower-than 20000|" ./redis.conf \
&& sed -i "s|slowlog-max-len 128| slowlog-max-len 1000|" ./redis.conf \
  • 验证修改配置
cat ${REDIS_HOME}/redis.conf | grep -E "^[^;#]"

4.2.8 Redis使用目录赋权

# 日志目录赋权
chown -R redis:redis /var/log/redis
# 程序目录赋权
chown -R redis:redis /usr/local/redis
# pid文件目录赋权
chown -R redis:redis /var/run/redis
# 数据目录赋权(如果单独指定了数据目录),与配置文件中rdb存储路径一致
#chown -R redis:redis /data/redis/
chown -R redis:redis /var/log/redis \
&& chown -R redis:redis /var/run/redis \
&& chown -R redis:redis ${REDIS_HOME} \

4.2.9 启动Redis验证

  • 使用普通用户启动Redis
 sudo -u redis /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf 
  • Redis已经监听6379端口
root@Virtual-Machine-203:~# netstat -ntlp| grep redis
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      19821/redis-server  
tcp6       0      0 ::1:6379                :::*                    LISTEN      19821/redis-server  
root@Virtual-Machine-203:~# redis-cli 
127.0.0.1:6379> auth yourpassword
OK
127.0.0.1:6379> select 0
OK
127.0.0.1:6379> dbsize
(integer) 0
127.0.0.1:6379> kkconfig get save
1) "save"
2) "3600 1 900 500 60 10000"
127.0.0.1:6379> 

4.2.10 目录结构

  1. Redis安装目录
  • ${REDIS_HOME} = /etc/usr/redis7.2.5
    • bin 程序目录,已添加到系统环境变量PATH中
    • dump_port.rdb 持久化rdb文件,每个对应一个节点
    • redis.conf 单例服务配置文件
[root@localhost redis7.2.5]# tree
.
├── bin
│   ├── redis-benchmark
│   ├── redis-check-aof -> redis-server
│   ├── redis-check-rdb -> redis-server
│   ├── redis-cli
│   ├── redis-sentinel -> redis-server
│   └── redis-server
├── dump_6379.rdb
└── redis.conf
  1. Redis日志目录
  • /var/log/redis
    • 每个Redis服务实例对应一个日志文件
[root@localhost redis]# tree
.
└── redis_6379.log
  1. Redis PID目录
  • /var/run/redis
    • 每个Redis服务实例对应一个PID文件
[root@localhost redis]# tree
.
└── redis_6379.pid

4.3 配置systemd管理

4.3.1 编译安装时未使用systemd

非正规做法!正常应该编译时指定使用systemd
https://github.com/redis/redis/commit/129d14e1431e913426485526663e1a9aac67838c

在这里插入图片描述

vim /etc/systemd/system/redis-server.service
# example systemd service unit file for redis-server
#
# In order to use this as a template for providing a redis service in your
# environment, _at the very least_ make sure to adapt the redis configuration
# file you intend to use as needed (make sure to set "supervised systemd"), and
# to set sane TimeoutStartSec and TimeoutStopSec property values in the unit's
# "[Service]" section to fit your needs.
#
# Some properties, such as User= and Group=, are highly desirable for virtually
# all deployments of redis, but cannot be provided in a manner that fits all
# expectable environments. Some of these properties have been commented out in
# this example service unit file, but you are highly encouraged to set them to
# fit your needs.
#
# Please refer to systemd.unit(5), systemd.service(5), and systemd.exec(5) for
# more information.

[Unit]
Description=Redis data structure server
Documentation=https://redis.io/documentation
#Before=your_application.service another_example_application.service
#AssertPathExists=/var/lib/redis
Wants=network-online.target
After=network-online.target

[Service]
# 配置正确的服务和配置文件路径
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf --supervised systemd --daemonize no
## Alternatively, have redis-server load a configuration file:
#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf
ExecStop=/bin/kill -s TERM $MAINPID
LimitNOFILE=65535
NoNewPrivileges=yes
#OOMScoreAdjust=-900
PrivateTmp=yes
#Type=notify  # 默认 simple
TimeoutStartSec=infinity
TimeoutStopSec=infinity
UMask=0077
User=redis
Group=redis
WorkingDirectory=/usr/local/redis

[Install]
WantedBy=multi-user.target
  • 替换配置文件中Redis路径
    如果使用默认路径/usr/local/redis,不用执行
# sed -i "s|/usr/local/redis|${REDIS_HOME}|g" /etc/systemd/system/redis-server.service 

4.3.2 编译安装时使用了systemd方式

vim /etc/systemd/system/redis-server.service
# example systemd service unit file for redis-server
#
# In order to use this as a template for providing a redis service in your
# environment, _at the very least_ make sure to adapt the redis configuration
# file you intend to use as needed (make sure to set "supervised systemd"), and
# to set sane TimeoutStartSec and TimeoutStopSec property values in the unit's
# "[Service]" section to fit your needs.
#
# Some properties, such as User= and Group=, are highly desirable for virtually
# all deployments of redis, but cannot be provided in a manner that fits all
# expectable environments. Some of these properties have been commented out in
# this example service unit file, but you are highly encouraged to set them to
# fit your needs.
#
# Please refer to systemd.unit(5), systemd.service(5), and systemd.exec(5) for
# more information.

[Unit]
Description=Redis data structure server
Documentation=https://redis.io/documentation
#Before=your_application.service another_example_application.service
#AssertPathExists=/var/lib/redis
Wants=network-online.target
After=network-online.target

[Service]
# 配置正确的服务和配置文件路径
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf --supervised systemd --daemonize no
## Alternatively, have redis-server load a configuration file:
#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf
LimitNOFILE=65535
NoNewPrivileges=yes
#OOMScoreAdjust=-900
PrivateTmp=yes
Type=notify
#TimeoutStartSec=infinity
#TimeoutStopSec=infinity
TimeoutStartSec=180
TimeoutStopSec=180
UMask=0077
User=redis
Group=redis
WorkingDirectory=/usr/local/redis

[Install]
WantedBy=multi-user.target
  • 替换配置文件中Redis路径
    如果使用默认路径/usr/local/redis,不用执行
# sed -i "s|/usr/local/redis|${REDIS_HOME}|g" /etc/systemd/system/redis-server.service 

4.3.3 加载并验证服务

  • 加载systemd配置文件,每次修改后都需要重新加载
systemctl daemon-reload
  • 验证服务启动
# 启动
systemctl start redis-server
# 查看进程
netstat -ntlp | grep redis
  • 验证服务重启
# 测试重启
systemctl restart redis-server
# 查看进程ID是否变更
netstat -ntlp | grep redis
  • 验证服务停止
# 测试重启
systemctl stop redis-server
# 查看进程ID是否变更
netstat -ntlp | grep redis

4.3 部署常见问题

4.3.1 编译时环境问题

  • 现象:Ubuntu 没装 GCC
make[1]: Entering directory '/root/redis-7.2.5/src'
sh: 1: cc: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
    CC Makefile.dep
sh: 1: cc: not found
  • 处理:Ubuntu 22.04 安装
apt install build-essential pkg-config -y
  • 处理:如果是CentOS 7.9,参考安装
yum install make automake gcc gcc-c++ kernel-devel -y

4.3.2 编译时缺少文件

  • 现象:编译时缺文件
/usr/bin/ld: cannot find ../deps/hiredis/libhiredis.a: No such file or directory
/usr/bin/ld: cannot find ../deps/lua/src/liblua.a: No such file or directory
/usr/bin/ld: cannot find ../deps/hdr_histogram/libhdrhistogram.a: No such file or directory
/usr/bin/ld: cannot find ../deps/fpconv/libfpconv.a: No such file or directory
/usr/bin/ld: cannot find ../deps/jemalloc/lib/libjemalloc.a: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:403: redis-server] Error 1
make[1]: Leaving directory '/root/redis-7.2.5/src'
make: *** [Makefile:9: install] Error 2
  • 处理:先编译缺少的文件
root@Virtual-Machine-203:~# cd deps/
root@Virtual-Machine-203:~# make hiredis lua hdr_histogram fpconv jemalloc linenoise

# 如果jemalloc仍然不行,可以试试以下方式
#root@Virtual-Machine-203:~# cd  deps/jemalloc/
#root@Virtual-Machine-203:~#  ./configure
#root@Virtual-Machine-203:~#  make && make install_bin install_include install_lib

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

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

相关文章

Linux连接工具MobaXterm详细使用教程

目录 一、MobaXterm的下载 1、访问官网 2、下载便携版 3、启动MobaXterm 二、MobaXterm基本使用设置 1、新建会话 2、使用ssh连接第一个会话 3、设置主密码 4、主界面 5、sftp文件上传下载 6、文件拖拽的上传下载 7.右键粘贴 8、查看服务器监测信息​编辑 9、个…

在Linux下使用CMake加载自定义路径第三方库的指南

CMake是一个强大的跨平台构建系统&#xff0c;广泛应用于C项目中。它不仅能够处理标准的构建过程&#xff0c;还可以灵活地集成各种第三方库&#xff0c;包括自定义路径的库、已编译的共享库&#xff08;.so 文件&#xff09;&#xff0c;以及仅包含头文件的库&#xff08;如Ei…

qt 简单实验创建一个可以拖拽和缩放的矩形

1.概要 2.代码 2.1 resizablewidget.h #ifndef RESIZABLEWIDGET_H #define RESIZABLEWIDGET_H#include <QWidget> #include <QMouseEvent>class ResizableWidget: public QWidget {Q_OBJECT public:ResizableWidget(QWidget *parent nullptr); protected:void m…

IPD笔记

IPD笔记 先弄一个一图流&#xff0c;改天再过来继续补充 IPD&#xff08;Integrated Product Development&#xff09;即集成产品开发&#xff0c;是一套产品开发的模式、理念与方法。华为的IPD的核心思想是基于市场需求&#xff0c;将产品开发作为一项投资来管理&#xff0c;以…

【复旦邱锡鹏教授《神经网络与深度学习公开课》笔记】卷积

卷积经常用在信号处理中&#xff0c;用于计算信号的延迟累积。假设一个信号发射器每个时刻 t t t产生一个信号 x t x_t xt​&#xff0c;其信息的衰减率为 w k w_k wk​&#xff0c;即在 k − 1 k-1 k−1个时间步长后&#xff0c;信息为原来的 w k w_k wk​倍&#xff0c;时刻 …

vivado、vitis2022安装及其注意事项(省时、省空间)

1、下载 AMD官网-资源与支持-vivado ML开发者工具&#xff0c;或者vitis平台&#xff0c; 下载的时候有个官网推荐web安装&#xff0c;亲测这个耗时非常久&#xff0c;不建议使用&#xff0c;还是直接下载89G的安装包快。 注意&#xff1a;安装vitis平台会默认安装vivado&…

速卖通测评成本低见效快,自养号测评的实操指南,快速积累销量和好评

对于初入速卖通的新卖家而言&#xff0c;销量和评价的积累显得尤为关键。由于新店铺往往难以获得平台活动的青睐&#xff0c;因此流量的获取成为了一大挑战。在这样的背景下&#xff0c;进行产品测评以积累正面的用户反馈和销售记录&#xff0c;成为了提升店铺信誉和吸引潜在顾…

Mybatis框架的缓存

Mybatis框架的缓存 一.为什么使用缓存 缓存(cache&#xff09;的作用是为了减去数据库的压力&#xff0c;提高查询性能。缓存实现的 原理是从数据库中查询出来的对象在使用完后不要销毁&#xff0c;而是存储在内存&#xff08;缓存&#xff09; 中&#xff0c;当再次需要获取…

算法设计与分析:动态规划法求扔鸡蛋问题 C++

目录 一、实验目的 二、问题描述 三、实验要求 四、算法思想和实验结果 1、动态规划法原理&#xff1a; 2、解决方法&#xff1a; 2.1 方法一&#xff1a;常规动态规划 2.1.1 算法思想&#xff1a; 2.1.2 时间复杂度分析 2.1.3 时间效率分析 2.2 方法二&#xff1a;动态规划加…

Excel导出实例

在上一节的基础上&#xff0c;本文演示下如何导出excel数据。 Excel导出操作演示 继承ocean-easyexcel SDK <dependency><groupId>com.angel.ocean</groupId><artifactId>ocean-easyexcel</artifactId><version>1.0.0</version> …

标准立项 | 《温室气体排放核算与报告要求 废油资源化企业》

《温室气体排放核算与报告要求 废油资源化企业》适用于废油资源化行业企业温室气体排放量的核算和报告。从事废油资源化生产的企业&#xff0c;均可参考该标准核算企业的温室气体排放量&#xff0c;并编制企业温室气体排放报告。 参编咨询&#xff1a;中华环保联合会水环境治理…

【Deep Learning】Self-Supervised Learning:自监督学习

自监督学习 本文基于清华大学《深度学习》第12节《Beyond Supervised Learning》的内容撰写&#xff0c;既是课堂笔记&#xff0c;亦是作者的一些理解。 在深度学习领域&#xff0c;传统的监督学习(Supervised Learning)的形式是给你输入 x x x和标签 y y y&#xff0c;你需要训…

电商平台生活用品销售数据分析与应用

摘 要 在当前互联网飞速发展的时代&#xff0c;计算机应用给我们的工作生活带来了极大的便利。如今我们的生活离不开电商平台&#xff0c;其随之而来的是各种各样的销售数据与消费者信息&#xff0c;这些数据和信息的分析应用成为了当前互联网领域研究的重要部分。 本论文以基…

【JavaEE】Cookie和Session详解

一.Cookie 首先我们知道HTTP协议本身是’‘无状态’‘的, 这里的’‘无状态’指的是:默认情况下HTTP协议的客户端和服务器之间的这次通信,和下次通信之间没有直接的联系. 但是在实际的开发过程之中, 我们很多时候是需要知道请求之间的关联关系的. 例如登陆网站成功后,第二次访…

【C语言】解决C语言报错:Array Index Out of Bounds

文章目录 简介什么是Array Index Out of BoundsArray Index Out of Bounds的常见原因如何检测和调试Array Index Out of Bounds解决Array Index Out of Bounds的最佳实践详细实例解析示例1&#xff1a;访问负索引示例2&#xff1a;访问超出上限的索引示例3&#xff1a;循环边界…

C# 实现draw一个简单的温度计

运行结果 概述&#xff1a; 代码分析 该控件主要包含以下几个部分&#xff1a; 属性定义&#xff1a; MinValue&#xff1a;最低温度值。 MaxValue&#xff1a;最高温度值。 CurrentValue&#xff1a;当前温度值。 构造函数&#xff1a; 设置了一些控件样式来提升绘制效果…

使用Spring Boot构建RESTful API:从理论到实践

文章目录 引言第一章 RESTful API基础知识1.1 什么是RESTful API1.2 RESTful API的优势 第二章 Spring Boot基础知识2.1 什么是Spring Boot2.2 Spring Boot的主要特性 第三章 使用Spring Boot构建RESTful API3.1 项目初始化3.2 构建基础结构3.3 定义实体类3.4 创建Repository接…

Android低版本上APP首次启动时间减少80%(二)

06-25 15:10:53.821 7449 7450 D dalvikvm: threadid2: sending two SIGSTKFLTs to threadid135 (tid8021) to cause debuggerd dump SIGSTKFLT 是 Dalvik 虚拟机特有的一个信号。当虚拟机发生了 ANR 或者需要做 GC 的时候&#xff0c;就需要挂起所有 RUNNING 状态的线程&…

FPGA国内”薪“赛道-在医疗领域的应用

mian 免 ze 责 sheng 声 ming 明 以下观点仅代表个人观点&#xff0c;不代表任何公司或者行业 从下游应用市场来看&#xff0c;通信和工业市场份额位居FPGA芯片一二位&#xff0c;同时通信市场份额有望持续提升。但是目前通信和工业市场趋于稳定&#xff0c;FPGA厂商一直推AI市…

Docker部署Nginx1.21.5(保姆级图文教程)

系列文章目录 Docker部署Nginx1.21.5&#xff08;保姆级图文教程&#xff09; Docker部署MySQL8.3.0&#xff08;保姆级图文教程&#xff09; 文章目录 一、环境二、拉取镜像2.1 查找 Docker Hub 上的 nginx 镜像2.2 拉取Nginx镜像2.3 查看Nginx镜像 三、在宿主机创建目录四、启…