検索

squid3加速web服务器

Jun 07, 2016 pm 03:05 PM
cweb加速するオペレーティング·システムサーバテスト環境

测试环境: 操作系统 :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 %h" "%{User-Agent}>h" %Ss:%Sh

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 页面。

       利用Headerjsp 服务器减压

     在参与缓存的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

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
酸性の特性(原子性、一貫性、分離、耐久性)を説明します。酸性の特性(原子性、一貫性、分離、耐久性)を説明します。Apr 16, 2025 am 12:20 AM

酸性属性には、原子性、一貫性、分離、耐久性が含まれ、データベース設計の基礎です。 1.原子性は、トランザクションが完全に成功するか、完全に失敗することを保証します。 2.一貫性により、データベースがトランザクションの前後に一貫性を保証します。 3.分離により、トランザクションが互いに干渉しないようにします。 4.永続性により、トランザクションの提出後にデータが永久に保存されることが保証されます。

MySQL:データベース管理システムとプログラミング言語MySQL:データベース管理システムとプログラミング言語Apr 16, 2025 am 12:19 AM

MySQLは、データベース管理システム(DBMS)であるだけでなく、プログラミング言語にも密接に関連しています。 1)DBMSとして、MySQLはデータを保存、整理、取得するために使用され、インデックスを最適化するとクエリのパフォーマンスが向上する可能性があります。 2)SQLとPythonに埋め込まれたプログラミング言語とSQLalchemyなどのORMツールを使用すると、操作を簡素化できます。 3)パフォーマンスの最適化には、インデックス、クエリ、キャッシュ、ライブラリ、テーブル分割、およびトランザクション管理が含まれます。

MySQL:SQLコマンドでデータの管理MySQL:SQLコマンドでデータの管理Apr 16, 2025 am 12:19 AM

MySQLはSQLコマンドを使用してデータを管理します。 1.基本コマンドには、select、挿入、更新、削除が含まれます。 2。高度な使用には、参加、サブクエリ、および集計関数が含まれます。 3.一般的なエラーには、構文、ロジック、パフォーマンスの問題が含まれます。 4。最適化のヒントには、インデックスの使用、Select*の回避、制限の使用が含まれます。

MySQLの目的:データを効果的に保存および管理しますMySQLの目的:データを効果的に保存および管理しますApr 16, 2025 am 12:16 AM

MySQLは、データの保存と管理に適した効率的なリレーショナルデータベース管理システムです。その利点には、高性能クエリ、柔軟なトランザクション処理、豊富なデータ型が含まれます。実際のアプリケーションでは、MySQLはeコマースプラットフォーム、ソーシャルネットワーク、コンテンツ管理システムでよく使用されますが、パフォーマンスの最適化、データセキュリティ、スケーラビリティに注意を払う必要があります。

SQLとMySQL:関係を理解するSQLとMySQL:関係を理解するApr 16, 2025 am 12:14 AM

SQLとMySQLの関係は、標準言語と特定の実装との関係です。 1.SQLは、リレーショナルデータベースの管理と操作に使用される標準言語であり、データの追加、削除、変更、クエリを可能にします。 2.MYSQLは、SQLを運用言語として使用し、効率的なデータストレージと管理を提供する特定のデータベース管理システムです。

Innodb Redoログの役割を説明し、ログを元に戻します。Innodb Redoログの役割を説明し、ログを元に戻します。Apr 15, 2025 am 12:16 AM

INNODBは、レドログと非論的なものを使用して、データの一貫性と信頼性を確保しています。 1.レドログは、クラッシュの回復とトランザクションの持続性を確保するために、データページの変更を記録します。 2.Undologsは、元のデータ値を記録し、トランザクションロールバックとMVCCをサポートします。

説明出力(タイプ、キー、行、追加)で探す重要なメトリックは何ですか?説明出力(タイプ、キー、行、追加)で探す重要なメトリックは何ですか?Apr 15, 2025 am 12:15 AM

説明コマンドのキーメトリックには、タイプ、キー、行、および追加が含まれます。 1)タイプは、クエリのアクセスタイプを反映しています。値が高いほど、constなどの効率が高くなります。 2)キーは使用されているインデックスを表示し、nullはインデックスがないことを示します。 3)行はスキャンされた行の数を推定し、クエリのパフォーマンスに影響します。 4)追加の情報を最適化する必要があるというFilesortプロンプトを使用するなど、追加情報を提供します。

説明の一時的なステータスを使用し、それを回避する方法は何ですか?説明の一時的なステータスを使用し、それを回避する方法は何ですか?Apr 15, 2025 am 12:14 AM

Temporaryを使用すると、MySQLクエリに一時テーブルを作成する必要があることが示されています。これは、異なる列、またはインデックスされていない列を使用して順番に一般的に見られます。インデックスの発生を回避し、クエリを書き直し、クエリのパフォーマンスを改善できます。具体的には、expliect出力に使用を使用する場合、MySQLがクエリを処理するために一時テーブルを作成する必要があることを意味します。これは通常、次の場合に発生します。1)個別またはグループビーを使用する場合の重複排除またはグループ化。 2)Orderbyに非インデックス列が含まれているときに並べ替えます。 3)複雑なサブクエリを使用するか、操作に参加します。最適化方法には以下が含まれます。1)OrderbyとGroupB

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

SublimeText3 英語版

SublimeText3 英語版

推奨: Win バージョン、コードプロンプトをサポート!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境