测试环境: 操作系统 :centos5.0 Web 服务器 :apache2 + tomcat 5.5 Jdk : j2se 1.5.5 1. 下载 squid-3.0.STABLE9.tar.gz (测试时最新的版本)。 http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE9.tar.gz 2. 添加用户及组 # useradd squid -M
测试环境:
操作系统:centos 5.0
Web 服务器: apache2 + tomcat 5.5
Jdk : j2se 1.5.5
1. 下载squid-3.0.STABLE9.tar.gz (测试时最新的版本)。
http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE9.tar.gz
2. 添加用户及组
# useradd squid -M -c "Squid user" -d /dev/null -s /sbin/nologin
3. 解压并编译安装
tar squid-3.0.STABLE9.tar.gz
cd squid-3.0.STABLE9
./configure --prefix=/data/squid3 --disable-carp --with-aufs-threads=32 --with-pthreads --enable-storeio='ufs,aufs, null' --enable-disk-io='AIO,Blocking' --enable-removal-policies='heap,lru' --disable-wccp --enable-kill-parent-hack --disable-snmp --disable-poll --disable-select --enable-auth=basic --with-aio --disable-ident-lookup --with-filedescriptors=65536
编译参数不做详细介绍请查相关文档
Make
make install
安装完毕。
4. 配置
可能需要创建一些文件 这些都是配置文件中需要调用的(这个要注意文件的属主和权限)
1) [root@www ~]#cd /data/squid3/var/logs/
2) [root@www ~]#touch cache.log
3) [root@www ~]#chmod 755 cache.log
4) [root@www ~]#chown squid:squid cache.log
5) [root@www ~]#touch page_zs_access_log
6) [root@www ~]#chmod 755 page_zs_access_log
7) [root@www ~]#chown squid:squid page_zs_access_log
8) [root@www ~]#cd /data/squid3/etc/
9) 配置squid 配置文件 squid.conf
[root@www ~]# vi squid.conf (192.168.3.11 为服务器的ip 地址)
visible_hostname www.test.com
http_port 80 vhost vport
cache_mem 512 MB
maximum_object_size_in_memory 2048 KB
memory_replacement_policy lru
cache_dir ufs /tmp 512 16 256
max_open_disk_fds 0
minimum_object_size 0 KB
maximum_object_size 32768 KB
logformat
combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %
access_log /data/squid3/var/logs/page_zs_access_log combined
pid_filename/data/squid3/var/logs/squid.pid
cache_store_log none
cache_peer 192.168.3.11 parent 81 0 no-query no-digest originserver name=www
cache_peer_domain www www.test.com
cache_peer_access www allow all
http_access allow all
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe
cache deny QUERY
cache_effective_user squid
cache_effective_group squid
10) [root@www ~]#/data/squid3/sbin/squid -k parse
可以根据这个测试命令用来验证squid.conf 的语法和配置(下面是OK 的如果不OK 会有相应的提示根据提示来修改配置文件)
2008/10/14 21:14:56| Processing Configuration File: /data/squid3/etc/squid.conf (depth 0)
11) [root@www ~]#/data/squid3/sbin/squid -z
用来创建缓存目录
12) vi 一个squid.sh 的启动脚本如下:赋予可执行权限
[root@www ~]#vi squid.sh
#!/bin/sh
#
ulimit -HSn 15000
# this script starts and stops Squid
echo 15000 > /proc/sys/fs/file-max
case "$1" in
start)
/data/squid3/sbin/squid -s
echo -n ' Squid'
;;
stop)
/data/squid3/sbin/squid -k shutdown
;;
esac
#chmod +x squid.sh
5. 启动squid
[root@www ~]#./squid.sh start 就可以启动squid 了
查看有没有启动可以
[root@www ~]#ps fax|grep squid
13750 pts /3 S+ 0:00 \_ grep squid
30474 ? Ss 0:00 /data/squid3/sbin/squid -s
30476 ? S 0:01 \_ (squid) -s
通过命令lsof -i:80 查看谁占用了80 端口
查看squid 的访问日志。
[root@www ~]# tail – f /data/squid3/var/logs/page_zs_access_log
查看命中率及其他相关信息
[root@www ~]# /data/squid3/bin/squidclient -p 80 -h localhost mgr:info
HTTP/1.0 200 OK
Server: squid/3.0.STABLE9
Mime-Version: 1.0
Date: Tue, 14 Oct 2008 13:22:40 GMT
Content-Type: text/plain
Expires: Tue, 14 Oct 2008 13:22:40 GMT
Last-Modified: Tue, 14 Oct 2008 13:22:40 GMT
X-Cache: MISS from www.6558855.com
Via: 1.0 www.6558855.com (squid/3.0.STABLE9)
Connection: close
Squid Object Cache: Version 3.0.STABLE9
Start Time: Tue, 14 Oct 2008 11:25:50 GMT
Current Time: Tue, 14 Oct 2008 13:22:40 GMT
Connection information for squid:
Number of clients accessing cache: 2
Number of HTTP requests received: 772
Number of ICP messages received: 0
Number of ICP messages sent: 0
Number of queued ICP replies: 0
Number of HTCP messages received: 0
Number of HTCP messages sent: 0
Request failure ratio: 0.00
Average HTTP requests per minute since start: 6.6
Average ICP messages per minute since start: 0.0
Select loop called: 7081542 times, 0.990 ms avg
Cache information for squid:
Hits as % of all requests: 5min: 0.0%, 60min: 89.7%
Hits as % of bytes sent: 5min: -0.0%, 60min: -0.0%
Memory hits as % of hit requests: 5min: 0.0%, 60min: 0.0%
Disk hits as % of hit requests: 5min: 0.0%, 60min: 0.0%
Storage Swap size: 104 KB
Storage Swap capacity: 0.0% used, 100.0% free
Storage Mem size: 228 KB
Storage Mem capacity: 0.0% used, 100.0% free
Mean Object Size: 10.40 KB
Requests given to unlinkd: 68
Median Service Times (seconds) 5 min 60 min:
HTTP Requests (All): 0.00000 0.00000
Cache Misses: 0.00000 0.00000
Cache Hits: 0.00000 0.00000
Near Hits: 0.00000 0.00000
Not-Modified Replies: 0.00000 0.00000
DNS Lookups: 0.00000 0.00000
ICP Queries: 0.00000 0.00000
Resource usage for squid:
UP Time: 7009.125 seconds
CPU Time: 0.948 seconds
CPU Usage: 0.01%
CPU Usage, 5 minute avg: 0.00%
CPU Usage, 60 minute avg: 0.01%
Process Data Segment Size via sbrk(): 2968 KB
Maximum Resident Size: 0 KB
Page faults with physical i/o: 2
Memory usage for squid via mallinfo():
Total space in arena: 3240 KB
Ordinary blocks: 3194 KB 17 blks
Small blocks: 0 KB 0 blks
Holding blocks: 11472 KB 17 blks
Free Small blocks: 0 KB
Free Ordinary blocks: 45 KB
Total in use: 14666 KB 100%
Total free: 45 KB 0%
Total size: 14712 KB
Memory accounted for:
Total accounted: 3001 KB 20%
memPool accounted: 3001 KB 20%
memPool unaccounted: 11710 KB 80%
memPoolAlloc calls: 147106
memPoolFree calls: 145713
File descriptor usage for squid:
Maximum number of file descriptors: 15000
Largest file desc currently in use: 14
Number of file desc currently in use: 8
Files queued for open: 0
Available number of file descriptors: 14992
Reserved number of file descriptors: 100
Store Disk files open: 0
Internal Data Structures:
45 StoreEntries
41 StoreEntries with MemObjects
40 Hot Object Cache Items
10 on-disk objects
6. 关于动态页面的缓存。
如 jsp 页面。
利用Header 为jsp 服务器减压
在参与缓存的jsp 中加入如下程序,进行“Last-Modified ”和“Expires ”的设置;
long file_lmodified = new File("/tmp/catchmodified".lastModified();
response.setBufferSize(16);
response.setDateHeader("Last-Modified", file_lmodified);
response.setDateHeader("Expires", System.currentTimeMillis() / 1000 * 1000 + 300000);
response.flushBuffer();
%>
7. 添加自动更新记时方式
[root@www ~]# vi refreshCatch.sh
#/bin/sh
/bin/echo >/tmp/catchmodified
Chmod +x refreshCatch.sh
然后在crontab 里写一句
*/5 * * * * /data/squid3/refreshCatch.sh

산성 속성에는 원자력, 일관성, 분리 및 내구성이 포함되며 데이터베이스 설계의 초석입니다. 1. 원자력은 거래가 완전히 성공적이거나 완전히 실패하도록합니다. 2. 일관성은 거래 전후에 데이터베이스가 일관성을 유지하도록합니다. 3. 격리는 거래가 서로를 방해하지 않도록합니다. 4. 지속성은 거래 제출 후 데이터가 영구적으로 저장되도록합니다.

MySQL은 데이터베이스 관리 시스템 (DBMS) 일뿐 만 아니라 프로그래밍 언어와 밀접한 관련이 있습니다. 1) DBMS로서 MySQL은 데이터를 저장, 구성 및 검색하는 데 사용되며 인덱스 최적화는 쿼리 성능을 향상시킬 수 있습니다. 2) SQL과 같은 ORM 도구를 사용하여 Python에 내장 된 SQL과 프로그래밍 언어를 결합하면 작업을 단순화 할 수 있습니다. 3) 성능 최적화에는 인덱싱, 쿼리, 캐싱, 라이브러리 및 테이블 부서 및 거래 관리가 포함됩니다.

MySQL은 SQL 명령을 사용하여 데이터를 관리합니다. 1. 기본 명령에는 선택, 삽입, 업데이트 및 삭제가 포함됩니다. 2. 고급 사용에는 조인, 하위 쿼리 및 집계 함수가 포함됩니다. 3. 일반적인 오류에는 구문, 논리 및 성능 문제가 포함됩니다. 4. 최적화 팁에는 인덱스 사용, 선택*을 피하고 한계 사용이 포함됩니다.

MySQL은 데이터 저장 및 관리에 적합한 효율적인 관계형 데이터베이스 관리 시스템입니다. 장점에는 고성능 쿼리, 유연한 트랜잭션 처리 및 풍부한 데이터 유형이 포함됩니다. 실제 애플리케이션에서 MySQL은 종종 전자 상거래 플랫폼, 소셜 네트워크 및 컨텐츠 관리 시스템에서 사용되지만 성능 최적화, 데이터 보안 및 확장성에주의를 기울여야합니다.

SQL과 MySQL의 관계는 표준 언어와 특정 구현의 관계입니다. 1.SQL은 관계형 데이터베이스를 관리하고 운영하는 데 사용되는 표준 언어로, 데이터 추가, 삭제, 수정 및 쿼리를 허용합니다. 2.MySQL은 SQL을 운영 언어로 사용하고 효율적인 데이터 저장 및 관리를 제공하는 특정 데이터베이스 관리 시스템입니다.

InnoDB는 Redologs 및 Undologs를 사용하여 데이터 일관성과 신뢰성을 보장합니다. 1. Redologs는 사고 복구 및 거래 지속성을 보장하기 위해 데이터 페이지 수정을 기록합니다. 2. 결점은 원래 데이터 값을 기록하고 트랜잭션 롤백 및 MVCC를 지원합니다.

설명 명령에 대한 주요 메트릭에는 유형, 키, 행 및 추가가 포함됩니다. 1) 유형은 쿼리의 액세스 유형을 반영합니다. 값이 높을수록 Const와 같은 효율이 높아집니다. 2) 키는 사용 된 인덱스를 표시하고 NULL은 인덱스가 없음을 나타냅니다. 3) 행은 스캔 한 행의 수를 추정하여 쿼리 성능에 영향을 미칩니다. 4) Extra는 최적화해야한다는 Filesort 프롬프트 사용과 같은 추가 정보를 제공합니다.

Temporary를 사용하면 MySQL 쿼리에 임시 테이블을 생성해야 할 필요성이 있으며, 이는 별개의, 그룹 비 또는 비 인덱스 열을 사용하여 순서대로 발견됩니다. 인덱스 발생을 피하고 쿼리를 다시 작성하고 쿼리 성능을 향상시킬 수 있습니다. 구체적으로, 설명 출력에 사용되는 경우, MySQL은 쿼리를 처리하기 위해 임시 테이블을 만들어야 함을 의미합니다. 이것은 일반적으로 다음과 같은 경우에 발생합니다. 1) 별개 또는 그룹을 사용할 때 중복 제거 또는 그룹화; 2) OrderBy가 비 인덱스 열이 포함되어있을 때 정렬하십시오. 3) 복잡한 하위 쿼리 또는 조인 작업을 사용하십시오. 최적화 방법은 다음과 같습니다. 1) Orderby 및 GroupB


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경
