最新的 日志 »


如今 Intel 自家的编译器已经发展到了第12个发行版,对于兼容性来说达到了极大的提高,以往版本无法编译的程序现在大部分都可以编译通过了,那么现在,已经到了介绍如何使用 ICC 的时机咯。(采用 ICC 编译的程序运行效率普遍比 GCC 高10%~300%)当然拉,我们还是只介绍 64 位 Linux OS 的安装方式,32位的朋友请先 RIOS


Step 1:确保你的服务器安装的是 Intel 芯片


Step 2:安装 JDK


mkdir /software
cd software
wget http://download.oracle.com/otn-pub/java/jdk/6u26-b03/jdk-6u26-linux-x64.bin
chmod 777 jdk-6u26-linux-x64.bin
./jdk-6u26-linux-x64.bin


请按照提示一路往下 yes, 最终生成 jdk 文件夹


mv jdk-($version) /usr/local/jdk


修改环境变量


nano /etc/profile


在最下方插入


export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar


重启服务器


reboot


检测 JDK 是否安装成功


java -version


Step 3:安装 ICC


首先更新需要支持的软件包


apt-get install gcc g++ libstdc++6


下载并安装 ICC 12


cd /software
wget http://registrationcenter-download.intel.com/akdlm/irc_nas/2136/l_ccompxe_intel64_2011.4.191.tgz
tar zxf l_ccompxe_intel64_2011.4.191.tgz
cd l_ccompxe_intel64_2011.4.191
./install.sh


一路往下,遇到输入序列号部分请输入 N49V-RFT67VK7 注意这是非商用版本,安装成功后需要首先开启编译器系统集成


source /opt/intel/composerxe-2011.4.191/bin/iccvars.sh intel64


至此 ICC 安装成功,检测一下,如遇到文本中未指出错误,请开动脑筋 Google


icc -v


Step 4:安装 PHP NGINX 支持软件包,以下软件包若不偷懒也可采用 ICC 编译


apt-get install autoconf libfreetype6-dev libxml2-dev zlib1g-dev linux-libc-dev libglib2.0-dev bzip2 libbz2-dev libncurses5-dev curl libcurl4-openssl-dev e2fsprogs libkrb5-dev libidn11-dev openssl libssl-dev make libsasl2-dev libperl-dev libgeoip-dev


下载需要安装的软件


cd /software
wget http://saco.iamalex.org/software/libiconv-1.13.1.tar.gz
wget http://saco.iamalex.org/software/libmcrypt-2.5.8.tar.gz
wget http://saco.iamalex.org/software/mcrypt-2.6.8.tar.gz
wget http://saco.iamalex.org/software/mhash-0.9.9.9.tar.gz
wget http://saco.iamalex.org/software/php-5.3.6.tar.gz
wget http://saco.iamalex.org/software/memcached-1.4.5.tar.gz
wget http://saco.iamalex.org/software/memcache-2.2.6.tgz
wget http://saco.iamalex.org/software/pcre-8.12.tar.gz
wget http://saco.iamalex.org/software/nginx-1.0.3.tar.gz
wget http://saco.iamalex.org/software/jpegsrc.v8c.tar.gz
wget http://saco.iamalex.org/software/libpng-1.5.2.tar.gz
wget http://saco.iamalex.org/software/GD_2_0_33.tar.gz
wget http://saco.iamalex.org/software/libevent-2.0.12-stable.tar.gz


针对Ubuntu 11.04 Server X86-64改写支持文件


nano /usr/asm/errno.h
nano /usr/include/linux/param.h
nano /usr/include/sys/syscall.h
nano /usr/include/asm-generic/unistd.h
nano /usr/include/bits/socket.h
nano /usr/include/asm-generic/socket.h
nano /usr/include/bits/ioctls.h
nano /usr/include/linux/ioctl.h
nano /usr/include/bits/ioctl-types.h

修改这些文件


asm/
改写为
asm-generic/


编辑链接库文件


nano /etc/ld.so.conf.d/lib.conf


输入


/usr/lib
/usr/local/lib
/opt/intel/composerxe-2011.4.191/compiler/lib/intel64


重新载入链接库


ldconfig


编译安装各种支持类库


tar zxf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
make distclean
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure -prefix=/usr/local
make
make install
cd ..


tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install
ldconfig
cd libltdl
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure --enable-ltdl-install
make
make install
cd ../../


tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install
cd ..


ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config


tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
ldconfig
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install
cd ..


tar zxf jpegsrc.v8c.tar.gz
cd jpeg-8c
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install


tar zxf libpng-1.5.2.tar.gz
cd libpng-1.5.2
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install


tar zxf GD_2_0_33.tar.gz
cd pierrejoye-gd-libgd-5551f61978e3/src
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install
ldconfig


Step 5:安装 PHP


创建编译文件


cd /software
tar zxf php-5.3.6.tar.gz
cd php-5.3.6
nano compiler-php.sh


输入以下内容,注意请按照你的 CPU 规格填写 CFLAGS 及 CXXFLAGS 特征,在此采用 Mysqlnd 实现 Mysql / Mysqli / PDO


#!/bin/bash
make distclean
DEST=/usr/local/webserver/php
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
./configure \
-prefix=$DEST \
-enable-fpm \
-enable-force-cgi-redirect \
-enable-fastcgi \
-enable-mbstring \
-enable-mbregex \
-enable-pcntl \
-enable-exif \
-enable-sockets \
-enable-sysvsem \
-enable-sysvshm \
-enable-inline-optimization \
-enable-zend-multibyte \
-enable-xml \
-enable-discard-path \
-enable-bcmath \
-enable-shmop \
-enable-sysvsem \
-enable-sockets \
-enable-gd-native-ttf \
-with-mcrypt \
-with-gd \
-with-openssl \
-enable-inline-optimization \
-disable-ipv6 \
-disable-debug \
-disable-rpath \
-with-mysql=mysqlnd \
-with-mysqli=mysqlnd \
-with-pdo-mysql=mysqlnd \
-with-config-file-path=$DEST/etc \
-with-config-file-scan-dir=$DEST/etc/php.d \
-with-zlib \
-with-curl \
-with-curlwrappers \
-with-gettext \
-with-freetype-dir \
-with-iconv-dir=/usr/local \
-with-jpeg-dir \
-with-png-dir \
-with-libxml-dir=/usr \
-with-mhash \
-with-xmlrpc \
-enable-zip \
-enable-soap \
-with-pcre-regex


对编译文件授权并执行配置编译


chmod 777 compiler-php.sh
./compiler-php.sh
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /usr/local/webserver/php/etc/php.ini


编译安装 Memcached 及 PHP5 扩展模块


tar zxf libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install
cd ../


cd /software
tar zxf memcached-1.4.5.tar.gz
cd memcached-1.4.5
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure
make
make install
cd ../
ldconfig


启动 Memcached


memcached -d -m 2048 -u root -l 10.0.0.18 -p 34567 -c 51200 -P /tmp/memcached.pid


tar zxvf memcache-2.2.6.tgz
cd memcache-2.2.6/
/usr/local/webserver/php/bin/phpize
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ..


修改 php.ini 配置


nano /usr/local/webserver/php/etc/php.ini

修改以下部分

extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/"

output_buffering
Default Value: On
Development Value: 4096
Production Value: 4096

cgi.fix_pathinfo=0

在最后添加
extension = "memcache.so"


创建www用户及用户组


/usr/sbin/groupadd www
/usr/sbin/useradd -g www www


创建虚拟主机目录并授权


mkdir /webs
chmod +w /webs
chown -R www:www /webs


创建php-fpm配置文件


nano /usr/local/webserver/php/etc/php-fpm.conf


;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr/local/webserver/php). This prefix can be dynamicaly changed by using the
; '-p' argument from the command line.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p arguement)
; - /usr/local/webserver/php otherwise
;include=etc/fpm.d/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /usr/local/webserver/php/var
; Default Value: none
pid = /usr/local/webserver/php/logs/php-fpm.pid

; Error log file
; Note: the default prefix is /usr/local/webserver/php/var
; Default Value: log/php-fpm.log
error_log = /usr/local/webserver/php/logs/php-fpm.log

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = error

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
emergency_restart_threshold = 10

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
emergency_restart_interval = 1m

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
process_control_timeout = 5s

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = yes

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[default]

; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr/local/webserver/php) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
listen.backlog = -1

; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen.allowed_clients = 127.0.0.1

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0666
listen.owner =
listen.group =
listen.mode = 0666

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www
group = www

; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives:
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; Note: This value is mandatory.
pm = static

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 320

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
;pm.start_servers = 20

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.min_spare_servers = 5

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.max_spare_servers = 35

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 102400

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
; accepted conn - the number of request accepted by the pool;
; pool - the name of the pool;
; process manager - static or dynamic;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes.
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic')
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
; accepted conn: 12073
; pool: www
; process manager: static
; idle processes: 35
; active processes: 65
; total processes: 100
; max children reached: 1
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout =0

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_slowlog_timeout = 0

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow

; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =

; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
;chdir = /var/www

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
catch_workers_output = yes

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr/local/webserver/php)

; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M


启动php-cgi进程


mkdir -p /usr/local/webserver/php/logs/

ulimit -SHn 65535
/usr/local/webserver/php/sbin/php-fpm


Step 6:安装 Nginx


安装pcre 注意pcre并不兼容icc编译


tar zxvf pcre-8.12.tar.gz
cd pcre-8.12
LD=xild \
AR=xiar \
CFLAGS='-Os' \
CXXFLAGS='-Os' \
./configure
make
make install
cd ..
ldconfig


安装nginx


tar zxvf nginx-1.0.3.tar.gz
cd nginx-1.0.3
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel' \
CXXFLAGS='-O3 -axsse4.2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti' \
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_geoip_module
make
make install
cd ..


创建nginx配置文件


nano /usr/local/webserver/nginx/conf/nginx.conf


user www www;
worker_processes 8;
pid /usr/local/webserver/nginx/nginx.pid;
worker_rlimit_nofile 51200;

events
{
use epoll;
worker_connections 51200;
}

http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 200m;
access_log /dev/null;
error_log /usr/local/webserver/nginx/logs/error.log;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
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 on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /webs;

location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
access_log on;
}
}


创建fcgi.conf


fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;


启动Nginx


ulimit -SHn 65535
/usr/local/webserver/nginx/sbin/nginx


创建PHP测试文件


nano /webs/index.php

phpinfo();
?>


配置开机启动


nano /etc/rc.local

ulimit -SHn 65535
/usr/local/webserver/php/sbin/php-fpm start
/usr/local/webserver/nginx/sbin/nginx


优化内核参数


nano /etc/sysctl.conf

在末尾添加

net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768

net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800

net.ipv4.ip_local_port_range = 1024 65535

使设置生效


/sbin/sysctl -p


无缝重启Nginx


/usr/local/webserver/nginx/sbin/nginx -s reload


无缝重启php


kill -SIGUSR2 `cat /usr/local/webserver/php/logs/php-fpm.pid`

岳麓

他们每天都快乐的生活着,直到晚上,一个人面对自己的时候。

寂寞的忍不住想找人聊聊,却又不知道该说些什么。往往一两个字就彼此交错。流动的城市中,忙的停不下来的时候,总是最充实的。

人生就是这样,充斥着各种陌生人。孤单了,就要找个寄托,心里想的,却从未说出口过。永远在穿梭中度过的我们,你是否真的有停下来的勇气,审视下自己到底要的是什么。

就像那山中的岳麓吧,淡淡的讲课,因为你总是别人的别人,并不是说给你听的。

回家的时候很幸福,因为慢慢发觉自己不再记得,在人群中,把一切全忘了。

服务器集群的最佳廉价解决方案

今天要讲的主题是 —- 如何搭建世界上最便宜、最强大、最高效、最小的服务器集群,OY~~

今天的主角是 MAC MINI,没错,就是 APPLE MAC MINI

你可以以每台 4000 RMB 左右的价格拿下,具体规格为:

  • 2.26GHz Intel Core 2 Duo processor
  • 3MB on-chip shared L2 cache running 1:1 with processor speed
  • 1066MHz frontside bus
  • 2GB (two 1GB SO-DIMMs) of 1066MHz DDR3 SDRAM; two SO-DIMM slots support up to 4GB
  • 如果是 500 台,价格那么就是 4000 * 500 = 2000000 RMB,集群后的具体规格为

  • 2.26GHz Intel Core 2 Duo processor * 500 = 1130GHz CPU 计算能力
  • 3MB on-chip shared L2 cache running 1:1 with processor speed
  • 1066MHz frontside bus
  • 2GB (two 1GB SO-DIMMs) of 1066MHz DDR3 SDRAM; two SO-DIMM slots support up to 4GB  * 500 = 1TB 内存
  • 附带交换机、机架、电源等费用,再加一台 XEON 或 安腾的母机,那么估计费用不会超过 500万 RMB

    换算成小型集群,10台吧,那么价格就仅为 4 万 RMB,但是你却可以在 2U 的空间内达到 20颗芯片 40G内存 5TB 的计算及存储能力,竟然如此廉价

    安装 Snow Leopard Server 之后,搭配高效千兆以太网交换机组成局域网来提供强大的计算能力,完全可以胜任 web / database 各种大型集群的需求

    那么从性能上来说,10台 2.26GHz Intel Core 2 Duo 与 1台 DELL XEON 5530 * 2 / 24G Mem 哪个更强大呢?知道集群强大之处的人自然知道,不然为何还需要 VMWARE VSPHERE 这种东西的存在呢,恶哈哈

    到底是不是呢,下面是一张 500 台 MAC MINI 集群的照片

    MAC MINI LB

    Debian 安装 DRBD8 及 GFS2

    系统需求

    2.6.24内核及以上
    apt-get update
    apt-get install linux-image-2.6.24-etchnhalf.1-686
    apt-get install linux-headers-2.6.24-etchnhalf.1-686
    reboot
    安装 dpkg-dev 及其他依赖的 deb 包
    apt-get install dpkg-dev debhelper dpatch fakeroot gcc libc6-dev bzip2
    更新你的 source.list 文件并取得最新软件列表
    deb http://ftp.de.debian.org/debian lenny main
    deb-src http://ftp.de.debian.org/debian lenny main
    #deb http://ftp.de.debian.org/debian etch main
    #deb-src http://ftp.de.debian.org/debian etch main
    apt-get update

    取得 GFS2 安装文件

    首先,创建一个目录来存放安装文件
    mkdir build
    cd build/
    取得源文件
    apt-get source gfs2-tools
    与此同时,取得安装必须的其他文件
    apt-get source findutils libopenais-dev libvolume-id-dev
    在接下去的步骤中,你将不再需要 lenny 安装源了,将 source.list 修改回去
    #deb http://ftp.de.debian.org/debian lenny main
    #deb-src   http://ftp.de.debian.org/debian lenny main
    deb   http://ftp.fr.debian.org/debian/ etch main
    deb-src   http://ftp.fr.debian.org/debian/ etch main
    deb   http://www.backports.org/debian etch-backports main contrib non-free
    如果你使用 backports 作为源,可在导入 key 后再次验证
    apt-get update
    apt-get install debian-backports-keyring
    apt-get update
    有空待续

    赛总教你玩TT

    什么是TT,当然不是电源电风扇了,TT是key-value数据库的一种,全名是 Tokyo Tyrant。

    我们不讨论哪一种key-value数据库的性能强劲,哪一种又是哪个上市公司赞助的,其实计算机发展到今天,我们的思路要回归的原始社会,对于任何一种大型集群结构,机器呢一定多比少好,芯片呢一定快比慢好,无论是x86平台上的服务器或是家用机,power平台或者什么SGI啊,AIX啊,SOLORIS啊,大致都是一样的。

    下面赛总开始讲课了。

    我们需要一台linux的服务器,至于什么硬件结构不是很重要。

    随便找个文件夹,下载 Mikio Hirabayashi 写的Tokyo Cabinet

    cd /opt

    wget http://1978th.net/tokyocabinet/tokyocabinet-1.4.33.tar.gz

    tar -zvxf tokyocabinet-1.4.33.tar.gz

    cd tokyocabinet-1.4.33

    ./configure

    make

    make install

    装完之后装 Tokyo Tyrant

    cd /opt

    wget http://1978th.net/tokyotyrant/tokyotyrant-1.1.34.tar.gz

    tar -zvxf tokyotyrant-1.1.34.tar.gz

    cd tokyotyrant-1.1.34

    ./configure

    make

    make install

    这样就全部装完了。

    找个文件夹运行一下

    mkdir -p /database

    cd /database

    ulimit -SHn 100000

    ttserver -host 127.0.0.1 -port 10001 -thnum 32 -dmn -pid /database/test.pid -log /database/test.log -le -ulog /database/ -ulim 128m -sid 1 -rts /database/test.rts /database/test.tct

    如此便在你的/database目录下产生了几个test开头的文件,注意tct为table型数据库,tcb为b-tree数据库,tch为hash数据库,tcf为定长数据库。

    如何沟通

    日本人提供了四种API,分别为JAVA, RUBY, PERL, LUA

    这里中国人告诉你一个PHP的,注意PHP版本需要5.2.0以上

    cd /opt

    wget http://pecl.php.net/get/tokyo_tyrant-0.1.0.tgz

    tar -zvxf tokyo_tyrant-0.1.0.tgz

    cd tokyo_tyrant-0.1.0

    phpize

    ./configure

    make

    make install

    编辑下php.ini,加入刚装好的tt插件

    重启下apache或者什么lighttpd,nginx

    看一下phpinfo,应该就有了

    现在你已经可以使用php与TT沟通了。

    我们写一个简单的例子

    <?php
    /* Connect to a table database */
    $tt = new TokyoTyrantTable(“localhost”, 10001);

    /* Passing null to put generates a new uid */
    $index = $tt->put(null, array(“column1″ => “恶哈哈”, “column2″ => “更多的恶哈哈”));

    /* Get the row back */
    var_dump($tt->get($index));

    /* Modify an existing row */
    $tt->put($index, array(“column1″ => “OY”, “column2″ => “更多的OY”));

    /* Get the row back */
    var_dump($tt->get($index));
    ?>

    将看到以下输出

    array(2) {
      ["column1"]=>
      string(9) "恶哈哈"
      ["column2"]=>
      string(9) "更多的恶哈哈"
    }
    array(2) {
      ["column1"]=>
      string(10) "OY"
      ["column2"]=>
      string(11) "更多的OY"
    }

    如此就差不多OK了,开动你的小脑筋,配合分布式文件系统,分布式硬件架构,海量的内存,再加上我们的分布式非关系型数据库,应用到各种超大型项目中去吧。

    恶哈哈哈哼哈哈哈哈哈

    十六色

    七色的光化为白色,又离散千万道色彩。

    若尝试复杂的人生,也许却也是那样简单吧。

    您好,IA又开了 ~

    来吧Skydrive

    MSN的Skydrive扩容到了25G,这是一个帐号的大小,那么40个呢,就是1T了,恶哈哈,现在让我们把Skydrive变成一块桌面硬盘。

    skydrive-logo

    首先,下载 Gladinet Desktop ,安装完成之后,就可以挂载虚拟硬盘了,右键点击右下角图标

    My Virtual Directories ->  Mount Storage as Virtual Directory -> Windows Live Skydrive

    输入MSN用户名及密码,挂载就成功了,请注意,单独文件大小不能超过 50M,分卷压缩就行了

    艺术家们,请像虐待自己的硬盘那样鞭打MSN吧,谢谢

    00004

    ehaha

    北京

    又在故宫边走了一圈。

    又从灯景中走到黑暗。

    若有一杯酒能否喝醉?

    你我终究是一粒尘沙,在武夷山,抑或是在北京。借用你那本书的名字,原来,一切都无所谓了。

    只喝一杯

    只喝一杯

    皇帝死了

    皇帝死了

    谁的宗祠

    谁的宗祠

    某一个晚上

    很多时候需要请朋友来坐坐,说说最近的故事。

    在你进入这博客的时候,便能听到我所听的音乐了,音乐替我把故事说给你听,无关年代,岁数,只是有那么点回忆,渐渐隐没在夜空之中,不变的是那海上明月,玉宇琼楼。

    三个澳洲瓶子

    三个澳洲瓶子

    Dal Broi ‘High Altitude’ Private Collection Heathcote Shiraz 2005

    深紫红的酒色,而泛着的微光又仿佛水波上的月光,细细看去又如同彩虹一般,一点点橡木,一点点薄荷,柔软顺滑的口感,香气中带着甘草与黑胡椒及淡淡的水果甜,入口激情热烈,待得饮后又平衡的余味,似乎将夜色渐渐褪去,时光往复,某一个晚上,也只是众多的某一个夜晚而已。

    阿姆斯特丹的机场每一个免税商店都叫“BUY BYE”。

    他们多了解那些旅行的人的伤感。要说再见了,怎么能无动于衷呢?

    但是,唯有爱情。

    它以甜蜜的温柔的心疼的方式潜入了另一个世界。

    一个和你十岁的时候曾经看见过的世界。

    在那个世界里,没有时间与空间的概念。

    所以。我们叫它-永恒。

      Powered by WordPress | Theme: Motion by 85ideas.