8.14-LVS主从+nginx的haproxy+mysql的haproxy+读写分离

news2024/9/21 22:36:45

一、LVS-主从数据库

# nat
# 添加规则
[root@DS ~]# ipvsadm -A -t 192.168.2.130:3306 -s rr
[root@DS ~]# ipvsadm -a -t 192.168.2.130:3306 -r 192.168.2.40:3306 -m
[root@DS ~]# ipvsadm -a -t 192.168.2.130:3306 -r 192.168.2.42:3310 -m
[root@DS ~]# 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.2.130:3306 rr
  -> 192.168.2.40:3306            Masq    1      0          0         
  -> 192.168.2.42:3310            Masq    1      0          0   
# 修改文件
[root@DS ~]# vim /etc/sysctl.conf
[root@DS ~]# sysctl -p
net.ipv4.ip_forward = 1
​
# 主数据库-添加网关
[root@master ~]# route del default
[root@master ~]# route add default gw 192.168.2.60
​
# 从数据库-添加网关
[root@slave ~]# route del default
[root@slave ~]# route add default gw 192.168.2.60
​
# 主数据库-创建用户
[root@master ~]# mysql -pHui@2003
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 8.0.33 MySQL Community Server - GPL
​
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
​
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
​
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
​
mysql> create user 'aaaa'@'%' identified by 'aaaa';
Query OK, 0 rows affected (0.03 sec)
​
mysql> grant all on *.* to 'aaaa'@'%';
Query OK, 0 rows affected (0.01 sec)
​
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
​
# 客户端测试
./mysql -h192.168.2.130 -P3306 -uaaaa -paaaa
show variables like 'server_id';

二、nginx的负载均衡

# 安装ntpdate
[root@haproxy ~]# yum -y install ntpdate.x86_64 
# 同步时间
[root@haproxy ~]# ntpdate cn.ntp.org.cn
14 Aug 10:22:43 ntpdate[1512]: adjust time server 203.107.6.88 offset 0.002669 sec
# 启动服务
[root@haproxy ~]# systemctl start ntpdate.service 
# 设置开机启动
[root@haproxy ~]# systemctl enable ntpdate.service 
# 安装haproxy
[root@haproxy ~]# yum -y install haproxy
# 修改配置文件
[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg 
63行 frontend  main *:80 # 把5000改为80
67行 # use_backend static          if url_static  # 注释
68行 default_backend             web # 把app改为web
86行:添加内容
backend web
        balance roundrobin
        server  weba 192.168.2.101:80 check
        server  webb 192.168.2.102:80 check
        
# 启动服务
[root@haproxy ~]# systemctl start haproxy.service 
# 设置开机自启
[root@haproxy ~]# systemctl enable haproxy.service 
# 本机测试
[root@haproxy ~]# curl 192.168.2.70
web===01
[root@haproxy ~]# curl 192.168.2.70
web===02
​
# 添加内容
[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg 
# 定义web管理界面
listen statistics
       bind   *:9090       #定义监听端口
       mode   http        #默认使用协议
       stats   enable    #启用stats
       stats   uri /hadmin?stats   #自定义统计页面的url
       stats   auth admin:admin   #统计页面的账号密码
       stats   hide-version   #隐藏在统计页面上
       stats   refresh 30s  # 统计页面自动刷新时间
       stats   admin if TRUE    # 如果认证通过就做管理功能,可以管理后端服务器
       stats   realm hapadmin   #统计页面密码框上提示文件,默认haproxy\statistics
       
# 重启服务
[root@haproxy ~]# systemctl restart haproxy.service 
​

浏览器访问:192.168.2.70:9090

关闭web02的nginx服务

[root@web02 ~]# nginx -s stop

# 设置权重
​
[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg 
​
backend web
        balance roundrobin
        server  weba 192.168.2.101:80 weight 8 check
        server  webb 192.168.2.102:80 weight 2 check
​
[root@haproxy ~]# systemctl restart haproxy.service 

浏览器访问:192.168.2.70

三、数据库的负载均衡

haproxy

[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg 
42 defaults
43    mode                    tcp  # 将http改为tcp
67    #use_backend static          if url_static # 注释
68    default_backend             mysql # 将web改为mysql
91    添加内容
backend mysql
        balance roundrobin
        server  master 192.168.2.40:3306 check
        server  master 192.168.2.42:3310 check
[root@haproxy ~]# systemctl restart haproxy.service 

主数据库-master

# 主数据库-创建用户
[root@master ~]# mysql -pHui@2003
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 49
Server version: 8.0.33 MySQL Community Server - GPL
​
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
​
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
​
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
​
mysql> create user 'aaaa'@'%' identified by 'aaaa';
Query OK, 0 rows affected (0.03 sec)
​
mysql> grant all on *.* to 'aaaa'@'%';
Query OK, 0 rows affected (0.01 sec)
​
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

客户端测试

[root@client ~]# ls
anaconda-ks.cfg  mysql-8.0.33-linux-glibc2.12-x86_64.tar
[root@client ~]# tar -xf mysql-8.0.33-linux-glibc2.12-x86_64.tar 
[root@client ~]# tar -xf mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz 
[root@client ~]# ls
anaconda-ks.cfg
mysql-8.0.33-linux-glibc2.12-x86_64
mysql-8.0.33-linux-glibc2.12-x86_64.tar
mysql-8.0.33-linux-glibc2.12-x86_64.tar.xz
mysql-router-8.0.33-linux-glibc2.12-x86_64.tar.xz
mysql-test-8.0.33-linux-glibc2.12-x86_64.tar.xz
[root@client ~]# cp -r mysql-8.0.33-linux-glibc2.12-x86_64 /usr/local/mysql
[root@client ~]# cd /usr/local/mysql/
[root@client mysql]# ls
bin  docs  include  lib  LICENSE  man  README  share  support-files
[root@client mysql]# cd bin
[root@client bin]# ./mysql -h192.168.2.70 -P5000 -uaaaa -paaaa
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.33 MySQL Community Server - GPL
​
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
​
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
​
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
​
mysql> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 11    |
+---------------+-------+
1 row in set (0.01 sec)
​
mysql> quit
Bye
[root@client bin]# ./mysql -h192.168.2.70 -P5000 -uaaaa -paaaa
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 8.0.33 MySQL Community Server - GPL
​
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
​
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
​
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
​
mysql> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 10    |
+---------------+-------+
1 row in set (0.05 sec)

远程访问测试

四、读写分离

1.在生产中,查询和修改的比例为7:3,查询压力大,可以分出多的主机做查询,slave也是可以被查询,所以,可以将mysql做成高可用主从复制

2.用户发送请求服务器响应压力 (nginx,lvs,haproxy),但是web服务器要提供服务,需要从数据库读写数据,随着业务并发量的提高,单点mysql已经无法满足需求,所以需要配置一主一从,一主多从

3.对数据库的从服务是不用允许修改,否则M-S失效

4.读写分离

5.代码级别读写分离,另一种是中间件读写分析

1.mysql的主从复制

(1)主数据库

# master
​
1.rm -rf /etc/my.cnf
2.glibc下载解压
3.将解压后的文件移动到指定的/usr/local/mysql
4.mkdir /usr/local/mysql/mysl-files
5.user -r -s /sbin/nologin mysql
6.chown mysql:mysql /usr/local/mysql/mysql-files
7.chmod 750 /usr/local/mysql/mysql-files
8./usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/
9.查看data目录和初始密码
10./usr/local/mysql/bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
11.配置文件
[root@master ~]# vim /usr/local/mysql/my.cnf 
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3306
log-error=/usr/local/mysql/data/db01-master.err
log-bin=/usr/local/mysql/data/binlog
server-id=10
character_set_server=utf8mb4
12.cp support-files/mysql.server /etc/init.d/mysql8
13.service mysql8 start
14.sed -i '$aexport PATH=$PATH:/usr/local/mysql/bin' /etc/profile
15.source /etc/profile

(2)创建用户

16.mysql -h192.168.2.40 -P3306 -uhaha -phaha
17.create user 'aaaa'%'aaaa' identified by 'an'
18.grant all on *.* to 'aaaa';

(3)从数据库

# slave
​
1.rm -rf /etc/my.cnf
2.glibc下载解压
3.将解压后的文件移动到指定的/usr/local/mysql
4.mkdir /usr/local/mysql/mysl-files
5.user -r -s /sbin/nologin mysql
6.chown mysql:mysql /usr/local/mysql/mysql-files
7.chmod 750 /usr/local/mysql/mysql-files
8.配置文件
[root@master ~]# vim /usr/local/mysql/my.cnf 
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
port=3310
log-error=/usr/local/mysql/data/mysql.log
log-log=/usr/local/mysql/data/relaylog
server-id=11
character_set_server=utf8mb4
9.cp support-files/mysql.server /etc/init.d/mysql8
10.sed -i '$aexport PATH=$PATH:/usr/local/mysql/bin' /etc/profile
11.source /etc/profile

(4)同步数据

1.yum -y install rsync 
2.service mysql8 stop 
3.master=> rm -rf /usr/local/mysql/data/auto.cnf
4.rsync -av /usr/local/mysql/data root@slaveip:/usr/local/mysql
5.slave=>service mysql8 start
6.master=>service mysql8 start

(5)设置主数据库

1.创建远程slave账号
create user 'slave'@'%' identified by 'slave';
​
grant replication slave on *.* to 'slave'@'%';
​
flush privileges;
2.锁表
flushtables with read lock;
3.查看主库信息
show master status\G;
​
•   1.文件名称
​
•   2.文件位置

(6)设置从数据库

1.设置change master to
mysql> change master to
    -> master_host='192.168.2.40',
    -> master_user='slave',
    -> master_password='slave_123',
    -> master_log_file='binlog.000006',
    -> master_log_pos=1547,
    -> get_master_public_key=1;
2.启动slave并且查看状态
start slave
​
show slave status\G
3.解锁
master=>unlock tables;

五、python代码的读写分离

1.环境配置

[root@client ~]# python3 -m pip install --upgrade pip
​
[root@client ~]# pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
​
[root@client ~]# pip3 install pymysql

2..安装pymysql是python管理mysql的驱动,或者成为连接器

[root@client ~]# pip3 install pymysql

3..在python3的命令行界面云如pymysql

>>> import pymysql

4.创建两个connection对象,一个指向master mysql,一个指向slave mysql

>>> import pymysql
>>> master_conn=pymysql.connect(host="192.168.2.40",user="aaaa",password="aaaa",database="test",port=3306)
>>> slave_conn=pymysql.connect(host="192.168.2.42",user="aaaa",password="aaaa",database="test",port=3310)

5.master-主数据库

(1)获取数据游标

语法:
master_cursor=master_conn.cursor()

(2)执行查询

语法:
select_sql="select * from user";
master_cursor.execute(select_sql);
rs=master_cursor.fetchall()
练习:
>>> master_cursor=master_conn.cursor()
>>> select_sql="select * from user";
>>> master_cursor.execute(select_sql);
4
>>> rs=master_cursor.fetchall()
>>> rs
((1, 'zhangsan', '123'), (2, 'lisi', '456'), (3, 'wangwu', '789'), (4, 'zhaoliu', 'aaa'))
在数据中查看
mysql> select * from user;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | zhangsan | 123      |
|  2 | lisi     | 456      |
|  3 | wangwu   | 789      |
|  4 | zhaoliu  | aaa      |
+----+----------+----------+
4 rows in set (0.00 sec)
​

(3)执行修改

语法:
update_sql="update user set password='000' where username='aaa'"
master_cursor.execute(update_sql)
master_conn.commit()
练习:
>>> update_sql="update user set password='rrr' where username='lisi'"
>>> master_cursor.execute(update_sql)
1
>>> master_conn.commit()
在数据中查看
mysql> select * from user;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | zhangsan | 123      |
|  2 | lisi     | rrr      |
|  3 | wangwu   | 789      |
|  4 | zhaoliu  | aaa      |
+----+----------+----------+
4 rows in set (0.01 sec)

(4)执行删除

语法:
delete_sql="delete user from user where username='aaaa'"
master_cursor.execute(delete_sql)
master_conn.commit()
练习:
>>> delete_sql="delete user from user where username='haha'"
>>> master_cursor.execute(delete_sql)
1
>>> master_conn.commit()
在数据中查看
mysql> select * from user;
+------+----------+----------+
| id   | username | password |
+------+----------+----------+
|    1 | zhangsan | 123      |
|    2 | lisi     | rrr      |
|    3 | wangwu   | 789      |
|    4 | zhaoliu  | aaa      |
| 1004 | haha     | a1b2     |
+------+----------+----------+
5 rows in set (0.00 sec)
​
mysql> select * from user;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | zhangsan | 123      |
|  2 | lisi     | rrr      |
|  3 | wangwu   | 789      |
|  4 | zhaoliu  | aaa      |
+----+----------+----------+
4 rows in set (0.00 sec)

(5)执行新增

语法:
insert_sql="insert into user values(1004,'dddd','dddd')"
master_cursor.execute(insert_sql)
master_conn.commit()
练习:
>>> insert_sql="insert into user values(1004,'haha','a1b2')"
>>> master_cursor.execute(insert_sql)
1
>>> master_conn.commit()
在数据中查看
mysql> select * from user;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | zhangsan | 123      |
|  2 | lisi     | rrr      |
|  3 | wangwu   | 789      |
|  4 | zhaoliu  | aaa      |
+----+----------+----------+
4 rows in set (0.01 sec)
​
mysql> select * from user;
+------+----------+----------+
| id   | username | password |
+------+----------+----------+
|    1 | zhangsan | 123      |
|    2 | lisi     | rrr      |
|    3 | wangwu   | 789      |
|    4 | zhaoliu  | aaa      |
| 1004 | haha     | a1b2     |
+------+----------+----------+
5 rows in set (0.00 sec)
slave-从数据库
>>> # 执行查询,获得slave游标
... 
>>> slave_cursor=slave_conn.cursor()
>>> select_sql
'select * from user'
>>> slave_cursor.execute(select_sql)
4
>>> slave_cursor.fetchall()
((1, 'zhangsan', '123'), (2, 'lisi', 'rrr'), (3, 'wangwu', '789'), (4, 'zhaoliu', 'aaa'))
​

脚本-判断如果是select开头,就去slave执行,如果是其他的就去master执行

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

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

相关文章

javaweb学习笔记(8.10)

一、JS 1.1JS简介 Web标准:由3WC制订 三个组成部分: HTML---》网页的基础结构 CSS---》网页的表现效果 JavaScript---》网页的行为 简介:JS是一门跨平台、面向对象的脚本语言。用来控制网页行为的,使网页交互。 1.2JS的引入…

贷奇乐漏洞学习 --- 两个变态WAF绕过

代码分析 第一个WAF 代码 function dowith_sql($str) {$check preg_match(/select|insert|update|delete|\|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/is, $str);if ($check) {echo "非法字符!";exit();}return $str;} 实现原理 这段PHP代码定义了一个…

Linux日常运维-主机名hosts

作者介绍:简历上没有一个精通的运维工程师。希望大家多多关注作者,下面的思维导图也是预计更新的内容和当前进度(不定时更新)。 本小章内容就是Linux进阶部分的日常运维部分,掌握这些日常运维技巧或者方法在我们的日常运维过程中会带来很多方…

探索消费新纪元:循环购模式的奥秘

在这个日新月异的消费时代,你是否听说过“消费1000送2000,每天领钱,提现无忧”的奇闻?或许你会疑惑,商家这是在慷慨解囊,还是在布下什么神秘的局?今天,让我作为你的私域电商向导&…

Linux应用--IO多路复用

一、I/O多路复用简介 socket通信,在Linux系统其是就是文件描述符,对应于内核中的缓冲区(包含读缓冲区与写缓冲区),实质上是对读写缓冲区的操作;多路复用,多条路复用成一条路。 I/O多路复用使得程…

爬虫动态http代理ip:提高数据抓取的有效工具

爬虫动态HTTP代理IP的概述与应用 在网络爬虫的世界中,动态HTTP代理IP是一个非常重要的工具。它不仅能帮助用户提高数据抓取的效率,还能有效避免被目标网站封禁。本文将为您详细介绍什么是动态HTTP代理IP、其优势、使用场景及如何获取和配置。 1. 什么是…

NVDLA专题8:具体模块介绍——Convolution Accumulator

概述 卷积累加器(Convolution Accumulator&#xff0c; CACC)是CMAC之后的卷积流水线的一个阶段,CACC的定义在NV_NVDLA_cacc.v&#xff0c;module定义如下&#xff1a; module NV_NVDLA_cacc (cacc2sdp_ready //|< i,csb2cacc_req_pd //|<…

ZooKeeper服务器下载|安装|配置|启动|关闭|端口占用冲突解决

1、下载ZooKeeper ZooKeeper官网&#xff1a;https://zookeeper.apache.org/ 下载ZooKeeper二进制包 2、安装ZooKeeper 对ZooKeeper压缩包解压即可 tar -zxvf apache-zookeeper-3.9.2-bin.tar.gz -C /usr/local/3、配置ZooKeeper 来到ZooKeeper配置文件页面 cd conf复制z…

一文详解ETC1压缩纹理——OpenGL中ETC1纹理加载与渲染实践

ETC1(Ericsson Texture Compression)是一种有损纹理压缩技术,2005年初由爱立信研究院参与研发,目的是用于减少移动设备和嵌入式系统中纹理存储的内存占用,应用场景见于游戏、VR、AR等需要大量的纹理资源来创建高质量的视觉效果以及复杂的动画效果场景。 ETC1可提供RGB888像…

宠物医院收银系统源码

1.系统开发语言 核心开发语言: PHP、HTML5、Dart 后台接口: PHP7.3 后合管理网站: HTML5vue2.0element-uicssjs 线下收银台&#xff08;安卓/Windows版&#xff09;: Dart3 框架&#xff1a;Flutter 3.19.6 助手: uniapp 商城: uniapp 2.系统概况 针对宠物医院的一套一体化收…

Unity 流光shader的思路

先看一下直线方程&#xff1a; 1.x0.5y0: 2.x0.5y20: 3.由上面的函数图像可以看出 zxky (k是常量)&#xff0c;表示所有斜率为k的直线集合&#xff0c;z是直线在x轴的截距&#xff0c;每个z的取值都确定一条唯一的斜率为k的直线。 4.那么给z一个取值范围就可以画出一条斜的条…

vulnhub系列:devguru

vulnhub系列&#xff1a;devguru 靶机下载 一、信息收集 nmap扫描存活&#xff0c;根据mac地址寻找IP nmap 192.168.23.0/24nmap扫描端口&#xff0c;开放端口&#xff1a;22、80、8585 nmap 192.168.23.147 -p- -sV -Pn -O访问80端口 dirb目录扫描&#xff0c;存在 git 源…

c shell 脚本学习使用

1.cd /进入该目录等 2.rm -rf filename 删除文件 3、ctrl allt 打开终端窗口 4、ls 查看该路径下的文件 5 mkdir filename 创建文件夹 6、sudo chmod 777 filename 给予权限 首先对于vcs而言&#xff0c;建立其脚本有以下几个步骤: 1、setup synopsys_sim.setu…

mysql中log

目录 MySQL 日志系统概述 日志类型 日志的作用和重要性 Mermaid图示 1. Undo Log 和 Redo Log 的协同工作图 2. Redo Log 确保持久性的流程图 Undo Log&#xff08;回滚日志&#xff09; 事务的原子性&#xff08;Atomicity&#xff09;保障 事务回滚机制 MVCC&#…

MySQL的初步认识

目录 1、MySQL的定义 2、数据库操作 2.1 创建数据库 2.2 查看数据库 2.3 选中数据库 2.4 删除数据库 3、数据表的操作 3.1 创建表 3.2 查看所有表 3.3 查看指定表结构 3.4 删除表 1、MySQL的定义 数据库技术主要是用来解决数据处理的非数值计算问题&#xff0c;数据处…

植物大战僵尸融合版

1.这是植物大战僵尸融合版 2.百度网盘 链接&#xff1a;https://pan.baidu.com/s/1yUytNeloiQs5tlss16fVOg 提取码&#xff1a;yspa 时间从2024年8月14号开始分享30天&#xff0c;10个人访问&#xff0c;先来先得。

项目管理软件中的项目集是什么?项目集管理哪些人适合学习?

在现今的数字化时代&#xff0c;项目管理软件已经成为企业高效运作不可或缺的工具。其中&#xff0c;项目集这一概念在项目管理领域内越来越受到重视。那么&#xff0c;项目管理软件中的项目集究竟是什么呢&#xff1f;它又适合哪些人进行学习和应用呢&#xff1f; 项目、大项目…

生信技能56 - 去除重复BAM文件的窗口reads计数方法

1. 输入去除重复的BAM文件 一般采用BWA MEM比对到参考基因组,对得到的BAM文件去除PCR重复,将去除重复的BAM文件作为窗口reads计数的输入文件。 去除重复方法参考本人文章: 生信软件23 - Samtools和GATK去除PCR重复方法汇总 2. 窗口文件制作 左到右列分别为: 染色体名…

RCE-无字母数字webshell命令执行

目录 1.源码 2.题目解析 3.利用方法 3.1 PHP7下如何实现 3.2PHP5下如何实现 3.2.1 shell下可以利用. 来执行任意脚本 3.2.2 Linux文件名支持用glob通配符代替 1.题目源码 <?php if(isset($_GET[code])){$code $_GET[code];if(strlen($code)>35){die(&q…

pytorch 3 计算图

计算图结构 分析&#xff1a; 起始节点 ab 5 - 3ac 2b 3d 5b 6e 7c d^2f 2e最终输出 g 3f - o&#xff08;其中 o 是另一个输入&#xff09; 前向传播 前向传播按照上述顺序计算每个节点的值。 反向传播过程 反向传播的目标是计算损失函数&#xff08;这里假设为…