0088 | LUSCA CDN installation
Thursday, January 14th, 2010 Posted in Misc | No Comments »จดไว้กันลืมครับ ไม่ต้องใส่ใจมากมาย
http://code.google.com/p/lusca-cache/downloads/list
./configure --prefix=/usr/local/lusca --with-maxfd=32768 --with-aio --with-pthreads --disable-ident-lookups --enable-snmp --enable-storeio="aufs" --enable-removal-policies="heap lru" --disable-wccp && make && make install ln -s /usr/local/lusca/etc /etc/lusca ln -s /usr/local/lusca/var/logs /var/log/lusca mkdir /usr/local/lusca/var/cache chown nobody /usr/local/lusca/var/cache /usr/local/lusca/var/logs ln -s /usr/local/lusca/sbin/squid /usr/sbin/squid ln -s /usr/local/lusca/bin/squidclient /usr/bin/squidclient |
cron
4 * * * * /usr/sbin/squid -k rotate |
config
acl all src all acl manager proto cache_object acl localhost src 127.0.0.1/32 acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny CONNECT acl upic_host dst 124.109.2.175 124.109.2.176 acl upic_port port 80 http_access allow upic_host upic_port http_access deny all icp_access deny all http_port 80 accel vhost cache_peer 124.109.2.176 parent 80 0 weight=5 no-query round-robin cache_peer 124.109.2.175 parent 80 0 weight=5 no-query round-robin cache_mem 32 MB maximum_object_size_in_memory 16 KB memory_replacement_policy heap GDSF cache_replacement_policy heap LFUDA cache_dir aufs /usr/local/lusca/var/cache 8192 16 256 logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh access_log /usr/local/lusca/var/logs/access.log combined cache_store_log none logfile_rotate 24 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 acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9] upgrade_http0.9 deny shoutcast acl apache rep_header Server ^Apache broken_vary_encoding allow apache cache_effective_user nobody server_persistent_connections off acl nullreferer referer_regex ^$ cache deny nullreferer visible_hostname cdn.upic.me snmp_port 3401 acl snmppublic snmp_community public snmp_access allow snmppublic localhost snmp_access deny all never_direct allow all coredump_dir /usr/local/lusca/var/cache pid_filename /var/run/lusca.pid |
/etc/init.d/lusca
#!/bin/bash # squid This shell script takes care of starting and stopping # Squid Internet Object Cache # # chkconfig: - 90 25 # description: Squid - Internet Object Cache. Internet object caching is \ # a way to store requested Internet objects (i.e., data available \ # via the HTTP, FTP, and gopher protocols) on a system closer to the \ # requesting site than to the source. Web browsers can then use the \ # local Squid cache as a proxy HTTP server, reducing access time as \ # well as bandwidth consumption. # pidfile: /var/run/squid.pid # config: /etc/squid/squid.conf PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # don't raise an error if the config file is incomplete # set defaults instead: SQUID_OPTS=${SQUID_OPTS:-"-D"} SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20} SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100} # determine the name of the squid binary [ -f /usr/sbin/squid ] && SQUID=squid prog="$SQUID" # determine which one is the cache_swap directory CACHE_SWAP=`sed -e 's/#.*//g' /etc/lusca/squid.conf | \ grep cache_dir | awk '{ print $3 }'` [ -z "$CACHE_SWAP" ] && CACHE_SWAP=/usr/local/lusca/var/cache/ RETVAL=0 start() { ulimit -HSn 32768 #check if the squid conf file is present if [ ! -f /etc/lusca/squid.conf ]; then echo "Configuration file /etc/lusca/squid.conf missing" 1>&2 exit 6 fi # don't raise an error if the config file is incomplete. # set defaults instead: SQUID_OPTS=${SQUID_OPTS:-"-D"} SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20} SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100} if [ -z "$SQUID" ]; then echo "Insufficient privilege" 1>&2 exit 4 fi for adir in $CACHE_SWAP; do if [ ! -d $adir/00 ]; then echo -n "init_cache_dir $adir... " $SQUID -z -F -D >> /var/log/lusca/squid.out 2>&1 fi done echo -n $"Starting $prog: " $SQUID $SQUID_OPTS >> /var/log/lusca/squid.out 2>&1 RETVAL=$? if [ $RETVAL -eq 0 ]; then timeout=0; while : ; do [ ! -f /var/run/lusca.pid ] || break if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then RETVAL=1 break fi sleep 1 && echo -n "." timeout=$((timeout+1)) done fi [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SQUID [ $RETVAL -eq 0 ] && echo_success [ $RETVAL -ne 0 ] && echo_failure echo return $RETVAL } stop() { # don't raise an error if the config file is incomplete. # set defaults instead: SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100} echo -n $"Stopping $prog: " $SQUID -k check >> /var/log/lusca/squid.out 2>&1 RETVAL=$? if [ $RETVAL -eq 0 ] ; then $SQUID -k shutdown & rm -f /var/lock/subsys/$SQUID timeout=0 while : ; do [ -f /var/run/lusca.pid ] || break if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then echo return 1 fi sleep 2 && echo -n "." timeout=$((timeout+2)) done echo_success echo else echo_failure echo fi return $RETVAL } reload() { # . /etc/sysconfig/squid # don't raise an error if the config file is incomplete. # set defaults instead: SQUID_OPTS=${SQUID_OPTS:-"-D"} $SQUID $SQUID_OPTS -k reconfigure } restart() { stop start } condrestart() { [ -e /var/lock/subsys/squid ] && restart || : } rhstatus() { status $SQUID && $SQUID -k check } probe() { return 0 } case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; condrestart) condrestart ;; status) rhstatus ;; probe) exit 0 ;; *) echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}" exit 2 esac exit $? |