squid3加速web服务器
测试环境: 操作系统 :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

핫 AI 도구

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

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

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

Clothoff.io
AI 옷 제거제

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

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











터미널에서 MySQL에 액세스 할 수 없음 : MySQL 서비스가 실행되지 않음; 연결 명령 오류; 불충분 한 권한; 방화벽 블록 연결; MySQL 구성 파일 오류.

Root로 MySQL에 로그인 할 수없는 주된 이유는 권한 문제, 구성 파일 오류, 암호 일관성이 없음, 소켓 파일 문제 또는 방화벽 차단입니다. 솔루션에는 다음이 포함됩니다. 구성 파일의 BAND-ADDRESS 매개 변수가 올바르게 구성되어 있는지 확인하십시오. 루트 사용자 권한이 수정 또는 삭제되어 재설정되었는지 확인하십시오. 케이스 및 특수 문자를 포함하여 비밀번호가 정확한지 확인하십시오. 소켓 파일 권한 설정 및 경로를 확인하십시오. 방화벽이 MySQL 서버에 연결되는지 확인하십시오.

MySQL에는 무료 커뮤니티 버전과 유료 엔터프라이즈 버전이 있습니다. 커뮤니티 버전은 무료로 사용 및 수정할 수 있지만 지원은 제한되어 있으며 안정성이 낮은 응용 프로그램에 적합하며 기술 기능이 강합니다. Enterprise Edition은 안정적이고 신뢰할 수있는 고성능 데이터베이스가 필요하고 지원 비용을 기꺼이 지불하는 응용 프로그램에 대한 포괄적 인 상업적 지원을 제공합니다. 버전을 선택할 때 고려 된 요소에는 응용 프로그램 중요도, 예산 책정 및 기술 기술이 포함됩니다. 완벽한 옵션은없고 가장 적합한 옵션 만 있으므로 특정 상황에 따라 신중하게 선택해야합니다.

Oracle 데이터베이스를 만들려면 일반적인 방법은 DBCA 그래픽 도구를 사용하는 것입니다. 단계는 다음과 같습니다. 1. DBCA 도구를 사용하여 데이터베이스 이름을 지정하기 위해 DBNAME을 설정하십시오. 2. SySpassword 및 SystemPassword를 강력한 암호로 설정하십시오. 3. Al32UTF8로 문자 세트 및 NationalCharacterset을 세트; 4. 실제 요구에 따라 조정하도록 메모리 크기 및 테이블 스페이스 크기를 설정하십시오. 5. 로그 파일 경로를 지정하십시오. 고급 메소드는 SQL 명령을 사용하여 수동으로 생성되지만 더 복잡하고 오류가 발생하기 쉽습니다. 비밀번호 강도, 문자 세트 선택, 테이블 스페이스 크기 및 메모리에주의하십시오.

MySQL은 여러 동시 연결을 처리하고 멀티 스레딩/다중 프로세싱을 사용하여 각 클라이언트 요청에 독립적 인 실행 환경을 할당하여 방해받지 않도록 할 수 있습니다. 그러나 동시 연결 수는 시스템 리소스, MySQL 구성, 쿼리 성능, 스토리지 엔진 및 네트워크 환경의 영향을받습니다. 최적화에는 코드 레벨 (효율적인 SQL), 구성 레벨 (Max_Connections 조정), 하드웨어 수준 (서버 구성 개선)과 같은 많은 요소를 고려해야합니다.

MySQL 및 MariaDB는 특정 데이터베이스 버전 또는 기능에 대한 다양한 프로젝트의 요구를 충족시키기 위해 단일 서버에 동시에 설치할 수 있습니다. 다음 세부 사항은 다음에주의를 기울여야합니다. 다른 포트 번호; 다른 데이터 디렉토리; 자원의 합리적인 할당; 모니터링 버전 호환성.

MySQL은 Android에서 직접 실행할 수는 없지만 다음 방법을 사용하여 간접적으로 구현할 수 있습니다. Android 시스템에 구축 된 Lightweight Database SQLite를 사용하여 별도의 서버가 필요하지 않으며 모바일 장치 애플리케이션에 매우 적합한 작은 리소스 사용량이 있습니다. MySQL 서버에 원격으로 연결하고 데이터 읽기 및 쓰기를 위해 네트워크를 통해 원격 서버의 MySQL 데이터베이스에 연결하지만 강력한 네트워크 종속성, 보안 문제 및 서버 비용과 같은 단점이 있습니다.

Linux는 서버, 개발 환경 및 임베디드 시스템에 적합합니다. 1. 서버 운영 체제로서 Linux는 안정적이고 효율적이며 종종 고 대전성 애플리케이션을 배포하는 데 사용됩니다. 2. 개발 환경으로서 Linux는 효율적인 명령 줄 도구 및 패키지 관리 시스템을 제공하여 개발 효율성을 향상시킵니다. 3. 임베디드 시스템에서 Linux는 가볍고 사용자 정의 가능하며 자원이 제한된 환경에 적합합니다.
