SDpower

FreeBSD

筆記 Haproxy 設定

by on 四月.07, 2010, under FreeBSD

Haproxy 設定筆記

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #chroot /var/chroot/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet
                                nbproc      2 # Number of processes
 
defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      30000
        srvtimeout      50000
        monitor-uri /ok.html
        stats uri /stats
        stats auth admin:admin
 
listen  load_balanced_http      :80
    mode http
    option httpchk
    option httplog
    option forwardfor
    option httpclose               # disable keep-alive
    option checkcache              # block response if set-cookie & cacheable
    option redispatch
    option persist
    cookie SERVERID insert nocache indirect
    balance roundrobin
    server shop1 192.168.0.1:80 cookie server01 weight 49 maxconn 400 check inter 40000
    server shop2 192.168.0.2:80 cookie server02 weight 51 maxconn 500 check inter 40000
 
listen  load_balanced_https     :443
    mode tcp
    balance roundrobin
    option  ssl-hello-chk
    option  forwardfor
    server shop1 192.168.0.1:443 check inter 30000 rise 1 fall 2
    server shop2 192.168.0.2:443 check backup
Fork me on GitHub
Leave a Comment more...

FreeBSD NGINX + PHP5

by on 三月.30, 2010, under FreeBSD, PHP & MYSQL

先去官網找到freebsd專用的port

http://php-fpm.org/downloads/freebsd-port/

# fetch http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz
# mv php-5.2.10-fpm-0.5.13.diff.gz /usr/ports/distfiles/
# fetch http://files.directadmin.com/services/custombuild/php-5.2.9-mail-header.patch
# mv php-5.2.9-mail-header.patch /usr/ports/distfiles/
# fetch http://php-fpm.org/downloads/freebsd-port/php-5.2.10-fpm-0.5.13.tar.gz
php-5.2.10-fpm-0.5.13.tar.gz                  100% of 9503  B   45 kBps
# tar zxvf php-5.2.10-fpm-0.5.13.tar.gz -C /usr/ports/lang
x php5-fpm/
x php5-fpm/files/
x php5-fpm/Makefile
x php5-fpm/distinfo
x php5-fpm/pkg-descr
x php5-fpm/pkg-plist
x php5-fpm/files/php-fpm.sh.in
x php5-fpm/files/patch-scripts::phpize.in
x php5-fpm/files/patch-TSRM_threads.m4
x php5-fpm/files/patch-Zend::zend.h
x php5-fpm/files/patch-Zend_zend_list.c
x php5-fpm/files/patch-Zend_zend_list.h
x php5-fpm/files/patch-ext_standard_array.c
x php5-fpm/files/patch-ext_standard_basic_functions.c
x php5-fpm/files/patch-ext_standard_dns.h
x php5-fpm/files/patch-ext_standard_image.c
x php5-fpm/files/patch-php.ini-dist
x php5-fpm/files/patch-php.ini-recommended
x php5-fpm/files/patch-main::php_config.h.in
x php5-fpm/files/patch-main_SAPI.c
x php5-fpm/files/patch-acinclude.m4
x php5-fpm/files/patch-configure.in
 
# cd /usr/ports/lang/php5-fpm/
# make install clean
# fetch http://www.grid.net.ru/nginx/download/nginx_upload_module-2.0.12.tar.gz
# mv nginx_upload_module-2.0.12.tar.gz /usr/ports/distfiles/
# fetch http://mod-zip.googlecode.com/files/mod_zip-1.1.5.tar.gz
# mv mod_zip-1.1.5.tar.gz /usr/ports/distfiles/
# cd /usr/ports/www/nginx-devel
# make install clean

編輯/usr/local/etc/php-fpm.conf
nobody改成www

Unix user of processes
nobody
Unix group of processes
nobody

編輯/usr/local/etc/nginx/nginx.conf

#user  nobody;
worker_processes  2;
 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
#pid        logs/nginx.pid;
 
events {
    worker_connections  1024;
}
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 8m;
 
    sendfile        on;
    #tcp_nopush     on;
    server_tokens  off;
    tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;
 
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
 
    gzip_static on;
    gzip  on;
    gzip_min_length  1k;
    gzip_proxied     expired no-cache no-store private auth;
    gzip_buffers 4 16k;
    gzip_comp_level   5;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_disable     "MSIE [1-6]\.";
    gzip_vary on;
 
    server {
        listen       80;
        server_name  localhost;
	autoindex  on;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   /www;
            index  index.php index.html index.htm;
        }
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /www;
     	    fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /www$fastcgi_script_name;
            include        fastcgi_params;
        }
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
 
    }
  server {
    listen       80;
    server_name  test2.localhost www.test2.localhost;
    access_log  /var/log/test2.access.log;
    error_log  /var/log/test2.error.log;
    location ~* ^.+\.(jpg|jpeg|gif)$ {
     root   /www/test2/pub;
     expires 30d;
    }
    location ~* ^.+\.(js|css)$ {
     root   /www/test2/pub;
     expires 1h;
    }
    location / {
        root   /www/test2/pub;
        index  index.php index.html index.htm;
    }
    location ~ \.php$ {
      root           /www/test2/pub;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  /www/test2/pub$fastcgi_script_name;
      include        fastcgi_params;
    }
    location ~ /\.ht {
            deny  all;
    }
  }
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;
 
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_timeout  5m;
 
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

編輯/etc/rc.conf

php_fpm_enable="YES"
nginx_enable="YES"

http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

http://wiki.nginx.org/Main

3 Comments more...

學習 FreeBSD ports

by on 三月.03, 2010, under FreeBSD

安裝

cd /usr/ports/ports-mgmt/porttools ; make install clean

簡介

FreeBSD Port Tools includes the following commands:
- port create: create a new port from a template
- port diff: generate a diff against a previous version of the port
- port fetch: fetch distfile(s) of a new version of the port
- port help: display usage summary for port(1) commands
- port submit: submit a PR with new port, or port change/update
- port test: automate testing a new port or a port update

WWW:	http://sourceforge.net/projects/porttools/

參考:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/index.html

http://blog.dragon2.net/2009/12/17/912.php

http://www.joehorn.idv.tw/archives/2010/03/02/759/

http://www.ptt.cc/man/FreeBSD/DEBD/D160/M.1135705310.A.E5B.html

http://blog.hubert.tw/2006/04/15/freebsd-ports-send-pr-%E5%88%9D%E9%AB%94%E9%A9%97/
Leave a Comment more...

QEMU on FreeBSD 8.0 再你的的server上,建立自己的虛擬電腦 lab 以供測試開發.

by on 十二月.16, 2009, under FreeBSD

一直以來你是否有跟我有相同的困擾? 手頭上只有一台機器,效能尚可系統負載不高.
但工作需要執行多種環境測試實驗,無法隨身攜帶各種系統. 等等困境….
一般的虛擬機器軟體又需要圖型介面,才可設定使用.(這無疑對系統又是一種負擔,與當機危險)

現在終於有實際解決方案~所需費用 0. (continue reading…)

Leave a Comment : more...

跨平台效能TEST

by on 七月.23, 2009, under FreeBSD

http://www.primatelabs.ca/geekbench/

支援很多喔
Geekbench 2.1.2 for Mac OS X
Geekbench 2.1.2 for Windows
Geekbench 2.1.2 for Linux
Geekbench 2.0.9 for Solaris

64Bit 要註冊

Leave a Comment more...

紀錄 FreeBSD make.conf

by on 六月.27, 2009, under FreeBSD

MASTER_SITE_BACKUP?= \
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp3.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp4.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp5.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp7.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp8.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp9.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/

MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
MASTER_SORT_REGEX=      \.tw/ \.tw\. \.edu/ \.edu\.
FETCH_CMD=fetch -U -A -P

WITHOUT_X11=yes
MACHINE=amd64
MACHINE_ARCH=amd64
MAKE_JOBS_NUMBER=3
WITH_LIB32=yes <~~~這個才會有32的LIB

# for cvsup make update

SUP_UPDATE=yes
SUP=            /usr/bin/csup
SUPFLAGS=       -g -L 2
SUPHOST=        cvsup2.tw.FreeBSD.org
SUPFILE=        /usr/share/examples/cvsup/standard-supfile
PORTSSUPFILE=   /usr/share/examples/cvsup/ports-supfile
DOCSUPFILE=     /usr/share/examples/cvsup/doc-supfile

Leave a Comment more...

apache2 限流模組 mod_cband 說明文件

by on 六月.03, 2009, under FreeBSD

Source:http://codee.pl/cband_documentation.html

Configuration

Configuration is very simple, you must write only several lines. First, you must add the following command to the main config file to load the mod_cband module:

LoadModule cband_module		modules/mod_cband.so

Configuration Directives

New commands from 0.9.7.0 version:

  • CBandDefaultExceededCode – the http code sent to the user when the quota is exceeded

Units accepted in various directives:

  • transfer speeds:
    • kbps, Mbps, Gbps – multiples of "bits per second", respectively: 1024, 1024*1024 and 1024*1024*1024 bps
    • kb/s, Mb/s, Gb/s – multiples of "bytes per second", respectively: 1024, 1024*1024 and 1024*1024*1024 b/s
    • defaults to kbps
  • transfer quotas:
    • K, M, G – multiples of bytes, respectively: 1000, 1000*1000 and 1000*1000*1000 bytes
    • Ki, Mi, Gi – multiples of bytes, respectively: 1024, 1024*1024 and 1024*1024*1024 bytes
    • defaults to K
  • time periods:
    • S, M, H, D, W – multiples of seconds: Seconds, Minutes, Hours, Days, Weeks; respectively: 1, 60, 3600, 86400, 604800 seconds
    • defaults to S
Name CBandDefaultExceededURL
Description Default URL where mod_cband should redirect all requests to the virtualhost or user when the configured transfer limit is exceeded
NOTE : If you don’t specify the exceeded URL location then standard 503 Service Unavailable will be sent
Context Server config
Syntax CBandDefaultExceededURL URL
Name CBandDefaultExceededCode
Description The http code sent to the user when the configured transfer is exceeded
Context Server config
Syntax CBandDefaultExceededCode HTTP_CODE
Example CBandDefaultExceededCode 509
Name CBandScoreFlushPeriod
Description Specifies a period after which the score for the virtualhost or user is written to the scoreboard file. Use this to improve mod_cband’s performance
Default 1
Context Server config
Syntax CBandScoreFlushPeriod number_of_requests
Example CBandScoreFlushPeriod 100
Any virtualhost’s or user’s scoreboard will be saved after 100 requests
Name CBandSpeed
Description Specifies a maximal speed for a virtualhost
Context
Syntax CBandSpeed kbps rps max_conn

kbps – maximal transfer speed in [kMG]bps or [kMG]B/s
rps – maximal requests per second
max_conn – maximal number of simultaneous connections

Example CBandSpeed 1024 10 30

Specifies maximal speed 1024kbps (1024 * 1024 bits per second), maximal 10 requests per second and with a maximum of 30 open connections

NOTE: This feature is available from version 0.9.6.0

Name CBandRemoteSpeed
Description Specifies maximal speed for any remote client
Context
Syntax CBandRemoteSpeed kbps rps max_conn

kbps – maximal transfer speed in [kMG]bps or [kMG]B/s
rps – maximal requests per second
max_conn – maximal number of simultaneous connections

Example CBandRemoteSpeed 20kb/s 3 3

Specifies maximal speed 20kB/s (20 * 1024 bytes per second), maximal 3 requests per second and 3 open connections for any remote client

NOTE: This feature is available from version 0.9.6.1-rc2

Name CBandClassRemoteSpeed
Description Specifies maximal speed for any remote client from some destination class
Context
Syntax CBandClassRemoteSpeed class_name kbps rps

class_name – name of defined destination class
kbps – maximal transfer speed in kbps or kB/s
rps – maximal requests per second
max_conn – maximal number of simultaneous connections

Example CBandClassDst 66.249.64/24
CBandClassDst 66.249.65/24
CBandClassDst 66.249.79/24

CBandClassRemoteSpeed googlebot_class 20kb/s 2 3

-Specifies maximal speed 20kB/s (20 * 1024 bytes per second), maximal 2 requests per second and 3 open connections for any remote client from class googlebot_class

NOTE: This feature is available from version 0.9.6.1-rc2

Name CBandRandomPulse
Description Turns On or Off the random pulse generator for data sending
Random pulse generator is a part of the speed-limiting implementation of mod_cband. This directive changes the way a connection’s speed is determined and enforced. The connections’ speeds are measured within some time period and then provided for in that period. When r.p.g. is enabled this period is chosen randomly, providing for a statisticaly saner load distribution. Disabling this causes spikes both in bandwidth and cpu usages
Context Global
Syntax CBandRandomPulse On/Off
Name CBandLimit
Description Specifies bandwidth limit for virtualhost
Context
Syntax CBandLimit limit
limit – bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
Example CBandLimit 10M
Specifies 10 * 1000 * 1000 bytes bandwidth quota
CBandLimit 10Mi
Specifies 10 * 1024 * 1024 bytes bandwidth quota
IMPORTANT NOTE : the meaning of K, M and G changed with version 0.9.6.0. Check your config
Name CBandClassLimit
Description Specifies bandwidth limit for virtualhost’s destination class
Context
Syntax CBandClassLimit class_name limit
class_name – the name of defined class
limit – bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
IMPORTANT NOTE : the meaning of K, M and G changed with version 0.9.6.0. Check your config
Name CBandExceededURL
Description Specifies a URL where mod_cband should redirect all requests to a virtualhost when the configured transfer limit is exceeded
NOTE : If you don’t specify the exceeded URL location then standard 503 Service Unavailable will be sent
Context
Syntax CBandExceededURL URL
Name CBandExceededSpeed
Description Specifies maximal speed to which mod_cband slows down a virtualhost when the configured transfer limit is exceeded
Context
Syntax CBandExceededSpeed kbps rps max_conn
kbps – maximal transfer speed in kbps or kB/s
rps – maximal requests per second
max_conn – maximal number of simultaneous connections
NOTE: This feature is available from version 0.9.6.0
Name CBandScoreboard
Description Specifies virtualhost’s scoreboard file
Context
Syntax BandScoreboard path
NOTE: The path must be writeable for the apache-user
Name CBandPeriod
Description Specifies a period after which a virtualhost’s usages are cleared
Context
Syntax CBandPeriod period
period – available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
Example CBandPeriod 1W
CBandPeriod 14D
CBandPeriod 60M
Name CBandPeriodSlice
Description Specifies the period slice length
Default slice_len = limit
Context
Syntax CBandPeriodSlice slice_length
Example CBandLimit 100G
CBandPeriod 4W
CBandPeriodSlice 1W

A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G …

Name
Description Define a new cband user
Context Server config
Syntax user_name >
Name CBandUserSpeed
Description Specifies maximal speed for a cband user
Context
Syntax CBandUserSpeed kbps rps max_conn
kbps – maximal transfer speed in kbps or kB/s
rps – maximal requests per second
max_conn – maximal number of simultaneous connections
Example CBandUserSpeed 100kb/s 10 5
Specifies maximal speed 100 kB/s (100 * 1024 bytes per second), maximal 10 requests per second and 5 open connections
NOTE: This feature is available from version 0.9.6.0
Name CBandUserLimit
Description Specifies bandwidth limit for a cband user
Context
Syntax CBandUserLimit limit
limit – bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
Example CBandUserLimit 10M
Specifies 10 * 1000 * 1000 bytes bandwidth quota
CBandUserLimit 10Mi
Specifies 10 * 1024 * 1024 bytes bandwidth quota
IMPORTANT NOTE : the meaning of K, M and G changed with version 0.9.6.0. Check your config
Name CBandUserClassLimit
Description Specifies bandwidth limit for a cband user’s destination class
Context
Syntax CBandUserClassLimit class_name limit
class_name – the name of defined class
limit – bandwidth quota size, available units: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
IMPORTANT NOTE : the meaning of K, M and G changed with version 0.9.6.0. Check your config
Name CBandUserExceededURL
Description Specifies a URL where mod_cband should redirect all requests to user’s virtualhost when the configured transfer limit is exceeded
NOTE : If you don’t specify the exceeded URL location then standard 503 Service Unavailable will be sent
Context
Syntax CBandUserExceededURL URL
Name CBandUserExceededSpeed
Description Specifies maximal speed to which mod_cband slows down user when the configured transfer limit is exceeded
NOTE: CBandUserExceededURL must not be used if you want to only slow down user’s pages with CBandUserExceededSpeed directive
Context
Syntax CBandUserExceededSpeed kbps rps max_conn
kbps – maximal transfer speed in kbps or kB/s
rps – maximal requests per second
max_conn – maximal number of simultaneous connections
NOTE: This feature is available from version 0.9.6.0
Name CBandUserScoreboard
Description Specifies a user’s scoreboard file
Context
Syntax CBandUserScoreboard path
NOTE: The path must be writeable for the apache-user
Name CBandUserPeriod
Description Specifies a period after which a user’s usages are cleared
Context
Syntax CBandUserPeriod period
period – available units: S (seconds), M (minutes), H (hours), D (days), W (weeks)
Example CBandUserPeriod 1W
CBandUserPeriod 14D
CBandUserPeriod 60M
Name CBandUserPeriodSlice
Description Specifies a period slice length
Default slice_len = limit
Context
Syntax CBandUserPeriodSlice slice_length
Example CBandUserLimit 100G
CBandUserPeriod 4W
CBandUserPeriodSlice 1W
A period will be divided into 4 small slices (4W/1W = 4). Each slice has 100G/4=25G bandwidth limit. After 1W slice limit will be 50G, after 2W will be 75G …

Status Handler Configuration Example

To view actual bandwidth limits, usages, users, scoreboards, add the following lines into the config file:

<Location /cband-status>
SetHandler cband-status
</Location>
<Location /cband-status-me>
SetHandler cband-status-me
</Location>

Then you can access the status page with a URL like:

http://server_name/cband-status

http://server_name/cband-status-me

In versions >=0.9.5-rc1 you can also view /cband-status handler in the XML format :

http://server_name/cband-status?xml

http://server_name/cband-status-me?xml

Bandwidth Speed Configuration Example

<VirtualHost *:80>
    DocumentRoot /var/www/xyz.org/
    ServerName xyz.org
    CustomLog /var/log/apache2/xyz.org.access combined
    ErrorLog /var/log/apache2/xyz.org.access.error
    RewriteEngine On
    RewriteOptions inherit

	# Maximal 1024kbps speed for this virtualhost
	# Maximal 10 requests per second for this virtualhost
	# Maximal 30 open connections for this virtualhost

	CBandSpeed 1024 10 30

	# Maximal 10kB/s speed, 3 requests/s and 2 open connections for any remote client
	CBandRemoteSpeed 10kb/s 3 2

	# Maximal 20kB/s speed, 2 requests/s and 3 open connections for remote
	# clients from class googlebot_class :P
	CBandClassRemoteSpeed googlebot_class 20kb/s 2 3
</VirtualHost>

Bandwidth Quota Configuration Example

per-virtualhost bandwidth limiting configuration

Next, you may define virtualhost’s bandwidth limits, URL location and the path to scoreboard files for individual virtualhosts:

# specify default 'bandwidth exceeded' location
CBandDefaultExceededURL	http://haha.org/bandwidth_exceeded.html

<VirtualHost *:80>
    DocumentRoot /var/www/xyz.org/
    ServerName xyz.org
    CustomLog /var/log/apache2/xyz.org.access combined
    ErrorLog /var/log/apache2/xyz.org.access.error
    RewriteEngine On
    RewriteOptions inherit

    # 100MB virtualhost bandwidth limit
    CBandLimit 100000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandExceededURL http://abc.org/bandwidth_exceeded.html

    # virtualhost's scoreboard file
    CBandScoreboard /var/run/apache2/xyz.org.scoreboard

    # a period of time after which the scoreboard will be cleared (30 minutes)
    # (only in >=0.9.5-rc2)
    CBandPeriod 30M
</VirtualHost>

per-user bandwidth limiting configuration (only in versions >=0.9.1)

In versions >=0.9.1 you can define limits for users and assign virtualhosts to them


# define user 'dembol'
<CBandUser dembol>
    # 200MB bandwidth limit for user 'dembol'
    CBandUserLimit 200000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandUserExceededURL http://abc.org/bandwidth_exceeded.html

    # user's scoreboard file
    CBandUserScoreboard /var/run/apache2/dembol.scoreboard

    # a period of time after which the scoreboard will be cleared (5 weeks)
    # (only in >=0.9.5-rc2)
    CBandUserPeriod 5W
</CBandUser>

# assign virtualhost 'xyz.org' to user 'dembol'
<VirtualHost *:80>
    ServerName xyz.org
    # Specify virtualhost's owner
    CBandUser dembol
</VirtualHost>

# assign virtualhost 'aga.org' to user 'dembol'
<VirtualHost *:80>
    ServerName aga.org
    # Specify virtualhost's owner
    CBandUser dembol
</VirtualHost>

per-user and per-virtualhost bandwidth limiting configuration (only in versions >=0.9.1)

In versions >=0.9.1 you can also mix per-user and per-virtualhost bandwidth limiting techniques


# define user 'dembol'
CBandUser dembol
    # 200MB bandwidth limit for user 'dembol'
    CBandUserLimit 200000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandUserExceededURL http://abc.org/bandwidth_exceeded.html

    # user's scoreboard file
    CBandUserScoreboard /var/run/apache2/dembol.scoreboard

    # a period of time after which the scoreboard will be cleared (4 days)
    # (only in >=0.9.5-rc2)
    CBandUserPeriod 4D
</CBandUser>

# assign virtualhost 'xyz.org' to user 'dembol'
<VirtualHost *:80>
    ServerName xyz.org
    # Specify virtualhost's owner
    CBandUser dembol

    # 100MB virtualhost bandwidth limit
    CBandLimit 100000

    # redirect to http://abc.org/bandwidth_exceeded.html
    # when the limit has been reached
    CBandExceededURL http://abc.org/bandwidth_exceeded.html

    # virtualhost's scoreboard file
    CBandUserScoreboard /var/run/apache2/dembol.scoreboard

    # a period of time after which the scoreboard will be cleared (50 minutes)
    # (only in >=0.9.5-rc2)
    CBandPeriod 50M
</VirtualHost>

# assign virtualhost 'aga.org' to user 'dembol'
<VirtualHost *:80>
    ServerName aga.org
    # Specify virtualhost's owner
    CBandUser dembol
</VirtualHost>

per-destination bandwidth limiting configuration (only in >=0.9.5-rc1 versions)

In >= 0.9.5-rc1 you can limit traffic to some destination classes. The destination classes are defined by section. The limits for the classes are specified by CBandClassLimit and CBandUserClassLimit commands

# define 'class_1'

<CBandClass class_1>
    CBandClassDst 217.172.231.67
    CBandClassDst 127/8
    CBandClassDst 192.168.0.0/24
    CBandClassDst 10.0.0.20
</CBandClass>

# define 'class_2'
<CBandClass class_2>
    CBandClassDst 192.168.100.100
    CBandClassDst 153.19/16
</CBandClass>

<CBandUser dembol>

    CBandUserLimit 1000000
    CBandUserExceededURL http://edns.pl/bandwidth_exceeded.html
    CBandUserScoreboard /home/dembol/write/user.dembol.scoreboard

    # 500MB limit for 'class_2'
    CBandUserClassLimit class_2 500000
</CBandUser>

<VirtualHost *:80>
    ...
    CBandUser dembol

    # 1GB limit for 'class_1'
    CBandClassLimit class_1 1000000

    # a period of time after which the scoreboard will be cleared (120 seconds)
    # (only in >=0.9.5-rc2)
    CBandPeriod 120S
</VirtualHost>
1 Comment : more...

DELL PERC 6/i on FreeBSD

by on 四月.27, 2009, under FreeBSD

此快raid卡為Lsi 代工

基本上差不多的’效能’

Lsi的raid 在6.1版後 全面進化 核心支援 sata sas 用起來粉快樂

以下裝置系統:

CPU: Dual Core AMD Opteron(tm) Processor 165    (1809.28-MHz K8-class CPU)
Origin = "AuthenticAMD"  Id = 0x20f32  Stepping = 2
Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
Features2=0×1<SSE3>
AMD Features=0xe2500800<SYSCALL,NX,MMX+,FFXSR,LM,3DNow!+,3DNow!>
AMD Features2=0×3<LAHF,CMP>
Cores per package: 2

mfi0: <Dell PERC 6> port 0×9000-0x90ff mem 0xd4040000-0xd407ffff,0xd4000000-0xd403ffff irq 16 at device 0.0 on pci3
mfi0: Megaraid SAS driver Ver 3.00
mfi0: 24311 (294135602s/0×0020/info) – Shutdown command received from host
mfi0: 24312 (boot + 3s/0×0020/info) – Firmware initialization started (PCI ID 0060/1000/1f0c/1028)
mfi0: 24313 (boot + 3s/0×0020/info) – Firmware version 1.11.52-0396
mfi0: 24314 (boot + 3s/0×0008/info) – Battery Present
mfi0: 24315 (boot + 3s/0×0020/info) – Package version 6.0.2-0002
mfi0: 24316 (boot + 10s/0×0002/info) – Inserted: PD 00(e0xff/s0)
mfi0: 24317 (boot + 10s/0×0002/info) – Inserted: PD 00(e0xff/s0) Info: enclPd=ffff, scsiType=0, portMap=00, sasAddr=1221000000000000,0000000000000000
mfi0: 24318 (boot + 10s/0×0002/WARN) – PD 00(e0xff/s0) is not a certified drive
mfi0: 24319 (boot + 10s/0×0002/info) – Inserted: PD 01(e0xff/s1)
mfi0: 24320 (boot + 10s/0×0002/info) – Inserted: PD 01(e0xff/s1) Info: enclPd=ffff, scsiType=0, portMap=01, sasAddr=1221000001000000,0000000000000000
mfi0: 24321 (boot + 10s/0×0002/WARN) – PD 01(e0xff/s1) is not a certified drive
mfi0: 24322 (boot + 10s/0×0002/info) – Inserted: PD 02(e0xff/s2)
mfi0: 24323 (boot + 10s/0×0002/info) – Inserted: PD 02(e0xff/s2) Info: enclPd=ffff, scsiType=0, portMap=02, sasAddr=1221000002000000,0000000000000000
mfi0: 24324 (boot + 10s/0×0002/WARN) – PD 02(e0xff/s2) is not a certified drive
mfi0: 24325 (boot + 10s/0×0002/info) – Inserted: PD 03(e0xff/s3)
mfi0: 24326 (boot + 10s/0×0002/info) – Inserted: PD 03(e0xff/s3) Info: enclPd=ffff, scsiType=0, portMap=03, sasAddr=1221000003000000,0000000000000000
mfi0: 24327 (boot + 10s/0×0002/WARN) – PD 03(e0xff/s3) is not a certified drive

然而要控制他必須使用 MegaCLi

如果照google大神找到資訊 會看到很多 叫你這樣裝(很多的dell機器 使用者)

cd /usr/ports/sysutils/linux-megacli;make install  clean

你會發現 得到以下地雷

===>  linux-megacli-1.01.40_2 is marked as broken: Unfetchable.
*** Error code 1

Stop in /usr/ports/sysutils/linux-megacli.

終於發現 要這樣裝

cd /usr/ports/sysutils/linux-megacli2;make install  clean

會的到以下提示

===================================================================
This port installed a commercial software product with a restricted
license. Please review the license terms at this URL:

http://www.lsi.com/cm/License.do

===================================================================

Add the following to /boot/loader.conf

# For MegaCLi
mfi_linux_load="YES"

Add the following to /etc/sysctl.conf

# For MegaCLi
compat.linux.osrelease=2.6.12

Add the following to /etc/fstab

# For MegaCLi
linproc     /compat/linux/proc  linprocfs rw 0 0
linsys      /compat/linux/sys   linsysfs  rw 0 0

Add the following to /etc/periodic.conf

# !!! Warning: test before running on a production system !!!
# !!! Warning: might hang your system                     !!!
# For daily summary mails and log diffs:
daily_status_mfi_raid_enable="YES"
# In case you want really lots of details enable this:
daily_status_mfi_raid_verbose="YES"
# In case you want the tty logs from the controller
daily_status_mfi_raid_tty_log="YES"

Add the following to /etc/rc.conf

# Save tty log on reboot (you want this)
rc_mfi_raid_tty_log="YES"

If you find mfi(4) too verbose, see mfi_evt_class_t in
/usr/src/sys/dev/mfi/mfireg.h for values you can use in the
hw.mfi.event_class
sysctl variable.

===>   Registering installation for linux-megacli-2.00.12_1
===>  Cleaning for linux-megacli-2.00.12_1

依照設定即可使用

Leave a Comment more...

FreeBSD PHP4 PHP5 APACHE1 APACHE22 共存

by on 四月.16, 2009, under FreeBSD

說明現在公司因為支前專案採用PHP4 APACHE1.3  要轉換到PHP5 APACHE22 其中又不使服務中斷 只好再一台系統上同時安裝兩種

以下只說明 另外安裝的PHP5 APACHE22

安裝apache22
cd /usr/ports/www/apache22
make config PREFIX=/usr/local/apache22 install clean
安裝php5
cd /usr/ports/lang/php5
make config PREFIX=/usr/local/php5 APXS=/usr/local/apache22/sbin/apxs APACHE_VERSION=22 install clean
安裝 PHP5-extions 模組
cd /usr/ports/lang/php5-extensions/
make config PREFIX=/usr/local/php5 LOCALBASE=/usr/local/php5 install

安裝中間如有模組卡住  須先到其模組安裝的PORT  重新安裝

並使用 make PREFIX=/usr/local/php5 LOCALBASE=/usr/local/php5 install FORCE_PKG_REGISTER="yes"

強制安裝  有點暴力@@

Leave a Comment :, , , more...

Freebsd 安裝 iftop

by on 四月.14, 2009, under FreeBSD

引用來源 http://blog.shian.tw/iftop.html/trackback

安裝:

cd /usr/ports/net-mgmt/iftop

make install clean

使用:
# iftop -i eth0

參數說明:
-i: 監控網路卡介面
-B: 以bytes為單位
-n: 以IP顯示不用DNS反解
-N: 只顯示port不顯示服務名稱
-F: 堅看某一網段的網路狀態

快速鍵:

進入iftop後可以使用一些快速鍵來看監控狀態

Host display:

n – 切換解析來源DNS
s – 切換顯示目的ip
d – 切換顯示來源ip
t – 切換進出顯示模式
Port display: N – 切換解析主機port
S – 切換顯示主機port
D – 切換顯示來源port
p – 切換顯示port
Sorting: 1/2/3 – 排列 1/2/3 欄位
< – 排列流量由大至小
> – 排列流量由小至大
o – 凍結目前排列
General: P – 暫停/開始
h – 切換顯示help
b – 切換顯示流量條
B – 切換流量條2/10/40秒的平均數
T – 切換顯示總流量欄位
j/k – j:往下查看 k:往上查看
f – 編輯filter碼
l – set screen filter
L – lin/log scales
! – 執行shell命令
q – 離開
Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!