Squid简介

Squid是一个支持HTTP,HTTPS,FTP等服务的Web缓存代理软件,它可以通过缓存页面来提高服务器的相应速度并降低带宽占用。并且,Squid还具有强大的访问控制功能。Squid可以运行在各种操作系统平台上。

Squid会将访问页面的结果缓存在硬盘和内存上。所以Squid对硬盘和内存的空间大小具有较高的要求。内存和硬盘越大,缓存的命中率就越高。但是真实服务器数据是实时更新的,因此,我们就需要不定期的清空缓存数据以保证用户访问结果的准确性。

Squid 将数据元缓存在内存和硬盘中,同时也缓存 DNS 查询的结果。Squid 支持 SSL,支持访问控制。由于使用了 ICP(轻量 Internet 缓存协议),Squid 能够实现层叠的代理阵列,从而最大限度的节约带宽。

Squid Cache(简称 Squid)是一个流行的代理服务器和 Web 缓存服务器软件。Squid 可以做正向代理,也可以做反向代理。官方网站地址为:http://www.squid-cache.org/

Web代理功能
# 1. 将区域网中的主机保护起来
# 2. 对网站的内容缓存,加快客户端的访问速度,减少网络流量
# 3. 静态页面的站点越来越少,可缓存的内容也变少,因为数据库中的信息是不能被缓存.

常用代理服务器类型

代理服务器有多种类型,一般意义上常分为标准正向代理服务器,透明代理服务器,反向代理服务器.

正向代理服务器主要应用于内部网络希望访问外部网络时缓存页面数据, 由于公网IP地址稀缺,企业内部成百上千台计算机不可能同时大欧连接到Internet上,目前的解决方案就是通过一个统一的网络接口连接Internet。Squid就可以提供这样的接口。所有的客户端通过设置代理服务器连接值Squid,通过代理上网。此模型下,Squid主要负责提供缓存加速服务和访问控制的功能。正向代理是对用户的一种操作。

透明代理与传统的正向代理相似,区别在于传统的正向代理需要每个客户端都进行代理服务器的设置。而透明代理通过网关进行部署。即,所有的设置都是由管理员在网关服务器以及代理服务器进行的。因此,透明代理对于用户是透明的,不需要用户进行任何设置。

反向代理结合智能DNS可以实现基本的CDN框架。通过DNS的分离解析功能,可以为不同地区的DNS请求解析不同的结果返回给客户端。用户访问时,感觉不到是在访问代理服务器。由于使用到了缓存技术,当大的并发量到达时,Squid也可以更快的给用户返回响应结果。反向代理结构如下图所示。

Squid代理服务器原理

Squid原理:客户端访问Squid代理服务器,由代理服务器代表客户访问后端真实服务器,真实服务器将响应的数据返回给Squid代理服务器。最后,Squid代理服务器将响应结果返回给客户端,同时将结果缓存在硬盘上及内存中,当客户端再次访问相同的网页时,代理服务器直接将响应结果返回给客户端。

正向代理

当 Squid 做正向代理时,Squid 后面是客户端,客户端想访问外部网络资源,必须经过 Squid。正向代理按其客户端配置方式不同,又可以分为标准(普通)代理模式和透明代理模式。

标准(普通)代理模式,是代理内部网络用户访问 internet 上服务器的连接请求,客户端必须指定代理服务器,并将本来要直接发送到 internet 上服务器的连接请求发送给代理服务器处理。用户在上网时必须在浏览器等软件中填写代理服务器的 IP 地址与端口号信息,否则默认不使用代理。

透明代理模式,是相对于代理服务器而言,客户端不需要做任何和代理服务器相关的设置和操作,对用户而言,感觉不到代理服务器的存在,所以称之为透明代理。即把代理服务器部署在核心的上网出口,当用户上网浏览页面时,会交给代理服务器向外请求,如果结合iptables,可以实现代理+网关+内容过滤+流量安全控制等完整的上网解决方案。

部署Squid服务
yum -y install squid
systemctl restart squid
配置squid

可以使用squid默认的配置文件,因为默认的配置文件其实就已经设置了正向代理,也可以修改默认的配置文件,如下:

[root@squid ~]# cat /etc/squid/squid.conf
# 默认对外端口为3128
http_port 3128 cache_effective_user squid
cache_effective_group squid # 内网控制,按需修改
acl manager proto cache_object
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network # 配置可访问的端口
acl SSL_ports port 443
acl Safe_ports port 80 8080 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT # 允许本机访问
http_access allow manager localhost
http_access deny manager http_access deny !Safe_ports # 拒绝443以外的端口访问
http_access deny CONNECT !SSL_ports # 允许内网
http_access allow localnet
http_access allow localhost http_access allow all # 设置缓存文件位置、cache目录容量(单位M)、一级缓存目录数量、二级缓存目录数量
cache_dir ufs /var/spool/squid 128 16 256
cache_mem 128 MB
coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320 # 重启squid服务
systemctl restart squid
验证代理

可以使用浏览器设置代理的方式,也可以直接使用 curl 命令来测试,其中 -x 选项即 --proxy,添加代理服务器地址和端口,如下:

[root@squid ~]# curl  -xlocalhost:3128 www.baidu.com -I
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Fri, 29 May 2020 12:40:45 GMT
ETag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
X-Cache: MISS from squid
X-Cache-Lookup: MISS from squid:3128
Via: 1.1 squid (squid/3.5.20)
Connection: keep-alive
ACL访问控制

只允许 IP 地址为 39.108.140.0 的客户端使用服务器上的 squid 服务程序提供的代理服务,禁止其余所有的主机代理请求

编辑 /etc/squid/squid.conf,添加如下设置:

acl client src 39.108.140.0
http_access allow client
http_access deny all [root@blog ~]# curl -x49.233.69.195:3128 -I www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Fri, 29 May 2020 12:35:27 GMT
ETag: "575e1f60-115"
Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
X-Cache: MISS from squid
X-Cache-Lookup: MISS from squid:3128
Via: 1.1 squid (squid/3.5.20)
Connection: keep-alive # 我们试一下其他IP服务器
[root@jd ~]# curl -x49.233.69.195:3128 www.baidu.com -I
HTTP/1.1 403 Forbidden
Server: squid/3.5.20
Mime-Version: 1.0
Date: Fri, 29 May 2020 12:45:44 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 3513
X-Squid-Error: ERR_ACCESS_DENIED 0
Vary: Accept-Language
Content-Language: en
X-Cache: MISS from squid
X-Cache-Lookup: NONE from squid:3128
Via: 1.1 squid (squid/3.5.20)
Connection: keep-alive
禁止所有客户端访问网址包含baidu关键词网站

编辑 /etc/squid/squid.conf,添加如下设置

acl deny_keyword url_regex -i baidu
http_access deny deny_keyword systemctl restart squid curl -x49.233.69.195:3128 -I www.baidu.com
HTTP/1.1 403 Forbidden
Server: squid/3.5.20
Mime-Version: 1.0
Date: Fri, 29 May 2020 12:50:39 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 3511
X-Squid-Error: ERR_ACCESS_DENIED 0
Vary: Accept-Language
Content-Language: en
X-Cache: MISS from squid
X-Cache-Lookup: NONE from squid:3128
Via: 1.1 squid (squid/3.5.20)
Connection: keep-alive curl -x49.233.69.195:3128 -I https://www.cnblogs.com/you-men/
HTTP/1.1 200 Connection established HTTP/1.1 200 OK
Date: Fri, 29 May 2020 12:50:06 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Vary: Accept-Encoding
禁止下载带有某些后缀的文件,比如.rar和.avi
acl badfile urlpath_regex -i \.rar$ \.avi$
http_access deny badfile systemctl restart squid
# 此处就不测试了

反向代理

反向代理(Reverse Proxy)方式是指以代理服务器来接受 internet 上的连接请求,然后将请求转发给内部网络上的服务器,并将从内部服务器上得到的结果返回给 internet 上请求连接的客户端,此时代理服务器对外就表现为一个服务器。

网站页面是由静态资源和动态资源一起组成的,其中静态资源包括网站架构 CSS/js 文件、大量的图片、视频等数据,这些数据相对于动态资源来说更加稳定,一般不会经常发生改变。但是随着建站技术的更新换代,外加人们不断提升的审美能力,这些静态资源占据的网站空间也越来越多。如果能够把这些静态资源从网站页面中抽离出去,然后在全国各地部署静态资源的缓存节点,这样不仅可以提升用户访问网站的速度,而且网站源服务器也会因为这些缓存节点的存在而降低负载。

反向代理是 Squid 服务程序的一种重要模式,其原理是把一部分原本向网站源服务器发起的用户请求交给 Squid 服务器缓存节点来处理。但是这种技术的弊端也很明显,如果有心怀不轨的人将自己的域名和服务器反向代理到某个知名的网站上面,从理论上来讲,当用户访问到这个域名时,也会看到与那个知名网站一样的内容(有些诈骗网站就是这样骗取用户信任的)。因此,当前许多网站都默认禁止了反向代理功能。开启了 CDN(内容分发网络)服务的网站也可以避免这种窃取行为。如果访问开启了防护功能的网站,一般会提示 500 错误。

将端口号 "http_port 3128" 修改为 "http_port 80 accel vhost vport",此时正向解析会被暂停,它不能与反向代理服务同时使用,然后再增加你要代理的后端真实服务器的信息。

编辑 /etc/squid/squid.conf,添加如下设置:

配置squid
# 监听端口
# 修改端口80 accel vhost vport 为反向代理
http_port 80 accel vhost vport
# cache_peer 代理IP 端口 0 originserver name=a "a"代表一个域名
cache_peer 39.108.140.0 parent 80 0 originserver name=a
cache_peer 116.196.83.113 parent 80 0 originserver name=b
# 设置a的域名为 www.qq.com
#cache_peer_domain a www.qq.com
#cache_peer_domain b www.baidu.com
# acl权限控制
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80 8080 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow localhost
http_access allow all # 设置缓存文件位置、cache目录容量(单位M)、一级缓存目录数量、二级缓存目录数量
cache_dir ufs /var/spool/squid 128 16 256
cache_mem 128 MB
coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320 systemctl restart squid
# 我们访问squid,可以看到代理我另一台博客服务器去了

Squid常用命令选项

# 常用的选项就是上面提到的 squid -k check,squid -k reconfigure 和 squid -k parse,这些命令均可以简写成:

# squid -kche(或 squid -k che),表示检查 squid.conf 配置文件是否有语法或配置错误。

# squid -krec(或 squid -k rec),表示当 squid.conf 进行过配置更改后,可以使用该命令进行 squid 配置重载,而不用重启 squid 服务,相当于热加载。

# squid -kpar(或 squid -k par),表示如果 squid.conf 有语法或配置错误,这里会返回提示你,如果没有返回,尝试启动 squid。

Squid+HAProxy+Keepalived

使用HAProxy的目的

haproxy是负载均衡器,它可以将网络请求按一定算法均匀分布到各个代理服务器(这里指正向代理)上,防止压力都集中在某一个节点上,提高整体的服务的负载能力。

假设有103台主机需要出外网,其中只有2台能直接访问外网,那么我们接着假设这两台主机的IP分别是192.168.29.210, 192.168.29.211,且已经在上面安装好squid代理服务。 还有一台主机我们将其选做负载均衡所在的机器,假设其IP为192.168.29.212。

按上述做法,在其余100台主机上可以设置代理(IE “Internet选项->连接->局域网设置->代理服务器” )为192.168.29.212,haproxy负载均衡器会将网络请求按一定算法均匀打到192.168.29.210, 192.168.29.211两台代理服务器上。

安装配置Squid
yum -y install squid
cat /etc/squid/squid.conf
cat /etc/squid/squid.conf
acl localnet src 10.0.0.0/8
acl localnet src 172.16.0.0/12
acl localnet src 192.168.0.0/16
acl localnet src fc00::/7
acl localnet src fe80::/10
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 80
coredump_dir /var/spool/squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320 systemctl restart squid
curl -x192.168.0.103:80 www.baidu.com -I
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Sat, 30 May 2020 06:24:34 GMT
ETag: "575e1f59-115"
Last-Modified: Mon, 13 Jun 2016 02:50:01 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
X-Cache: MISS from squid-1
X-Cache-Lookup: MISS from squid-1:80
Via: 1.1 squid-1 (squid/3.5.20)
Connection: keep-alive
安装配置HAProxy
yum -y install haproxy
cat /etc/haproxy/haproxy.cfg
global
log 127.0.0.1 local2 chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
frontend http-in
bind *:8000
default_backend servers
backend servers
balance leastconn
server server1 192.168.171.134:80
server server2 192.168.171.141:80 systemctl restart haproxy curl -x192.168.171.141:8000 -I www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Sat, 30 May 2020 07:53:13 GMT
ETag: "575e1f5d-115"
Last-Modified: Mon, 13 Jun 2016 02:50:05 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
X-Cache: MISS from squid-1
X-Cache-Lookup: MISS from squid-1:80
Via: 1.1 squid-1 (squid/3.5.20)
安装配置Keepalived
yum -y install keepalived

cat /etc/keepalived/keepalived.conf
global_defs {
router_id node103
} vrrp_script chk_squid_port {
script "/etc/keepalived/scripts/check_squid.sh"
interval 2
weight 2
} vrrp_instance chk_squid {
state BACKUP
interface ens32
virtual_router_id 20
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass squid123
} track_script {
chk_squid_port
} virtual_ipaddress {
192.168.171.250
}
} mkdir -p /etc/keepalived/scripts/
mkdir -p /etc/keepalived/log/ cat /etc/keepalived/scripts/check_squid.sh
#!/bin/bash START_SQUID="systemctl start squid.service"
STOP_KEEPALIVED="systemctl stop keepalived.service"
LOGFILE="/etc/keepalived/log/keepalived-squid-state.log" HAPS=`ps -C squid --no-header |wc -l` if [ $HAPS -eq 0 ];then
echo $(date "+%Y-%m-%d %H:%M:%S") >> $LOGFILE
echo "start squid failed, killall keepalived" >> $LOGFILE
$STOP_KEEPALIVED fi
chmod a+x /etc/keepalived/scripts/check_squid.sh
systemctl restart keepalived curl -x192.168.171.250:80 -I www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Sat, 30 May 2020 07:48:47 GMT
ETag: "575e1f5d-115"
Last-Modified: Mon, 13 Jun 2016 02:50:05 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
X-Cache: MISS from squid-1
X-Cache-Lookup: MISS from squid-1:80
Via: 1.1 squid-1 (squid/3.5.20)
Connection: keep-alive # 我们模拟其中一台squid宕机, 虚拟IP会漂移到另一台机器,依然能提供服务支持
systemctl stopo squid

还有一种是如果正向代理服务器多, 可以用haproxy反代一下, 将正向代理的请求分发到不同的squid, 在haproxy的基础上做高可用

cat /etc/keepalived/keepalived.conf
global_defs {
router_id node104
} vrrp_script chk_http_port {
script "/etc/keepalived/scripts/check_haproxy.sh"
interval 2
weight 2
} vrrp_script chk_squid_port {
script "/etc/keepalived/scripts/check_squid.sh"
interval 2
weight 2
} vrrp_instance chk_squid {
state MASTER
interface ens32
virtual_router_id 20
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass squid123
} track_script {
chk_squid_port
} virtual_ipaddress {
192.168.171.250
}
} cat /etc/keepalived/scripts/check_haproxy.sh
#!/bin/bash START_HAPROXY="systemctl start haproxy"
STOP_KEEPALIVED="systemctl stop keepalived.service"
LOGFILE="/etc/keepalived/log/keepalived-haproxy-state.log" HAPS=`ps -C haproxy --no-header |wc -l` #如果没有haproxy进程存在,就启动haproxy,停止keepalived,并写入日志
#if [ $HAPS -eq 0 ];then
# echo $(date "+%Y-%m-%d %H:%M:%S") >> $LOGFILE
# echo $START_HAPROXY >> $LOGFILE
# $START_HAPROXY >> $LOGFILE 2>&1
# sleep 3
#fi if [ `ps -C haproxy --no-header |wc -l` -eq 0 ];then
echo $(date "+%Y-%m-%d %H:%M:%S") >> $LOGFILE
echo "start haproxy failed, killall keepalived" >> $LOGFILE
$STOP_KEEPALIVED
fi
chmod a+x /etc/keepalived/scripts/check_haproxy.sh
systemctl restart keepalived curl -x192.168.171.250:8000 -I www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Content-Length: 277
Content-Type: text/html
Date: Sat, 30 May 2020 08:08:33 GMT
ETag: "575e1f5c-115"
Last-Modified: Mon, 13 Jun 2016 02:50:04 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
X-Cache: MISS from squid-1
X-Cache-Lookup: MISS from squid-1:80
Via: 1.1 squid-1 (squid/3.5.20)

01 . Squid原理配置和使用的更多相关文章

  1. Tomcat数据源的原理,配置及使用(JNDI)

    Tomcat数据源的原理,配置及使用 知识点: 1.数据源的作用及操作原理; 2.Tomcat中数据源的配置; 3.数据源的查找及使用 传统JDBC使用过程存在以下四个步骤: 1.加载驱动程序 2.进 ...

  2. QM[中控群控云控]01. 中控原理

    QM[中控群控云控]01. 中控原理 虽然自己对于中控有了解 也自己做过一些简单中控 不过看看紫猫老师的思路 应该有很多帮助和提高 中控核心:数据交流而已 脚本端和服务端之间的信息交换 ------个 ...

  3. Squid 访问控制配置

    Squid 访问控制配置 主配置文件内加入限制参数 vim /etc/squid/squid.conf # 访问控制 acl http proto HTTP # 限制访问 good_domain添加两 ...

  4. 01 . Varnish简介,原理,配置缓存

    简介 Varnish是高性能开源的反向代理服务器和HTTP缓存服务器,其功能与Squid服务器相似,都可以用来做HTTP缓存.可以安装 varnish 在任何web前端,同时配置它缓存内容.与传统的 ...

  5. 01 . HAProxy原理使用和配置

    HaProxy简介 HaProxy是什么? HAProxy是一个免费的负载均衡软件,可以运行于大部分主流的Linux操作系统上. HAProxy提供了L4(TCP)和L7(HTTP)两种负载均衡能力, ...

  6. 01 . Keepalived原理使用和配置

    Keepalived简介 是什么? keepalived是一个类似于layer3, 4 & 5交换机制的软件,也就是我们平时说的第3层.第4层和第5层交换.Keepalived的作用是检测we ...

  7. Windows Squid 安装配置

    squid 可以做反向代理将系统中相对静态的页面进行缓存和负责均衡,提高网站访问速度,增强网站可用性.安全性.用户访问Squid 反向代理服务器的 IP 地址,这样客户端的 URL 请求将被发送到反向 ...

  8. MIT JOS学习笔记01:环境配置、Boot Loader(2016.10.22)

    未经许可谢绝以任何形式对本文内容进行转载! 一.环境配置 关于MIT课程中使用的JOS的配置教程网上已经有很多了,在这里就不做介绍,个人使用的是Ubuntu 16.04 + qemu.另注,本文章中贴 ...

  9. squid日志配置与轮询

    squid日志分类及参数 SQUID默认的log文件非常多,其中最重要的LOG日志有三个,分别为access.log.store.log.cache.log.三个日志的记录的内容如下: access. ...

随机推荐

  1. libevent(九)bufferevent

    bufferevent,带buffer的event struct bufferevent { struct event_base *ev_base; const struct bufferevent_ ...

  2. php5与php7安全性的区别

    0X01 前言 本篇文章大多为转载,但是修正了一些不正确的说法,对某些功能点的变更指出具体是哪个版本变更,加入了一些小更新. (原文地址:https://www.freebuf.com/article ...

  3. SSM整合案例:图书管理系统

    目录 SSM整合案例:图书管理系统 1.搭建数据库环境 2.基本环境搭建 2.1.新建一个Maven项目,起名为:ssmbuild,添加web的支持 2.2.导入pom的相关依赖 2.3.Maven静 ...

  4. Coursera课程笔记----C程序设计进阶----Week 3

    函数的递归(Week 3) 什么是递归 引入 函数可以嵌套调用:无论嵌套多少层,原理都一样 函数不能嵌套定义:不能在一个函数里再定义另一个函数,因为所有函数一律平等 问题:一个函数能调用它自己吗? 举 ...

  5. layui里面的layer模块弹窗,强制居中的方法!!!

    每次调用layer弹窗做动态展示的时候,只要内容不固定或者需要二次渲染 比如layui.form.render()进行渲染的时候 由于弹窗已经出来了,只是content部分的结构改变了宽度或者高度,l ...

  6. 【Scala】新手入门,基础语法概览

    目录 变量.常量和数据类型 var val 数据类型 条件表达式 块表达式 to循环 for循环 for推导式 scala中的方法和函数 方法的定义 函数的定义 函数和方法的区别 变量.常量和数据类型 ...

  7. Kubernetes笔记(三):Gitlab+Jenkins Pipeline+Docker+k8s+Helm自动化部署实践(干货分享!)

    通过前面两篇文章,我们已经有了一个"嗷嗷待哺"的K8s集群环境,也对相关的概念与组件有了一个基本了解(前期对概念有个印象即可,因为只有实践了才能对其有深入理解,所谓"纸上 ...

  8. Mysql 常用语句实战(3)

    前置 sql 语句 用来创建表.插入数据 ; DROP TABLE IF EXISTS dept_;-- 部门表 DROP TABLE IF EXISTS emp_;-- 部门表 ; SELECT @ ...

  9. 你了解C#的协变和逆变吗

    从C# 4.0开始,泛型接口和泛型委托都支持协变和逆变,由于历史原因,数组也支持协变. 里氏替换原则:任何基类可以出现的地方,子类一定可以出现. 协变(out) 协变:即自然的变化,遵循里氏替换原则, ...

  10. 【雕爷学编程】Arduino动手做(47)---七段LED数码管模块

    37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践(动手试试)出真知的理念,以学习和交流为目的,这里准备 ...