2 月 272013
 

MySQL复制的使用:(1)配置一个额外的服务器专门作为热备份(hot standby),在Master宕机的时候随时接管任务。(2)直接用服务器上的数据创建报表将大大降低服务器的性能,在某些情况下尤其显著。(3)查看某些查询是否有性能问题,以及服务器是否由于某个糟糕的查询而不同步。

将服务器配置为Master,要确保该服务器有一个活动的二进制日志(binary log)和唯一的服务器ID。

二进制日志上保存了Master上所有的改变,并且可以在Slave上重新执行。服务器ID用于区分服务器。

要创建二进制日志和服务器iD,需要停掉服务器。

2 月 262013
 

CentOS 6.3 最小化安装镜像在图形安装界面手工配置信息

 DEVICE="eth0"
 BOOTPROTO=none
 NM_CONTROLLED="yes"
 ONBOOT=yes
 TYPE="Ethernet"
 UUID="49adb2e7-dd1e-474e-9ea6-73af61132420"
 HWADDR=00:50:56:A8:1D:4B
 IPADDR=192.168.11.181
 PREFIX=24
 GATEWAY=192.168.11.1
 DNS1=202.96.128.86
 DEFROUTE=yes
 IPV4_FAILURE_FATAL=yes
 IPV6INIT=no
 NAME="System eth0"

最小化安装镜像基于文本安装界面下为配置网络接口信息

 DEVICE="eth0"
 BOOTPROTO="dhcp"
 HWADDR="00:50:56:A8:1D:4D"
 NM_CONTROLLED="yes"
 ONBOOT="no"
 TYPE="Ethernet"
 UUID="cab6583e-aab8-4f20-aa32-a6919acfcdd5"

hh

 

2 月 242013
 

MySQL 复制(Replication)允许在出现不可避免的故障的情况下提供高可用的数据服务。

MySQL可以实现大量服务器的高效复制。

复制就是复制一个服务器上(称为主节点服务器或者简称主节点)的所有改变到另一个服务器(称为从服务器或者简称从节点)。

复制常见的用途包括:(1)创建一个主节点的备份,以避免主节点崩溃时丢失数据;(2)拥有一份主节点的副本,从而在不干扰其他业务的情况下执行报表和分析工作。

异步复制的好处在于它比同步复制更快,更具可扩展性,但在那些实时数据很重要的情况下,必须采用同步的方式以保证信息总是最新的。

复制的另一个重要应用是通过添加冗余来保证高可用性。

备份的必要性:(1)如果发现错误,一般在它实际发生以后很长时间才发现,这时复制便不再有效。(2)当建立新的服务器时,用于横向扩展的从节点或者备用的新的主节点,都需要对现有服务器做备份并在新的服务器上恢复这个备份映像。

监控的必要性:即使已经正确搭建了复制,还需要理解系统负载,密切监控可能发生的任何问题。

 

内容引用:
(1) O’Reilly- MySQL High Availability

2 月 232013
 

在CentOS6.3最小化安装环境中需要安装的软件包

[root@squid ~]# yum install wget gcc gcc-c++ make perl

编译安装Squid

 [root@squid ~]# cd squid-3.3.1
 [root@squid squid-3.3.1]# ./configure --prefix=/usr/local/squid
 [root@squid squid-3.3.1]# make all
 [root@squid squid-3.3.1]# make install

安装完成后查看安装文件目录及配置文件

 [root@squid squid-3.3.1]# cd /usr/local/squid/
 [root@squid squid]# ls
 bin etc include lib libexec sbin share var
 [root@squid squid]# ls etc/
 cachemgr.conf mime.conf squid.conf
 cachemgr.conf.default mime.conf.default squid.conf.default
 errorpage.css msntauth.conf squid.conf.documented
 errorpage.css.default msntauth.conf.default
 [root@squid squid]#

Continue reading »

2 月 212013
 

安装编译工具

[root@localhost ~]# yum install gcc make

添加用以执行nginx的用户

[root@localhost conf]# groupadd nginx
[root@localhost conf]# useradd -g nginx nginx -s /sbin/nologin

安装PHP依赖

[root@localhost php-5.2.17]# yum install libxml2-devel

CentOS 6.3最小化安装环境已包含libxml2未包含libxml2-devel

libxml2-devel的安装依赖包关系

Installing:
 libxml2-devel        i686        2.7.6-12.el6_4.1         updates        1.1 M
Installing for dependencies:
 pkgconfig            i686        1:0.23-9.1.el6           base            67 k
 zlib-devel           i686        1.2.3-29.el6             base            44 k
Updating for dependencies:
 libxml2              i686        2.7.6-12.el6_4.1         updates        800 k
 zlib                 i686        1.2.3-29.el6             base            73 k

编译安装PHP环境

[root@localhost php-5.2.17]# ./configure --prefix=/usr/local/php --enable-fastcgi
[root@localhost php-5.2.17]# make
[root@localhost php-5.2.17]# make install

将路径加入系统环境变量

[root@localhost ~]# vi /etc/profile
 export PATH=/usr/local/php/bin:$PATH
[root@localhost ~]# source /etc/profile
[root@localhost php-5.2.17]# cp php.ini-dist /usr/local/php/lib/php.ini

启动php-cgi模式,监听端口9000,并使用指定的php.ini配置,后台运行

[root@localhost ~]# php-cgi -b 9000 -c /usr/local/php/lib/php.ini &

查看php-cgi监听端口

[root@localhost ~]# netstat -ltun |grep 9000
 tcp        0      0 0.0.0.0:9000                0.0.0.0:*                   LISTEN
 [root@localhost ~]#

安装nginx编译过程中所需要的依赖软件包

[root@localhost nginx-1.4.0]# yum install gcc-c++ perl

编译安装nginx 1.4.0版本

[root@localhost nginx-1.4.0]# ./configure --prefix=/usr/local/nginx \
 > --with-http_stub_status_module --with-http_ssl_module \
 > --with-pcre=../pcre-8.32/ --with-zlib=../zlib-1.2.8 \
 > --with-openssl=../openssl-1.0.1e
[root@localhost nginx-1.4.0]# make
[root@localhost nginx-1.4.0]# make install

将nginx加入系统环境变量

export PATH=/usr/local/nginx/sbin:$PATH

查看nginx版本

[root@localhost ~]# nginx -v
 nginx version: nginx/1.4.0
 [root@localhost ~]#

默认示例配置文件部分

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}

启用FastCGI并修改配置

location ~ \.php$ {
 root           html;
 fastcgi_pass   127.0.0.1:9000;
 fastcgi_index  index.php;
 #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
 fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
 include        fastcgi_params;
 }

建立PHP测试页面文件

[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost html]# vi hello.php
 <?php phpinfo(); ?>

启动nginx并查看端口监听状态

[root@localhost ~]# netstat -ltu |grep http
 tcp        0      0 *:http                      *:*                         LISTEN
[root@localhost ~]#

访问默认首页

nginx-php-01

 

访问PHP测试页面

…… nginx-php-02

相关下载:
(1) nginx 1.4.0 (2)(3)

2 月 202013
 

下载最新版本nginx,pcre,openssl,zlib并解压缩

nginx-01-01

编译安装

 [root@localhost nginx-1.2.7]# ./configure --prefix=/usr/local/nginx \
 --with-pcre=../pcre-8.32/ --with-zlib=../zlib-1.2.7 \
 --with-openssl=../openssl-1.0.1e --with-http_ssl_module
[root@localhost nginx-1.2.7]#make
[root@localhost nginx-1.2.7]#make install

查看安装完成nginx的版本

[root@localhost sbin]# ./nginx -v
 nginx version: nginx/1.2.7

查看nginx命令参数

[root@localhost sbin]# ./nginx -h
nginx version: nginx/1.2.7
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
 -?,-h : this help
 -v : show version and exit
 -V : show version and configure options then exit
 -t : test configuration and exit
 -q : suppress non-error messages during configuration testing
 -s signal : send signal to a master process: stop, quit, reopen, reload
 -p prefix : set prefix path (default: /usr/local/nginx/)
 -c filename : set configuration file (default: conf/nginx.conf)
 -g directives : set global directives out of configuration file
[root@localhost sbin]#

启动

[root@localhost sbin]# ./nginx
 [root@localhost sbin]# netstat -lut |grep http
 tcp 0 0 *:http *:* LISTEN
 [root@localhost sbin]#

通过浏览器访问nginx服务器
nginx-01-02

错误分析1

./configure: error: the HTTP rewrite module requires the PCRE library.
 You can either disable the module by using --without-http_rewrite_module
 option, or install the PCRE library into the system, or build the PCRE library
 statically from the source with nginx by using --with-pcre=<path> option.

错误分析2

./configure: error: the HTTP gzip module requires the zlib library.
 You can either disable the module by using --without-http_gzip_module
 option, or install the zlib library into the system, or build the zlib library
 statically from the source with nginx by using --with-zlib=<path> option.

错误分析3

./configure: error: SSL modules require the OpenSSL library.
 You can either do not enable the modules, or install the OpenSSL library
 into the system, or build the OpenSSL library statically from the source
 with nginx by using --with-openssl=<path> option.

Nginx官方文档配置参数

--prefix=path
 --sbin-path=path
 --conf-path=path
 --pid-path=path
 --error-log-path=path
 --http-log-path=path
 --user=name
 --with-select_module
 --without-select_module
 --with-poll_module
 --without-poll_module
 --without-http_gzip_module
 --without-http_proxy_module
 --with-http_ssl_module
 --with-pcre=path
 --with-pcre-jit
 --with-zlib=path
--with-cc-opt=parameters
 --with-ld-opt=parameters

Nginx官方文档配置示例

./configure
 --sbin-path=/usr/local/nginx/nginx
 --conf-path=/usr/local/nginx/nginx.conf
 --pid-path=/usr/local/nginx/nginx.pid
 --with-http_ssl_module
 --with-pcre=../pcre-4.4
 --with-zlib=../zlib-1.1.3

相关下载:
(1)nginx 1.2.7 (2)openssl 1.0.1e (3)pcre 8.32 (4)zlib 1.2.7
内容引用:
(1)