零基础入门haproxy七层代理

article/2025/6/20 11:39:34

文章目录

    • haproxy的安装和服务信息
      • global配置
      • proxies配置
        • defaults配置
        • frontend配置
        • backed配置
        • listen配置
      • socat工具
    • haproxy算法
      • 静态算法
      • 动态算法
      • 其他算法
    • 高级功能及配置案例
      • 基于cookie会话保持
      • HAProxy状态页
      • IP透传
        • 四层IP透传
        • 七层IP透传
      • ACL
        • 匹配规范
          • 基于HTTP请求头部的匹配
          • 精确匹配
          • URL部分匹配
          • URL完整匹配
          • IP、端口匹配
          • 状态码匹配
          • HTTP请求方法匹配
        • 匹配模式
        • 具体操作符
        • 操作对象类型
        • 域名匹配示例
        • 基于源IP、子网调度
        • 匹配浏览器类型
        • 基于文件后缀实现动静分离
      • HAProxy错误页面
        • 自定义页面错误
        • 重定向页面错误
      • HAProxy的https实现

haproxy的安装和服务信息

#安装软件
yum install -y haproxy

配置文件:/etc/haproxy/haproxy.cfg

global:全局配置段

​ 进程及安全配置相关的参数
​ 性能调整相关参数
​ Debug参数

proxies:代理配置段
defaults:为frontend,backend,listen提供默认配置
frontend:前端,相当于nginx中的server0}
backend:后端,相当于nginx中的upstream
listen:同时拥有前端和后端配置,配置简单,生产推荐使用

global配置

log  127.0.0.1 local2#运行目录chroot      /var/lib/haproxy#pid文件路径pidfile     /var/run/haproxy.pidmaxconn     4000user        haproxygroup       haproxydaemon#开启多线程nbthread 数字#开启多进程nbproc	数字cpu-map 1 0		#为进程指定cpucpu-map 2 1# 套接字文件stats socket /var/lib/haproxy/stats1 mode 600 level admin process 1
#查看进程数
pstree -p | grep haproxy#查看线程数
cat /proc/子进程id/status

proxies配置

defaults配置
针对以下的frontend、backed、listen生效defaultsmode                    http	#默认工作类型log                     globaloption                  httplogoption                  dontlognulloption http-server-closeoption forwardfor       except 127.0.0.0/8option                  redispatchretries                 3timeout http-request    10stimeout queue           1mtimeout connect         10s	#最长连接等待时间timeout client          1m	#与客户端最长非活动时间timeout server          1m	#请求处理时长timeout http-keep-alive 10s	#会话保持超时时间timeout check           10s	#默认检测时间maxconn                 3000
frontend配置
前端servername、类似于虚拟主机和lvs的集群frontend mainbind *:5000	#监听地址及其端口号use_backend static          if url_staticdefault_backend             app
backed配置
后端服务器组,类似于RS服务器mode httpltcp	#指定负载协议类型,和对应的frontend必须一致
option		#配置选项
server		#定义后端realserver,必须指定IP和端口
listen配置
将frontend和backed合并在一起配置,更加简洁listen webserver_80bind 172.25.254.100:80mode httpoption forwardforserver webserver1 192.168.0.101:80 check inter 3s fa11 3 rise 5 #每隔三秒检查一次,连续失败三次则转为线下,失败之后重连5次则转为线上server webserver2 192.168.0.102:80 check inter 3s fa11 3 rise 5

socat工具

对服务器动态权重和其它状态可以利用 socat工具进行调整,Socat 是 Linux 下的一个多功能的网络工具,名字来由是Socket CAT,相当于netCAT的增强版.Socat 的主要特点就是在两个数据流之间建立双向通道,且支持众多协议和链接方式。如IP、TCP、UDP、IPv6、Socket文件等

#软件下载
[root@haproxy ~]# yum install -y socat#编辑配置文件,进行授权
[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg stats socket /var/lib/haproxy/stats mode 600 level admin#重启haproxy
[root@haproxy ~]# systemctl start socat
#查看权值
[root@haproxy ~]# echo "get weight web/web1" | socat stdio /var/lib/haproxy/stats
#设置权值
[root@haproxy ~]# echo "set weight web/web1 2" | socat stdio /var/lib/haproxy/stats
#关闭、重启服务
[root@haproxy ~]# echo "disable server web/web1" | socat stdio /var/lib/haproxy/stats
[root@haproxy ~]# echo "enable server web/web1" | socat stdio /var/lib/haproxy/stats注:web/web1分别为frontene的集群名和backed内的服务器名称
注2:socat设定完之后若重启haproxy服务配置则会失效
针对多进程时
#开启多进程
[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg nbproc 2cpu-map 1 0cpu-map 2 1stats socket /var/lib/haproxy/stats1 mode 600 level admin process 1stats socket /var/lib/haproxy/stats2 mode 600 level admin process 2#调用更改时只需改变文件存储位置即可
例如  socat stdio /var/lib/haproxy/stats1

haproxy算法

静态算法

  1. static-rr

基于权重的轮询调度

不支持慢启动

不支持socat进行权重的动态调整

[root@node1 ~]# vim /etc/haproxy/haproxy.cfg
listen web_80bind 10.10.100.101:80mode httpbalance static-rrserver web01 10.10.100.102:80 weight 1 check inter 3000 fall 3 rise 5server web02 10.10.100.103:80 weight 1 check inter 3000 fall 3 rise 5#测试
[root@node1 ~]# while true; do curl -L http://10.10.100.101; sleep 1s; done
web02 10.10.100.103
web01 10.10.100.102
web01 10.10.100.102
web02 10.10.100.103

​ 2.first

基于服务器在列表中的位置,自上而下进行调度

当第一台服务器链接数达到上限,请求会分配给下一台服务器

忽略权重设置

不支持socat进行动态修改权限

[root@node1 ~]# vim /etc/haproxy/haproxy.cfg
listen web_80bind 10.10.100.101:80mode httpbalance firstserver web01 10.10.100.102:80 maxconn 2 weight 1 check inter 3000 fall 3 rise 5server web02 10.10.100.103:80 weight 1 check inter 3000 fall 3 rise 5#测试
[root@node1 ~]# while true; do curl http://10.10.100.101; sleep 0.1;done

动态算法

  1. roundrobin

基于权重进行轮询调度

支持慢启动(新加的服务器会逐渐增加转发数量)

每个后端backend中最多支持4095个RS

支持动态权重调整

listen web_80bind 10.10.100.101:80mode httpbalance roundrobinserver web01 10.10.100.102:80 weight 1 check inter 3000 fall 3 rise 5server web02 10.10.100.103:80 weight 1 check inter 3000 fall 3 rise 5#测试
[root@node1 ~]# while true; do curl http://10.10.100.101; sleep 1;done
web01 10.10.100.102
web02 10.10.100.103
web01 10.10.100.102
web02 10.10.100.103#动态调整权重
[root@node1 ~]# echo "get weight web_80/web01" |socat stdio /var/lib/haproxy/haproxy.sock1
1 (initial 1)[root@node1 ~]# echo "set weight web_80/web01 3" |socat stdio /var/lib/haproxy/haproxy.sock1[root@node1 ~]# echo "get weight web_80/web01" |socat stdio /var/lib/haproxy/haproxy.sock1
3 (initial 1)

​ 2.leastconn

连接数最少的服务器优先接收连接。

leastconn建议用于长会话服务,例如LDAP、SQL、TSE等,而不适合短会话协议。如HTTP.该算法是动态的,对于实例启动慢的服务器权重会在运行中调整。

listen web_80bind 10.10.100.101:80mode httpbalance leastconnserver web01 10.10.100.102:80 weight 1 check inter 3000 fall 3 rise 5server web02 10.10.100.103:80 weight 1 check inter 3000 fall 3 rise 5

其他算法

  1. source

    根据请求的源 IP 地址来决定将请求分配到哪个后端服务器。相同源 IP 的请求总是被分配到相同的服务器,适用于需要保持会话一致性的场景。

    map-base取模法:

    对源地址进行hash计算后在基于服务器的总权重进行取模 hash(sour_ip)%weight总

    作为静态算法,不支持慢启动和在线调整权重

    一致性hash算法(consistenet):

    当服务器的权重发生变化影响是局部的,不会造成较大变动

    作为动态算法,支持socat工具进行在线权重修改,支持慢启动

    算法具体步骤:

    1、后端服务器生成哈希环点 key=hash(后端服务器虚拟ip)%(2^32)

    2、客户机生成哈希环点 key=hash(前端客户机虚拟IP)%(2^32)

    3、将服务器和客户机生成的哈希环点都放到(0.2^32-1)组成的hash环上,客户机哈希环点顺时针访问最近的服务器哈希环点

    #map-base取模法
    listen web_80bind 10.10.100.101:80mode httpbalance sourceserver web01 10.10.100.102:80 weight 1 check inter 3000 fall 3 rise 5server web02 10.10.100.103:80 weight 1 check inter 3000 fall 3 rise 5#一致性hash算法
    listen web_80bind 10.10.100.101:80mode httpbalance source#指定使用一致性hashhash-type consistentserver web01 10.10.100.102:80 weight 1 check inter 3000 fall 3 rise 5server web02 10.10.100.103:80 weight 1 check inter 3000 fall 3 rise 5
    
  2. uri

    对用户请求的uri进行hash,再将hash后的结果基于总权重进行取模,根据最终结果选择请求的后端服务器

    hash(uri)%weight总

    算法基于应用层,只支持http、不支持tcp

  3. url_param

    url_param对⽤户请求的url中的params部分中的参数name(key)作hash计算,并由服务器总权重相除以后派发⾄某挑出的服务器。后端搜索同一个数据会被调度到同一个服务器

  4. hdr

    针对http头部请求中的指定信息进行hash,由服务器权重取模之后发送至跳出的服务器

高级功能及配置案例

主机名角色
192.168.84.141web1
192.168.84.142web2
192.168.84.140haproxy

基于cookie会话保持

为当前server指定cookie值,实现基于cookie的会话黏性,相对于基于 source 地址hash 调度算法对客户端的粒度更精准,但同时也加大了haproxy负载,目前此模式使用较少, 已经被session 共享服务器代替

#1、web1、web2中下载nginx,方便后续效果展示
yum install -y nginx
echo web2-192.168.84.142 > /usr/share/nginx/html/index.html
systemctl restart nginx#2、haproxy下载软件并进行相关配置
vim /etc/haproxy/conf.d/cookie.cfg
listen cookiebind *:80mode httpbalance roundrobincookie HAHA	insert nocache indirectserver web1 192.168.84.141:80 cookie web1 check inter 3 fall 3 rise 5 weight 1server web2 192.168.84.142:80 cookie web2 check inter 3 fall 3 rise 5 weight 1

测试:

image-20240811094400048

image-20240811094437212

image-20240811094736924

HAProxy状态页

通过web页面显示当前haproxy的状态

vim /etc/haproxy/conf.d
listen statsbind *:80mode httpbalance	static-rrstats enable			#基于默认参数启用stats pagstats uri /status		#设定uristats auth zhou:123		#设定用户登录账号密码server web1 192.168.84.141:80 check inter 3 fall 4 rise 5 weight 1server web2 192.168.84.142:80 check inter 3 fall 4 rise 5 weight 1

测试:

image-20240811095900190 image-20240811100328801

image-20240811100349519

IP透传

IP 透传指的是在网络通信中,允许一个数据包在经过中间设备或网络节点时,保留其原始的源 IP 地址和目的 IP 地址,而不被中间设备修改或替换。

四层IP透传
#1、#nginx 配置:在访问日志中通过变量$proxy_protocol_addr 记录透传过来的客户端IP
[root@web1 ~]# cat /etc/nginx/nginx.conf
http {log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" '' "$proxy_protocol_addr"' #记录透传过来的客户IP'"$http_user_agent" "$http_x_forwarded_for"';server {listen       80 proxy_protocol; #无法直接访问,只能走四层listen       [::]:80;server_name  _;root         /usr/share/nginx/html;#2、haproxy设置
[root@haproxy conf.d]# cat ip.cfg 
listen ipbind *:80mode tcp		#四层透传balance roundrobinserver web1 192.168.84.141:80 send-proxy check inter 3 fall 3 rise 5 weight 1server web2 192.168.84.142:80  check inter 3 fall 3 rise 5 weight 1
七层IP透传
#1、#nginx 配置:在访问日志中通过变量"$proxy_add_x_forwarded_for"
[root@web1 ~]# cat /etc/nginx/nginx.conf
http {log_format  main  '"$proxy_add_x_forwarded_for" - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';server {listen       80;listen       [::]:80;server_name  _;root         /usr/share/nginx/html;#2、haproxy设置
[root@haproxy conf.d]# cat ip.cfg 
listen ipbind *:80mode http		#七层透传balance roundrobinserver web1 192.168.84.141:80 send-proxy check inter 3 fall 3 rise 5 weight 1server web2 192.168.84.142:80  check inter 3 fall 3 rise 5 weight 1

ACL

#用acl来定义或声明一个acl
acl   <aclname> <criterion>   [flags]     [operator]   [<value>]
acl     名称     匹配规范       匹配模式     具体操作符   操作对象类型
匹配规范
基于HTTP请求头部的匹配
hdr([<name> [,<occ>]]):完全匹配字符串,header的指定信息,<occ> 表示在多值中使用的值的出
现次数
hdr_beg([<name> [,<occ>]]):前缀匹配,header中指定匹配内容的begin
hdr_end([<name> [,<occ>]]):后缀匹配,header中指定匹配内容end
hdr_dom([<name> [,<occ>]]):域匹配,header中的dom(host)
hdr_dir([<name> [,<occ>]]):路径匹配,header的uri路径
hdr_len([<name> [,<occ>]]):长度匹配,header的长度匹配
hdr_reg([<name> [,<occ>]]):正则表达式匹配,自定义表达式(regex)模糊匹配
hdr_sub([<name> [,<occ>]]):子串匹配,header中的uri模糊匹配 模糊匹配c 报文中a/b/c也会匹
配 
精确匹配
base:
#返回第一个主机头和请求的路径部分的连接,该请求从主机名开始,并在问号之前结束,对虚拟主机有用
<scheme>://<user>:<password>@#<host>:<port>/<path>;<params>#?<query>#<frag>base_beg:前缀匹配上述连接。
base_dir:子目录匹配上述连接。
base_dom:域匹配上述连接。
base_end:后缀匹配上述连接。
base_len:根据上述连接的长度进行匹配。
base_reg:使用正则表达式匹配上述连接。
base_sub:子串匹配上述连接。
URL部分匹配
path : string
#提取请求的URL路径,该路径从第一个斜杠开始,并在问号之前结束(无主机部分)
<scheme>://<user>:<password>@<host>:<port>#/<path>;<params>#?<query>#<frag>path     : exact string matchpath_beg : prefix match  #请求的URL开头,如/static、/images、/img、/csspath_end : suffix match  #请求的URL中资源的结尾,如 .gif .png .css .js .jpg .jpeg
path_dom:域匹配请求的 URL 路径。
path_dir:子目录匹配请求的 URL 路径。
path_len:根据请求的 URL 路径长度进行匹配。
path_reg:使用正则表达式匹配请求的 URL 路径。
path_sub:子串匹配请求的 URL 路径。
URL完整匹配
url:提取请求中的整个 URL。
url_beg:前缀匹配整个 URL。
url_dir:子目录匹配整个 URL。
url_dom:域匹配整个 URL。
url_end:后缀匹配整个 URL。
url_len:根据整个 URL 的长度进行匹配。
url_reg:使用正则表达式匹配整个 URL。
url_sub:子串匹配整个 URL。
IP、端口匹配
dst:匹配目标 IP 地址。
dst_port:匹配目标端口。
src:匹配源 IP 地址。
src_port:匹配源端口。
状态码匹配
status : integer  #返回在响应报文中的状态码
HTTP请求方法匹配
method : 请求方法
acl valid_method method GET HEAD
http-request deny if ! valid_method
匹配模式
-i 不区分大小写
-m 使用指定的正则表达式匹配方法
-n 不做DNS解析
-u 禁止acl重名,否则多个同名ACL匹配或关系
具体操作符
整数比较:eq、ge、gt、le、lt
字符比较:
- exact match     (-m str) :字符串必须完全匹配模式
- substring match (-m sub) :在提取的字符串中查找模式,如果其中任何一个被发现,ACL将匹配
- prefix match   (-m beg) :在提取的字符串首部中查找模式,如果其中任何一个被发现,ACL将匹配
- suffix match   (-m end) :将模式与提取字符串的尾部进行比较,如果其中任何一个匹配,则ACL进行
匹配
- subdir match   (-m dir) :查看提取出来的用斜线分隔(“/")的字符串,如其中任一个匹配,则ACL
进行匹配
- domain match   (-m dom) :查找提取的用点(“.")分隔字符串,如果其中任何一个匹配,则ACL进行
匹配
操作对象类型
- Boolean #布尔值
- integer or integer range #整数或整数范围,比如用于匹配端口范围
- IP address / network #IP地址或IP范围, 192.168.0.1 ,192.168.0.1/24
- string--> www.abc.orgexact #精确比较substring #子串suffix #后缀比较prefix #前缀比较subdir #路径, /wp-includes/js/jquery/jquery.jsdomain #域名,www.abc.org
- regular expression #正则表达式
- hex block #16进制
域名匹配示例
注:若要windows主机测试,则需提前做好主机host映射
#1、haproxy配置
[root@haproxy conf.d]# cat http.cfg 
frontend httpbind *:80mode httpacl webhost hdr_dom(host) www.zhou.com		 #定义acl规则use_backend test if webhost		 #达成webhost执行test、否则执行test1default_backend test1
backend testmode httpserver web1 192.168.84.141:80 check inter 3 fall 3 rise 5 weight 1
backend test1mode httpserver web2 192.168.84.142:80 check inter 3 fall 3 rise 5 weight 1

image-20240811111442569

基于源IP、子网调度
#1、haproxy操作
[root@haproxy conf.d]# cat http1.cfg 
frontend http1bind *:80mode http#IP地址为172.25.2254.2和1912.168.0.0/24都会访问web1acl webhost src 172.25.254.2 192.168.0.0/24use_backend test2 if webhostdefault_backend test3
backend test2mode httpserver web1 192.168.84.141:80 check inter 3 fall 3 rise 5 weight 1
backend test3mode httpserver web2 192.168.84.142:80 check inter 3 fall 3 rise 5 weight 1

image-20240811113102042

匹配浏览器类型
[root@haproxy conf.d]# cat http2.cfg 
frontend httpbind *:80mode httpacl webhost1 hdr_sub(User-Agent) -i wget#acl webhost1 hdr_sub(User-Agent) -i curlhttp-request deny if webhost1 #符合webhost1条件拒绝连接default_backend b
backend amode httpserver web1 192.168.84.141:80 check inter 3 fall 3 rise 5 weight 1
backend bmode httpserver web2 192.168.84.142:80 check inter 3 fall 3 rise 5 weight 1

image-20240811114140670

基于文件后缀实现动静分离
[root@haproxy conf.d]# cat http2.cfg 
frontend httpbind *:80mode httpacl url_static path_end -i .jpg .png .css .js .html #静态后缀aclacl url_php     path_end -i .php		#动态后缀acluse_backend static_host if url_staticuse_backend php_host if url_phpdefault_backend default_webserver
backend static_hostmode httpserver web1 192.168.84.141:80 check inter 3 fall 3 rise 5 weight 1
backend php_hostmode httpserver web2 192.168.84.142:80 check inter 3 fall 3 rise 5 weight 1
backend default_webservermode httpserver web2 192.168.84.143:80 check inter 3 fall 3 rise 5 weight 1

HAProxy错误页面

自定义页面错误
#1、制作错误显示内容文件
[root@haproxy ~]# mkdir -p /etc/haproxy/error   #自定义错误页面存储位置
[root@haproxy ~]#cp /usr/share/haproxy/503.http /etc/haproxy/error/503log.cfg
[root@haproxy ~]#vim /etc/haproxy/error/503log.cfg
HTTP/1.0 503 Service Unavailable^M
Cache-Control: no-cache^M
Connection: close^M
Content-Type: text/html^M
^M
<html><body><h1>503 Service Unavailable</h1>
******************************
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%.
</body></html>#2、更改配置文件
[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg defaultserrorfile 503 /etc/haproxy/error/503log.cfg  #指向自定义错误页面的文件位置

image-20240811131116804

重定向页面错误
#修改配置文件
[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg defaultserrorloc 503 https://www.baidu.com  #访问报错时直接转向百度页面

HAProxy的https实现

#配置HAProxy支持https协议,支持ssl会话;bind *:443 ssl crt /PATH/TO/SOME_PEM_FILE 
#指令 crt 后证书文件为PEM格式,需要同时包含证书和所有私钥cat demo.key demo.crt > demo.pem 
#把80端口的请求重向定443bind *:80redirect scheme https if !{ ssl_fc } 
#1、生成私钥和证书
[root@haproxy certs]# openssl req -newkey rsa:2048 -nodes -sha256 -keyout /etc/haproxy/certs/zy.key -x509 -days 365 -out /etc/haproxy/certs/zy.crt#2、将私钥和证书导入文件内
[root@haproxy certs]#cat  /etc/haproxy/certs/zy.key /etc/haproxy/certs/zy.crt > /etc/haproxy/zy.pem#3、配置haproxy文件
haproxy ~]# vim /etc/haproxy/haproxy.cfg
frontend webserverbind *:80redirect scheme https if !{ ssl_fc }mode httpuse_backend webcluster
frontend webserver-httpsbind *:443 ssl crt /etc/haproxy/zy.pemmode httpuse_backend webcluster
backend webclustermode httpbalance roundrobinserver web1 192.168.84.141:80 check inter 3s fall 3 rise 5server web2 192.168.84.142:80 check inter 3s fall 3 rise 5

http://www.hkcw.cn/article/ndGoGSZvOy.shtml

相关文章

清华大学杨诚最新Nature子刊

研究背景 电致变色&#xff08;Electrochromic, EC&#xff09;器件作为一种新兴的节能和调光技术&#xff0c;展示了动态调节光和热透射率的能力&#xff0c;是未来智能建筑、智能汽车天窗以及智能可穿戴设备的重要技术组成。然而&#xff0c;传统的EC器件的商业化面临着诸如…

【课程笔记】华为 HCIP-Cloud Computing 云计算08:OpenStack网络管理

OpenStack网络管理 目录 OpenStack网络管理 一、Linux网络虚拟化基础 二、Neutron简介 三、Neutron概念 四、Neutron架构 五、Neutron典型操作及流程 六、Neutron网络流量分析 一、Linux网络虚拟化基础 Linux下的网络虚拟化本质就是将原本物理网络中的网卡、物理虚拟机…

使用异步编程模型结合资源预测算法优化云计算环境下的任务调度与能耗管理技术详解

&#x1f493; 博客主页&#xff1a;瑕疵的CSDN主页 &#x1f4dd; Gitee主页&#xff1a;瑕疵的gitee主页 ⏩ 文章专栏&#xff1a;《热点资讯》 使用异步编程模型结合资源预测算法优化云计算环境下的任务调度与能耗管理技术详解 使用异步编程模型结合资源预测算法优化云计算…

云计算——云计算关键技术

作者简介&#xff1a;一名云计算网络运维人员、每天分享网络与运维的技术与干货。 座右铭&#xff1a;低头赶路&#xff0c;敬事如仪 个人主页&#xff1a;网络豆的主页​​​​​ 目录 前言 一.云计算关键技术 1.虚拟化技术 2.分布式数据存储技术 &#xff08;1&…

2024广东省职业技能大赛云计算——私有云(OpenStack)平台搭建

OpenStack搭建 前言 搭建采用双节点安装&#xff0c;即controller控制节点和compute计算节点。 CentOS7 系统选择 2009 版本&#xff1a;CentOS-7-x86_64-DVD-2009.iso 可从阿里镜像站下载&#xff1a;https://mirrors.aliyun.com/centos/7/isos/x86_64/ OpenStack使用竞赛培…

云计算时代的运维: 职业发展方向与岗位选择

✨✨ 欢迎大家来访Srlua的博文&#xff08;づ&#xffe3;3&#xffe3;&#xff09;づ╭❤&#xff5e;✨✨ &#x1f31f;&#x1f31f; 欢迎各位亲爱的读者&#xff0c;感谢你们抽出宝贵的时间来阅读我的文章。 我是Srlua&#xff0c;在这里我会分享我的知识和经验。&#x…

如何找到一条适合自己企业的发展之路?

一个创业型的企业&#xff0c;开始就需要面向市场&#xff0c;通过自己的服务或产品&#xff0c;帮助用户解决问题&#xff0c;为客户创造价值&#xff0c;通过为客户创造的价值&#xff0c;出创造一定的的现金流&#xff0c;让企业存活下来&#xff01; 企业的运营过程中&…

Github 热点 Github 热点 Syncthing:多台设备,持续同步文件,安全同步,隐私无忧!

今日推荐&#xff1a;syncthing Syncthing是一个开源、安全且易于使用的持续文件同步工具&#xff0c;可在多台计算机之间自动同步文件。 1prompt-eng-interactive-tutorial 今日星标 1211 总星标数 4273 主要语言 Jupyter Notebook https://github.com/anthropics/prompt-e…

K 值选对,准确率翻倍:KNN 算法调参的黄金法则

目录 一、背景介绍 二、KNN 算法原理 2.1 核心思想 2.2 距离度量方法 2.3 算法流程 2.4算法结构&#xff1a; 三、KNN 算法代码实现 3.1 基于 Scikit-learn 的简单实现 3.2 手动实现 KNN&#xff08;自定义代码&#xff09; 四、K 值选择与可视化分析 4.1 K 值对分类…

线程(上)【Linux操作系统】

文章目录 线程概念及其相关知识线程的概念及一些重要认识重要认识Linux中线程的实现Linux中的被调度的执行流是被task_struct描述的 线程是如何瓜分进程的代码和数据的&#xff1f;对于数据&#xff1a;对于代码&#xff1a; 线程的优点线程的缺点线程调度细节调度&#xff1a;…

定制开发开源AI智能名片S2B2C商城小程序:数字营销时代的话语权重构

摘要&#xff1a;在数据驱动的数字营销时代&#xff0c;企业营销话语权正从传统媒体向掌握用户数据与技术的平台转移。本文基于“数据即权力”的核心逻辑&#xff0c;分析定制开发开源AI智能名片S2B2C商城小程序如何通过技术赋能、场景重构与生态协同&#xff0c;帮助企业重构营…

【笔记】Windows 成功部署 Suna 开源的通用人工智能代理项目部署日志

#工作记录 本地部署运行截图 kortix-ai/suna&#xff1a; Suna - 开源通用 AI 代理 项目概述 Suna 是一个完全开源的 AI 助手&#xff0c;通过自然对话帮助用户轻松完成研究、数据分析等日常任务。它结合了强大的功能和直观的界面&#xff0c;能够理解用户需求并提供结果。其强…

哪些工作最容易被AI取代?

在 AI 技术狂飙突进的今天&#xff0c;一场 “职场大地震” 正在悄然酝酿。当 ChatGPT 能妙笔生花&#xff0c;当智能机器人开始站岗执勤&#xff0c;在这个 AI 飞速发展的时代&#xff0c;“饭碗危机” 已悄然降临。你是否想过&#xff0c;自己的工作是否也处在被 AI 取代的高…

二叉搜索树——AVL

AVL AVL定义AVL树出现的原因AVL的插入平衡因子的更新旋转左单旋右单旋左右双旋右左双旋 杂谈完整代码 AVL定义 AVL树是最先发明的⾃平衡⼆叉查找树&#xff0c;AVL是⼀颗空树&#xff0c;或者具备下列性质的⼆叉搜索树&#xff1a;它的左右⼦树都是AVL树&#xff0c;且左右⼦树…

Deepin 20.9社区版安装Docker

个人博客地址&#xff1a;Deepin 20.9社区版安装Docker | 一张假钞的真实世界 注意事项 Deepin 20.9 社区版安装 Docker 需要注意两点&#xff1a; 因为某些原因&#xff0c;Docker 官方源基本不可用&#xff0c;所以需要使用镜像源进行安装。当然也可以用安装包直接安装&am…

(7)-Fiddler抓包-Fiddler状态面板-QuickExec命令行

1.简介 Fiddler成了网页调试必备的工具&#xff0c;抓包看数据。Fiddler自带命令行控制&#xff0c;并提供以下用法。Fiddler的快捷命令框让你快速的输入脚本命令。 除了输入默认命令&#xff0c;也可以自定义命令&#xff0c;你可以通过编辑 FiddlerScript 来增加新命令&…

Linux --UDP套接字实现简单的网络聊天室

一、Server端的实现 1.1、服务端的初始化 ①、创建套接字&#xff1a; 创建套接字接口&#xff1a; #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> int socket(int domain, int type, int protocol); //1. 这是一个创建套接字的接…

OpenHarmony标准系统-HDF框架之音频驱动开发

文章目录 引言OpenHarmony音频概述OpenHarmony音频框图HDF音频驱动框架概述HDF音频驱动框图HDF音频驱动框架分析之音频设备驱动HDF音频驱动框架分析之supportlibs实现HDF音频驱动框架分析之hdi-passthrough实现HDF音频驱动框架分析之hdi-bindev实现HDF音频驱动加载过程HDF音频驱…

C#WinForm程序时方法很多时Form.cs文件会很长,如何分别写入多个文件,partial class的作用体现出来了。

右键->添加->类 类文件名称为 FormButtonClick.cs 双击button3&#xff0c;将Form1里button3的Click事件处理方法拷贝到FormButtonClick.cs里面。

关于win10系统中环境变量path变成一行显示的问题

怎么把环境变量从一行显示恢复成列表显示(原文链接在最下面&#xff0c;感谢) 一行显示&#xff08;调整了环境变量把C:\Windows\System64开头的挪到了后面或者删了就会这样&#xff09;&#xff1a; 只需在开头加上 C:\Windows\System64; 重新打开 就恢复成列表显示了 关于wi…