lvs+keepalived集群

来源:https://www.cnblogs.com/Xkf-IE/archive/2023/03/23/17245989.html
-Advertisement-
Play Games

使用lvs+keepalived架構架構實現後端web伺服器(該web伺服器要求搭建wordpress博客站)的負載均衡 最終客戶端訪問功能變數名稱 我的名字.wordpress.cn 能夠訪問搭建的博客站 ,達到負載均衡的目的 IP 主機名 角色 192.168.26.101 rs1 後端真實伺服器/ng ...


使用lvs+keepalived架構架構實現後端web伺服器(該web伺服器要求搭建wordpress博客站)的負載均衡

最終客戶端訪問功能變數名稱     我的名字.wordpress.cn 能夠訪問搭建的博客站 ,達到負載均衡的目的

IP 主機名 角色
192.168.26.101 rs1 後端真實伺服器/nginx
192.168.26.102 rs2 後端真實伺服器/nginx
192.168.26.103 master keepalived伺服器master 
192.168.26.104 backup keepalived伺服器backup
192.168.26.105 nfs Nfs伺服器
192.168.26.201 web 資料庫伺服器
192.168.26.12 cesi 客戶端

 

一.基礎環境搭建

1.1master配置

1.1.1安裝配置keepalived

[root@master ~]# yum -y install keepalived

[root@master ~]# cat /etc/keepalived/keepalived.conf

! Configuration File for keepalived
global_defs {
    router_id master
}

vrrp_instance VI_1 {
 state MASTER
 interface ens33
 virtual_router_id 51
 priority 150
 advert_int 1
 authentication {
     auth_type PASS
     auth_pass 1111
 } 
 virtual_ipaddress {
     192.168.26.222/24 dev ens33 label ens33:1
 }
}

virtual_server 192.168.26.222 80 {
 delay_loop 6
 lb_algo wrr
 lb_kind DR
 # persistence_timeout 50
 protocol TCP

 real_server 192.168.26.101 80 {
    weight 1
    HTTP_GET {
   url {
  path /
  status_code 200
  } 
   }
  connect_timeout 3
  nb_get_retry 3
  delay_before_retry 3
 }

 real_server 192.168.26.102 80 {
      weight 1
      HTTP_GET {
       url {
        path /
        status_code 200
        }
      }
       connect_timeout 3
       nb_get_retry 3
              delay_before_retry 3
 }
}
 1.1.2查看下ipvsadm -ln是否幫你自動添加了lvs集群規則
[root@master ~]# systemctl restart keepalived.service    #生效   
[root@master ~]# yum -y install ipvsadm                   
[root@master ~]# ipvsadm -ln #查看當前ipvs模塊中記錄的連接
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.26.222:80 wrr
  -> 192.168.26.101:80            Route   1      0          0         
  -> 192.168.26.102:80            Route   1      0          0         

 

1.2Backup配置
[root@backup ~]#  yum -y install keepalived
[root@backup ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
    router_id backup
}

vrrp_instance VI_1 {
 state BACKUP
 interface ens33
 virtual_router_id 51
 priority 100
 advert_int 1
 authentication {
     auth_type PASS
     auth_pass 1111
 }
 virtual_ipaddress {
     192.168.26.222/24 dev ens33 label ens33:1
 }
}

virtual_server 192.168.26.222 80 {
 delay_loop 6
 lb_algo wrr
 lb_kind DR
 # persistence_timeout 50
 protocol TCP

 real_server 192.168.26.101 80 {
    weight 1
    HTTP_GET {
   url {
  path /
  status_code 200
  }
   }
  connect_timeout 3
  nb_get_retry 3
  delay_before_retry 3
 }

 real_server 192.168.26.102 80 {
      weight 1
      HTTP_GET {
       url {
        path /
        status_code 200
        }
      }
       connect_timeout 3
       nb_get_retry 3
              delay_before_retry 3
 }

[root@backup ~]# systemctl restart keepalived.service

[root@master ~]# systemctl restart keepalived.service

[root@master ~]# yum -y install ipvsadm

[root@backup ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.26.222:80 wrr
  -> 192.168.26.101:80            Route   1      0          0         
  -> 192.168.26.102:80            Route   1      0          0   



 

1.3Rs1 安裝nginx 添加虛擬IP arp抑制

#關閉防火牆和slinux
[root@rs1 ~]# systemctl stop firewalld.service
[root@rs1 ~]# setenforce 0
[root@rs1 ~]# yum -y install nginx


[root@rs1 ~]# echo "rs1" > /usr/share/nginx/html/index.html [root@rs1 ~]# systemctl enable --now nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. [root@rs1 ~]# curl 127.0.0.1 rs1 [root@rs1 ~]# ip addr add 192.168.26.222/32 dev ens33 label ens33:1 [root@rs1 ~]# vim /etc/sysctl.conf #在末尾插入 [root@rs1 ~]# sysctl -p net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2

1.4RS2同上

[root@rs2 ~]# systemctl stop firewalld.service 
[root@rs2 ~]# setenforce 0
[root@rs2 ~]# yum -y install nginx

[root@rs2 ~]# echo "rs2" > /usr/share/nginx/html/index.html
[root@rs2 ~]# systemctl enable --now nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@rs2 ~]#  ip addr add 192.168.26.222/32 dev lo label lo:1
[root@rs2 ~]# curl 127.0.0.1
rs2
[root@rs2 ~]# vim /etc/sysctl.conf
[root@rs2 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2


 

 1.5測試

二.實現後端伺服器上運行wordpress博客站點

2.1Rs1  rs2繼續配置 都配置PHP環境(編譯安裝

[root@rs1 ~]# yum -y remove php-fpm php-mysqlnd php-json  #(刪除自帶yum安裝的)
Loaded plugins: fastestmirror
No Match for argument: php-fpm
No Match for argument: php-mysqlnd
No Match for argument: php-json
No Packages marked for removal
[root@rs1 ~]# yum -y install gcc openssl-devel libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel
[root@rs1 ~]# cd /usr/local/src
[root@rs1 src]# wget https://www.php.net/distributions/php-7.4.11.tar.xz --2023-03-23 15:56:56-- https://www.php.net/distributions/php-7.4.11.tar.xz Resolving www.php.net (www.php.net)... 185.85.0.29, 2a02:cb40:200::1ad Connecting to www.php.net (www.php.net)|185.85.0.29|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10302076 (9.8M) [application/octet-stream] Saving to: ‘php-7.4.11.tar.xz’ 100%[============================================================================================>] 10,302,076 2.26MB/s in 4.6s 2023-03-23 15:57:02 (2.16 MB/s) - ‘php-7.4.11.tar.xz’ saved [10302076/10302076] [root@rs1 src]# tar xf php-7.4.11.tar.xz [root@rs1 src]# cd php-7.4.11/

#編譯安裝
[root@rs1 php-7.4.11]# ./configure --prefix=/usr/local/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
[root@rs1 php-7.4.11]# make -j 8 && make install
[root@rs1 php-7.4.11]# cp /usr/local/src/php-7.4.11/php.ini-production /etc/php.ini
[root@rs1 php-7.4.11]# cd /usr/local/php74/etc/
[root@rs1 etc]# cp php-fpm.conf.default php-fpm.conf
[root@rs1 etc]# pwd
/usr/local/php74/etc
[root@rs1 etc]# cd php-fpm.d/
[root@rs1 php-fpm.d]# cp www.conf.default www.conf
[root@rs1 php-fpm.d]# vim www.conf

user = nginx

group = nginx

打開

listen.allowed_clients = 127.0.0.1

pm.status_path = /status

[root@rs1 php-fpm.d]#  /usr/local/php74/sbin/php-fpm -t
[23-Mar-2023 16:07:09] NOTICE: configuration file /usr/local/php74/etc/php-fpm.conf test is successful

[root@rs1 php-fpm.d]#  /usr/local/php74/sbin/php-fpm
[root@rs1 php-fpm.d]#  ss -ntl
State      Recv-Q Send-Q                      Local Address:Port                                     Peer Address:Port              
LISTEN     0      128                             127.0.0.1:9000                                                *:*                  
LISTEN     0      128                                     *:80                                                  *:*                  
LISTEN     0      128                                     *:22                                                  *:*                  
LISTEN     0      100                             127.0.0.1:25                                                  *:*                  
LISTEN     0      128                                  [::]:80                                               [::]:*                  
LISTEN     0      128                                  [::]:22                                               [::]:*                  
LISTEN     0      100                                 [::1]:25                                               [::]:*                  
[root@rs1 php-fpm.d]# vim /etc/nginx/nginx.conf
功能變數名稱登錄

 

         index        index.php;

     # Load configuration files for the default server block.

        include /etc/nginx/default.d/*.conf;

插入   location ~ \.php$ {

   root html;

   fastcgi_pass 127.0.0.1:9000;

   fastcgi_index index.php;

   fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;

   include fastcgi_params;

  }

 

[root@rs1 php-fpm.d]# systemctl restart nginx.service

 

2.2部署 WordPress

[root@rs1 ~]# wget https://cn.wordpress.org/wordpress-6.0.1-zh_CN.tar.gz
--2023-03-23 16:23:27--  https://cn.wordpress.org/wordpress-6.0.1-zh_CN.tar.gz
Resolving cn.wordpress.org (cn.wordpress.org)... 198.143.164.252
Connecting to cn.wordpress.org (cn.wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21933976 (21M) [application/octet-stream]
Saving to: ‘wordpress-6.0.1-zh_CN.tar.gz’

100%[============================================================================================>] 21,933,976  4.26MB/s   in 6.8s   

2023-03-23 16:23:35 (3.09 MB/s) - ‘wordpress-6.0.1-zh_CN.tar.gz’ saved [21933976/21933976]

[root@rs1 ~]# tar xf wordpress-6.0.1-zh_CN.tar.gz
[root@rs1 ~]# cp -r wordpress/* /usr/share/nginx/html/
[root@rs1 ~]# cd /usr/share/nginx/html/
[root@rs1 html]# cp wp-config-sample.php wp-config.php
[root@rs1 html]# vim wp-config.php

 

 
[root@rs1 html]# chown -R nginx.nginx .  #修改許可權所屬

 

2.3rocky安裝資料庫

[root@web ~]# systemctl stop firewalld.service
[root@web ~]# setenforce 0
[root@web ~]# curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
[root@web ~]# bash mariadb_repo_setup --mariadb-server-version=10.6
# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.6 is valid
# [info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo
# [info] Adding trusted package signing keys...
/etc/pki/rpm-gpg ~
~
# [info] Successfully added trusted package signing keys
# [info] Cleaning package cache...
25 文件已刪除
[root@web ~]# dnf -y install mariadb-server
[root@web ~]#  systemctl enable --now mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@web ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.6.12-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>  create database wordpress;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> create user wordpress@'192.168.26.%' identified by '123456';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all on wordpress.* to wordpress@'192.168.26.%';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit

 百度訪問RS1IP 192.168.26.101

 

 

 

 

2.4RS2配置

[root@rs2 ~]# yum -y remove php-fpm php-mysqlnd php-json
Loaded plugins: fastestmirror
No Match for argument: php-fpm
No Match for argument: php-mysqlnd
No Match for argument: php-json
No Packages marked for removal
[root@rs2 ~]# yum -y install gcc openssl-devel libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel

[root@rs2 src]# wget https://www.php.net/distributions/php-7.4.11.tar.xz --2023-03-23 15:56:56-- https://www.php.net/distributions/php-7.4.11.tar.xz Resolving www.php.net (www.php.net)... 185.85.0.29, 2a02:cb40:200::1ad Connecting to www.php.net (www.php.net)|185.85.0.29|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10302076 (9.8M) [application/octet-stream] Saving to: ‘php-7.4.11.tar.xz’ 100%[============================================================================================>] 10,302,076 2.26MB/s in 4.6s 2023-03-23 15:57:02 (2.16 MB/s) - ‘php-7.4.11.tar.xz’ saved [10302076/10302076] [root@rs2 src]# tar xf php-7.4.11.tar.xz [root@rs2 src]# cd php-7.4.11/


[root@rs2 php-7.4.11]# ./configure --prefix=/usr/local/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
[root@rs1 php-7.4.11]# make -j 8 && make install
[root@rs1 ~]#  scp /usr/local/php74/etc/php-fpm.conf [email protected]:/usr/local/php74/etc/
[email protected]'s password:
php-fpm.conf                                                                                        100% 5387     3.5MB/s   00:00    
[root@rs1 ~]# scp /usr/local/php74/etc/php-fpm.d/www.conf  [email protected]:/usr/local/php74/etc/php-fpm.d/
[email protected]'s password:
www.conf                                                                                            100%   19KB  11.1MB/s   00:00  


[root@rs2 php-7.4.11]# ls /usr/local/php74/etc/ php-fpm.conf php-fpm.conf.default php-fpm.d [root@rs2 php-7.4.11]# ls /usr/local/php74/etc/php-fpm.d/ www.conf www.conf.default [root@rs2 php-7.4.11]# vim /etc/nginx/nginx.conf

 


     index        index.php;


     # Load configuration files for the default server block.


        include /etc/nginx/default.d/*.conf;


插入   location ~ \.php$ {


   root html;


   fastcgi_pass 127.0.0.1:9000;


   fastcgi_index index.php;


   fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;


   include fastcgi_params;


  }

 

[root@rs2 php-7.4.11]# systemctl restart nginx.service
[root@rs2 php-7.4.11]# 

 

2.5NFS伺服器

  [root@nfs ~]# yum -y install nfs-utils


[root@nfs ~]# mkdir /code [root@nfs ~]# vim /etc/exports
/code * (rw)
[root@nfs
~]# chmod 777 /code/ [root@nfs ~]# systemctl start nfs-server.service

  客戶端rs1rs2 掛載

yum -y install nfs-utils

systemctl restart nfs-server

yum -y install rpcbind

systemctl enable --now nfs-server rpcbind

showmount -e 192.168.26.105 測試

Export list for 192.168.26.105:

/code *                    #以上rs1,2都執行

[root@rs1 ~]# tar zcf xkf.tar.gz /usr/share/nginx/html/
tar: Removing leading `/' from member names
[root@rs1 ~]# ls
\  anaconda-ks.cfg  wordpress  wordpress-6.0.1-zh_CN.tar.gz  xkf.tar.gz
[root@rs1 ~]# scp xkf.tar.gz [email protected]:/root

[root@nfs ~]# tar xf xkf.tar.gz
[root@nfs ~]# cd usr/share/nginx/html/
[root@nfs html]# cd ..
[root@nfs nginx]# mv html/* /code
[root@nfs nginx]# ls /code/
404.html  img          nginx-logo.png   wp-admin              wp-config-sample.php  wp-links-opml.php  wp-settings.php
50x.html  index.html   poweredby.png    wp-blog-header.php    wp-content            wp-load.php        wp-signup.php
en-US     index.php    readme.html      wp-comments-post.php  wp-cron.php           wp-login.php       wp-trackback.php
icons     license.txt  wp-activate.php  wp-config.php         wp-includes           wp-mail.php        xmlrpc.php
[root@rs1 ~]# mount -t nfs 192.168.26.105:/code /usr/share/nginx/html/
[root@rs1 ~]# df -Th
192.168.26.105:/code    nfs4       40G  1.7G   39G   5% /usr/share/nginx/html

[root@rs2 php-7.4.11]# showmount -e 192.168.26.105
Export list for 192.168.26.105:
/code *
[root@rs2 php-7.4.11]# mount -t nfs 192.168.26.105:/code /usr/share/nginx/html/
[root@rs2 php-7.4.11]# df -Th
192.168.26.105:/code    nfs4       40G  1.7G   39G   5% /usr/share/nginx/htm

 

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 說明 使用 VLD 記憶體泄漏檢測工具輔助開發時整理的學習筆記。 1. 使用前的準備 參考本人另一篇博客 安裝 Visual Leak Detector 下載 vld-2.5.1-setup.exe 並按步驟安裝 VLD。這一種使用方式的特點是,在一臺電腦上安裝完成後,將 VLD 安裝目錄下的 lib ...
  • ​1 導庫 import re 2 使用模板 re_pattern = re.compile(pattern, flags=0) result = re.findall(re_pattern,string) 3 說明 參數 描述 pattern 匹配的正則表達式,如 r'abc' 可用來匹配abc ...
  • Salt安裝部署 一:salt簡介 ​ 早期運維人員會根據自己的生產環境來寫特定腳本完成大量重覆性工作,這些腳本複雜且難以維護。系統管理員面臨的問題主要是1、系統配置管理,2、遠程執行命令,因此誕生了很多開源軟體,系統維護方面有fabric、puppet、chef、ansible、saltstack ...
  • """ 需求1:會員卡充值 金額只能輸入數字和浮點數、不能輸入負數 充值100(包含100)金額提示:成功充值N元,恭喜你成為普通會員 充值100.01(包含100.01)至200金額提示:成功充值N元,恭喜你成為鉑金會員 充值200.01(包含100.01)至300金額提示:成功充值N元,恭喜你成 ...
  • 本人是一家小公司的技術總監,工作包括寫市場分析、工作彙報、產品推廣文案及代碼開發等。在ChatGPT推出之後本人一直在工作中使用,在頭腦風暴、大綱生成、語句優化、代碼生成方面很有效果。但ChatGPT在一些常識性生成方面並不理想,比如某個省有哪些旅游景點、三角數學公式推算等,大家使用中一定要註意並仔 ...
  • .NET Core WebApi介面ip限流實踐 前言 之前一直想實現介面限流,但一直沒去實現,然後剛好看到一篇文章是基於AspNetCoreRateLimit 組件的限流策略。這個組件不做多的介紹,想瞭解詳情可以去訪問官方網址或者原文地址,地址在文章底部,本文只講實現。 實現介面限流步驟 導包 第 ...
  • 當前的Winform分頁控制項中,當前導出的數據一般使用Excel來處理,Excel的文檔可以用於後期的數據展示或者批量導入做準備,因此是比較好的輸入輸出格式。但是有框架的使用客戶希望分頁控制項能夠直接導出PDF,雖然Excel也可以直接轉換為PDF,不過直接導出PDF的處理肯定更加方便直觀。因此整理了... ...
  • 1. 核心關註點 1.1. 開發軟體的原因 2. 切麵關註點 2.1. 所有的代碼領域都需要處理相關的問題 3. 結構化模式 3.1. 裝飾器模式 3.1.1. 可以在現有對象上添加新的功能,而不改變其結構 3.2. 代理模式 3.2.1. 所提供的對象可以替代客戶端使用的實際服務對象 4. 使用P ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...