nginx基本使用 linux(mac下的)

目錄結構

編譯后會有:conf html logs sbin 四個文件 (其他兩個是之前下載的安裝包)

  • conf:配置文件
  • html:頁面資源
  • logs:日志
  • sbin:啟動文件,nginx主程序

運行后多了文件<font style="color:rgb(51,51,51);">client_body_temp fastcgi_temp proxy_temp scgi_temp</font>

這些都是臨時文件,可忽略

運行原理


master主進程:

Worker為子進程

nginx配置基礎

  1. 基礎配置
# 工作worker子進程(小于cpu數:并行 -- 大于CPU數:并發)
worker_processes  1;# worker的最大連接
events {worker_connections  1024;
}http {# include:引入其他配置文件# mime.types:請求頭(發送類型)# default_type:默認發送類型include       mime.types;default_type  application/octet-stream;# 數據零拷貝sendfile        on;# 長連接 時間keepalive_timeout  65;# 虛擬主機vhost(nginx可配置多個主機)server {# nginx端口號listen       80;# 主機名server_name  localhost;# http://localhost:80/【localtion中的uri】location / {root   html;index  index.html index.htm;}# 服務器端發生錯誤的時候,轉到/50x.html地址頁面# 轉到/50x.html的時候后,會在html文件夾中,尋找50x.html頁面error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
}
  • <font style="color:rgb(38, 38, 38);background-color:rgb(245, 245, 245);">mime.types</font>請求頭類型
types {text/html                                        html htm shtml;text/css                                         css;text/xml                                         xml;image/gif                                        gif;image/jpeg                                       jpeg jpg;application/javascript                           js;application/atom+xml                             atom;application/rss+xml                              rss;text/mathml                                      mml;text/plain                                       txt;text/vnd.sun.j2me.app-descriptor                 jad;text/vnd.wap.wml                                 wml;text/x-component                                 htc;image/avif                                       avif;image/png                                        png;image/svg+xml                                    svg svgz;image/tiff                                       tif tiff;image/vnd.wap.wbmp                               wbmp;image/webp                                       webp;image/x-icon                                     ico;image/x-jng                                      jng;image/x-ms-bmp                                   bmp;font/woff                                        woff;font/woff2                                       woff2;application/java-archive                         jar war ear;application/json                                 json;application/mac-binhex40                         hqx;application/msword                               doc;application/pdf                                  pdf;application/postscript                           ps eps ai;application/rtf                                  rtf;application/vnd.apple.mpegurl                    m3u8;application/vnd.google-earth.kml+xml             kml;application/vnd.google-earth.kmz                 kmz;application/vnd.ms-excel                         xls;application/vnd.ms-fontobject                    eot;application/vnd.ms-powerpoint                    ppt;application/vnd.oasis.opendocument.graphics      odg;application/vnd.oasis.opendocument.presentation  odp;application/vnd.oasis.opendocument.spreadsheet   ods;application/vnd.oasis.opendocument.text          odt;application/vnd.openxmlformats-officedocument.presentationml.presentationpptx;application/vnd.openxmlformats-officedocument.spreadsheetml.sheetxlsx;application/vnd.openxmlformats-officedocument.wordprocessingml.documentdocx;application/vnd.wap.wmlc                         wmlc;application/wasm                                 wasm;application/x-7z-compressed                      7z;application/x-cocoa                              cco;application/x-java-archive-diff                  jardiff;application/x-java-jnlp-file                     jnlp;application/x-makeself                           run;application/x-perl                               pl pm;application/x-pilot                              prc pdb;application/x-rar-compressed                     rar;application/x-redhat-package-manager             rpm;application/x-sea                                sea;application/x-shockwave-flash                    swf;application/x-stuffit                            sit;application/x-tcl                                tcl tk;application/x-x509-ca-cert                       der pem crt;application/x-xpinstall                          xpi;application/xhtml+xml                            xhtml;application/xspf+xml                             xspf;application/zip                                  zip;application/octet-stream                         bin exe dll;application/octet-stream                         deb;application/octet-stream                         dmg;application/octet-stream                         iso img;application/octet-stream                         msi msp msm;audio/midi                                       mid midi kar;audio/mpeg                                       mp3;audio/ogg                                        ogg;audio/x-m4a                                      m4a;audio/x-realaudio                                ra;video/3gpp                                       3gpp 3gp;video/mp2t                                       ts;video/mp4                                        mp4;video/mpeg                                       mpeg mpg;video/quicktime                                  mov;video/webm                                       webm;video/x-flv                                      flv;video/x-m4v                                      m4v;video/x-mng                                      mng;video/x-ms-asf                                   asx asf;video/x-ms-wmv                                   wmv;video/x-msvideo                                  avi;
}
  • 開啟數據零拷貝工作比較

沒開啟sendfile:nginx讀取到html,然后存入緩存,接著將緩存內容發給網絡接口,網絡接口發送給互聯網

開啟sendfile:nginx不緩存html了,直接給網絡接口發送信號,讓網絡接口直接來讀取html,然后發送到互聯網

  • 全部配置
#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;server {listen       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}

虛擬主機配置

域名配置

將域名綁定ip

不同端口訪問不同資源

worker_processes  1;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       80;server_name  localhost;location / {root   /www/video;index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}server {listen       81;server_name  localhost;location / {root   /www/www;index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}}

不同域名訪問同一資源

匹配

不同的域名,都會匹配到80端口

    server {listen       80;server_name  www.xingheng.cn a.xingheng.cn;location / {root   /www/video;index  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
匹配規則
  1. 通配符匹配
server_name *.mmban.com
  1. 通配符結束匹配
server_name vod.*;
  1. 正則匹配
server_name ~^[0-9]+\.mmban\.com$;

反向代理

正向代理與反向代理

畫板

主要區別在于這兩種方式的作用不同,他們的本質其實是一樣的(請求轉發),代理代理,就是代替某個東西去做什么

  • 一個是代理客戶端,就是代理用戶,去訪問外網服務器
  • 一個是代理服務器,就是代理服務器,讓用戶可以訪問

代理規則

proxy_pass:代理路徑 – 有了proxy_pass就不會訪問root /www/video; index index.html index.html;

location / {root   /www/video;index  index.html index.htm;proxy_pass http://xingheng.com/;
}

基于反向代理的負載均衡

使用
# httpd是負載均衡組的名字,可自定義
upstream httpd {server 192.168.44.102:80;server 192.168.43.103:80;
}location / {root   /www/video;index  index.html index.htm;proxy_pass http://httpd  # 有這個上面的靜態資源就不訪問了}
常用策略
upstream httpd {server 127.0.0.1:8050 weight=10 down;server 127.0.0.1:8060 weight=1;server 127.0.0.1:8060 weight=1 backup;
}
  • weight:默認為1 weight越大,負載的權重就越大。
  • down:表示當前的server暫時不參與負載
  • backup: 其它所有的非backup機器down或者忙的時候,請求backup機器。(備用服務器)
了解策略
  • ip_hash:根據客戶端的ip地址轉發同一臺服務器,可以保持回話。
  • least_conn:最少連接訪問
  • url_hash:根據用戶訪問的url定向轉發請求
  • fair:根據后端服務器響應時間轉發請求

動靜分離

location配置靜態資源

server {listen       80;server_name  localhost;# / 的匹配優先級最低location / {proxy_pass http://127.0.0.1:8080;}# 匹配路徑是/js的路徑location /js {root   htmlindex  index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}
}

路徑匹配規則

location前綴規則

/ 通用匹配,任何請求都會匹配到。

= 精準匹配,不是以指定模式開頭

~ 正則匹配,區分大小寫

~* 正則匹配,不區分大小寫

^~ 非正則匹配,匹配以指定模式開頭的location

location匹配順序
  1. 多個正則location直接按書寫順序匹配,成功后就不會繼續往后面匹配
  2. 普通(非正則)location會一直往下,直到找到匹配度最高的(最大前綴匹配)
  3. 當普通location與正則location同時存在,如果正則匹配成功,則不會再執行普通匹配
  4. 所有類型location存在時,“=”匹配 > “^~”匹配 > 正則匹配 > 普通(最大前綴匹配)
location ~*/(css|img|js) {root /usr/local/nginx/static;index index.html index.htm;
}
alias與root
location /css/ {alias /usr/local/nginx/static/css/;index index.html index.htm;
}
location /css {alias /usr/local/nginx/static;index index.html index.htm;
}

alias和root指令功能類似,都是指定訪問的資源,不過配置上有些區別:

  1. **root**** 是“加在 URI 前面的前綴”
    **alias**
    **是“把整個 location 路徑替換掉”
  2. **root**** 通常用于匹配路徑不變的情況
    **alias**
    **用于重寫某段 URL 到另一路徑
  3. **root**/不敏感
    **alias**的路徑末尾最好加 /,否則容易匹配失敗
    例如:代碼中的代碼路徑,現在要訪問/css/style.css
    root是直接拼接/usr/local/nginx/static + /css/style.css
    alias是裁剪/css/style.css 匹配,裁剪location后的路徑/css/,變為style.css,然后將style.css拼接到/usr/local/nginx/static/css/后面

UrlRewrite

入門案例

location / {rewrite ^/xingheng/(.*)$ /index.jsp?pageName=$1 break;proxy_pass http://127.0.0.1:8080;
}

如果訪問呢的路徑匹配到了/xingheng,那么就轉向訪問http://127.0.0.1:8080/index.jsp?pageName=?路徑

也就是說,如果匹配到了rewirte終點額正則表達式,那么就會講后面的路徑拼接到proxy_pass中設置的路徑后面

規則

rewrite是實現URL重寫的關鍵指令,根據regex (正則表達式)部分內容,重定向到replacement,結尾是flag標記。

格式:

rewrite <regex> <replacement> [flag];

關鍵字:正則(regex) 替代內容(replacement) flag標記

關鍵字:其中關鍵字error_log不能改變

  • 正則:perl兼容正則表達式語句進行規則匹配
  • 替代內容:將正則匹配的內容替換成replacement
  • flag標記:rewrite支持的flag標記

rewrite參數的標簽段位置: <font style="color:rgb(51,51,51);">server,location,if </font>

flag標記說明:

  • last :本條規則匹配完成后,繼續向下匹配新的location URI規則
  • break :本條規則匹配完成即終止,不再匹配后面的任何規則
  • redirect :返回302臨時重定向,瀏覽器地址會顯示跳轉后的URL地址(就是真實地址會帶出來)
  • permanent :返回301永久重定向,瀏覽器地址欄會顯示跳轉后的URL地址

防盜鏈

防盜鏈概念

  1. 所謂盜鏈,就是別人直接在他們的網站上引用你網站的資源,比如這樣:
<img src="http://yourdomain.com/images/logo.png">

這樣一來,對方的網頁訪問者會去訪問你的服務器資源,消耗你的帶寬資源,卻不給你任何訪問量或廣告收益,所以我們需要防盜鏈

  1. referer

假設你在 https://a.com/index.html 這個頁面上,有一張圖片:

<img src="https://b.com/images/logo.png">

當用戶訪問 a.com/index.html 頁面時,瀏覽器會自動去加載圖片,這個時候對 b.com/images/logo.png 的請求里,HTTP 請求頭中會自動帶上:

Referer: https://a.com/index.html

也就是說,服務器 **b.com** 可以知道:訪問這張圖的是從 **a.com** 頁面跳過來的。

那么什么時候沒有refer呢?直接在瀏覽器頂部地址輸入對應的地址訪問就沒有referer啦

配置防盜鏈

  1. 配置案例
valid_referers 192.168.44.101;
if ($invalid_referer) {return 403;
}
  1. 詳細規則
valid_referers none | blocked | server_names | strings ....;
- `**<font style="color:#DF2A3F;">none</font>**`<font style="color:rgb(51,51,51);">, 檢測 Referer 頭域不存在的情況,如果不存在,那么就可以訪問(即使是本網站訪問也不行)</font>
- `<font style="color:rgb(51,51,51);">blocked</font>`<font style="color:rgb(51,51,51);">,檢測 Referer 頭域的值被防火墻或者代理服務器刪除或偽裝的情況。這種情況該頭域的值不以 “http://” 或 “https://” 開頭。 </font>
- `<font style="color:rgb(51,51,51);">server_names</font>`<font style="color:rgb(51,51,51);"> ,設置一個或多個 URL ,檢測 Referer 頭域的值是否是這些 URL 中的某一個。</font>

使用curl測試

安裝
yum install -y curl
常用命令
  1. 看某個地址能否訪問
curl -I http://192.168.44.101/img/logo.png
  1. 帶referer
# http://baidu.com就是refer
curl -e "http://baidu.com" -I http://192.168.44.101/img/logo.png

高可用配置

keepalive高可用原理

畫板

keepalive安裝

yum install -y keepalived

keepalive配置

  1. 打開文件
# 打開keeplived.conf
cd /etc/keepalived
vi keepalived.conf
  1. 配置文件

第一臺機器

! Configuration File for keepalivedglobal_defs {router_id lb111
}vrrp_instance VI_1 {# 當前機器是masterstate MASTER# 網卡名稱(改)interface enp0s5virtual_router_id 51# 優先級,競選成功的優先級priority 100# 間隔檢測時間advert_int 1# 多個keepalived通信配置(相同即可)authentication {auth_type PASSauth_pass 1111}# 虛擬地址(改)virtual_ipaddress {192.168.33.200}
}

注:interface需要改成自己的網卡地址,通過ip addr獲取

第二臺機器

! Configuration File for keepalivedglobal_defs {router_id lb111
}vrrp_instance VI_1 {# 當前機器是backupstate BACKUP# 網卡名稱interface enp0s5virtual_router_id 51# 優先級,競選成功的優先級priority 100# 間隔檢測時間advert_int 1# 多個keepalived通信配置(相同即可)authentication {auth_type PASSauth_pass 1111}# 虛擬地址virtual_ipaddress {192.168.33.200}
}
  1. 啟動服務
systemctl start keepalived

查看狀態:

systemctl status keepalived

查看現有ip:

! Configuration File for keepalivedglobal_defs {notification_email {acassen@firewall.locfailover@firewall.locsysadmin@firewall.loc}notification_email_from Alexandre.Cassen@firewall.locsmtp_server 192.168.200.1smtp_connect_timeout 30router_id LVS_DEVELvrrp_skip_check_adv_addrvrrp_strictvrrp_garp_interval 0vrrp_gna_interval 0
}vrrp_instance VI_1 {state MASTERinterface eth0virtual_router_id 51priority 100advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.200.16192.168.200.17192.168.200.18}
}virtual_server 192.168.200.100 443 {delay_loop 6lb_algo rrlb_kind NATpersistence_timeout 50protocol TCPreal_server 192.168.201.100 443 {weight 1SSL_GET {url {path /digest ff20ad2481f97b1754ef3e12ecd3a9cc}url {path /mrtg/digest 9b3a0c85a887a256d6939da88aabd8cd}connect_timeout 3retry 3delay_before_retry 3}}
}virtual_server 10.10.10.2 1358 {delay_loop 6lb_algo rrlb_kind NATpersistence_timeout 50protocol TCPsorry_server 192.168.200.200 1358real_server 192.168.200.2 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl3/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}connect_timeout 3retry 3delay_before_retry 3}}real_server 192.168.200.3 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334c}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334c}connect_timeout 3retry 3delay_before_retry 3}}
}virtual_server 10.10.10.3 1358 {delay_loop 3lb_algo rrlb_kind NATpersistence_timeout 50protocol TCPreal_server 192.168.200.4 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl3/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}connect_timeout 3retry 3delay_before_retry 3}}real_server 192.168.200.5 1358 {weight 1HTTP_GET {url {path /testurl/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl2/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}url {path /testurl3/test.jspdigest 640205b7b0fc66c1ea91c463fac6334d}connect_timeout 3retry 3delay_before_retry 3}}
}

Https證書配置

server
{listen 443 ssl http2 ;server_name www.xinghengdati.cn;ssl_certificate    /www/server/panel/vhost/cert/www.xinghengdati.cn/fullchain.pem;ssl_certificate_key    /www/server/panel/vhost/cert/www.xinghengdati.cn/privkey.pem;
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/89384.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/89384.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/89384.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

基于大眾點評的重慶火鍋在線評論數據挖掘分析(情感分析、主題分析、EDA探索性數據分析)

文章目錄 有需要本項目的代碼或文檔以及全部資源&#xff0c;或者部署調試可以私信博主項目介紹數據采集數據預處理EDA探索性數據分析關鍵詞提取算法情感分析LDA主題分析總結每文一語 有需要本項目的代碼或文檔以及全部資源&#xff0c;或者部署調試可以私信博主 項目介紹 本…

鴻蒙系統(HarmonyOS)應用開發之經典藍色風格登錄頁布局、圖文驗證碼

一、項目概述 本項目是一款基于鴻蒙 ArkTS&#xff08;ETS&#xff09;開發的用戶登錄頁面&#xff0c;集成了圖文驗證碼功能&#xff0c;旨在為應用提供安全、便捷的用戶身份驗證入口。項目采用現代化 UI 設計&#xff0c;兼顧用戶體驗與安全性&#xff0c;適用于多種需要用戶…

0.96寸OLED顯示屏 江協科技學習筆記(36個知識點)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 32 33 34 35 36

Flutter SnackBar 控件詳細介紹

文章目錄 Flutter SnackBar 控件詳細介紹基本特性基本用法1. 顯示簡單 SnackBar2. 自定義持續時間 主要屬性高級用法1. 帶操作的 SnackBar2. 自定義樣式3. 浮動式 SnackBar SnackBarAction 屬性實際應用場景注意事項完整示例建議 Flutter SnackBar 控件詳細介紹 SnackBar 是 F…

【C++】頭文件的能力與禁忌

在C中&#xff0c;?頭文件&#xff08;.h/.hpp&#xff09;?? 的主要作用是聲明接口和共享代碼&#xff0c;但如果不規范使用&#xff0c;會導致編譯或鏈接錯誤。以下是詳細總結&#xff1a; 一、頭文件中可以做的事情 1.1 聲明 函數聲明&#xff08;無需inline&#xff…

騰訊 iOA 零信任產品:安全遠程訪問的革新者

在當今數字化時代&#xff0c;企業面臨著前所未有的挑戰與機遇。隨著遠程辦公、多分支運營以及云計算的廣泛應用&#xff0c;傳統的網絡安全架構逐漸暴露出諸多不足。騰訊 iOA 零信任產品憑借其創新的安全理念和強大的功能特性&#xff0c;為企業提供了一種全新的解決方案&…

IP5219全集成Type-C移動電源SOC!2.1A快充+2.4A放電,極簡BOM方案

產品概述&#xff1a; IP5219是一款集成升壓轉換器、鋰電池充電管 理、電池電量指示和TYPE_C協議的多功能電源管 理SOC&#xff0c;為移動電源提供完整的電源解決方案。 IP5219的高集成度與豐富功能&#xff0c;使其在應用時 僅需極少的外圍器件&#xff0c;并有效減小整體方案…

報道稱CoreWeave洽談收購Core Scientific,后者漲超30%

CoreWeave與數字基礎設施公司Core Scientific的收購事宜可能在未來幾周內敲定交易&#xff0c;前提是雙方不出現重大分歧。消息傳出后&#xff0c;Core Scientific股價一度暫停交易&#xff0c;隨后恢復交易最終收漲逾32%。 AI云服務巨頭CoreWeave正與數字基礎設施公司Core Sc…

Qt5.15.2實現WebAssembly:2、設置emsdk目錄

步驟1 打開QT&#xff0c;編輯&#xff0c;Preference&#xff08;首選項&#xff09;&#xff1a; 設備&#xff0c;WebAssembly&#xff0c;游覽。 找到安裝好的emscripten目錄&#xff0c;選擇。 稍等一會&#xff0c;QT會解析出相應的信息&#xff0c;再點確定。 圖中…

SpringMVC--使用RESTFul實現用戶管理系統

一、靜態頁面準備 1. user.css .header {background-color: #f2f2f2;padding: 20px;text-align: center; }ul {list-style-type: none;margin: 0;padding: 0;overflow: hidden;background-color: #333; }li {float: left; }li a {display: block;color: white;text-align: ce…

hello算法_C++_ 最差、最佳、平均時間復雜度

算法的時間效率往往不是固定的&#xff0c;而是與輸入數據的分布有關。假設輸入一個長度為 的數組 nums &#xff0c;其中 nums 由從 1 至 n 的數字組成&#xff0c;每個數字只出現一次&#xff1b;但元素順序是隨機打亂的&#xff0c;任務目標是返回元素 的索引。我們可以…

2024考研數一真題及答案

歷年數一真題及答案下載直通車 已知函數 f ( x ) ∫ 0 x e cos ? t d t f(x) \int_0^x e^{\cos t} dt f(x)∫0x?ecostdt&#xff0c; g ( x ) ∫ 0 sin ? x e t 2 d t g(x) \int_0^{\sin x} e^{t^2} dt g(x)∫0sinx?et2dt&#xff0c;則&#xff08; &#xff09;。 A…

MIT 6.824學習心得(2) 淺談多線程和RPC

上篇文章中我們簡單介紹了分布式系統的設計思想以及簡單性質&#xff0c;之后用一定篇幅簡要介紹了MapReduce這個經典的分布式計算框架的大致工作原理&#xff0c;相信朋友們已經對此有了最基本的理解。在現實場景中&#xff0c;分布式系統的設計初衷是為了解決并發問題&#x…

opensuse/debian grub啟動界面太模糊?

現代操作系統或者新電腦使用那么模糊的界面啟動&#xff0c;雖然沒有什么不良反應&#xff0c;但是多少有點看不過去&#xff0c;這是因為為了保證正常啟動做出的適配。而我們可以對其分辨率進行選定。 1 您好&#xff0c;非常感謝您提供的截圖。這張圖片非常關鍵&#xff0c…

zookeeper Curator(5):集群架構和集群搭建

文章目錄 一、集群架構&#xff1a;Leader-Follower 模式二、核心機制&#xff1a;ZAB 協議三、Leader 選舉機制四、集群部署要點五、優勢與挑戰 Zookeeper 集群是一個由多個 Zookeeper 服務實例組成的分布式協調服務系統&#xff0c; 通過奇數個節點&#xff08;通常 3、5、7…

道可云人工智能每日資訊|浦東啟動人工智能創新應用競賽

道可云人工智能&元宇宙每日簡報&#xff08;2025年7月1日&#xff09;訊&#xff0c;今日人工智能&元宇宙新鮮事有&#xff1a; 江城模境工信部人工智能大模型公共服務平臺&#xff08;武漢&#xff09;上線運行 2025年6月27日&#xff0c;光谷人工智能創新大會在湖北…

Python元組的遍歷

一、前言 在 Python 中&#xff0c;元組&#xff08;tuple&#xff09; 是一種非常基礎且常用的數據結構&#xff0c;它與列表類似&#xff0c;都是有序的序列&#xff0c;但不同的是&#xff0c;元組是不可變的&#xff08;immutable&#xff09;&#xff0c;一旦創建就不能修…

矩陣的條件數(Condition Number of a Matrix)

文章目錄 矩陣的條件數&#xff08;Condition Number of a Matrix&#xff09;&#x1f4cc; 定義&#x1f9ee; 常見形式&#xff1a;2-范數下的條件數&#x1f50d; 條件數的意義&#x1f9e0; 實際意義舉例&#x1f4bb; Python 示例&#xff08;NumPy&#xff09;&#x1f…

1 Studying《Computer Architecture A Quantitative Approach》1-4

目錄 Preface 1 Fundamentals of Quantitative Design and Analysis 1.1 Introduction 1.2 Classes of Computers 1.3 Defining Computer Architecture 1.4 Trends in Technology 1.5 Trends in Power and Energy in Integrated Circuits 1.6 Trends in Cost 1.7 Depe…

Reactor Hot Versus Cold

這段文字詳細解釋了 Reactor 中 熱發布者&#xff08;Hot Publisher&#xff09; 和 冷發布者&#xff08;Cold Publisher&#xff09; 的區別&#xff0c;并通過示例展示了它們的行為差異。以下是對其含義的總結和解釋&#xff1a; 1. 冷發布者&#xff08;Cold Publisher&…