这里使用LVS的IP负载均衡技术,它由IPVS模块实现,IPVS安装在Director Server(简称DS)上,在DS(这里是192.168.1.3)上虚拟一个IP(Virtual IP 简称VIP,这里是192.168.1.4),用户通过这个虚拟出来的IP访问服务器。这样用户请求通过VIP到达DS,然后DS从RS列表挑选一个RS响应。
挑选的RS如何响应用户请求呢?有三种方式VS/NAT,VS/TUN,VS/DR,这里使用VS/DR方式。
编辑/etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib # su
man帮助文档,编辑/etc/man.config
MANPATH /usr/local/mysql/man
头文件
ln -sv /usr/local/mysql/include/ /usr/include/mysql# service mysqld start
# chkconfig --add mysqld# mysql
mysql> UPDATE user SET password=PASSWORD('xiaoming') WHERE USER='root';
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'192.168.1.%' IDENTIFIED BY 'xiaoming';
mysql> FLUSH PRIVILEGES;
DNS搭建
进192.168.1.8
# yum -y install bind bind-utils
配置/etc/named.conf 文件
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
directory "/var/named";
recursion yes;
};
zone "." IN {
type hint;
file "named.ca";
};
logging {
channel query_log {
file "/var/log/named/bind_query.log" versions 3;
severity dynamic;
print-category yes;
print-time yes;
print-severity yes;
};
category queries { query_log; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
配置/etc/named.rfc1912.zones文件
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "localhost.localdomain" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.empty";
allow-update { none; };
};
zone "mingxiao.info" IN {
type master;
file "mingxiao.info.zone";
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "192.168.1.zone";
};
# cd /var/named
配置mingxiao.info.zone
$TTL 86400
@ IN SOA ns.mingxiao.info admin.mingxiao.info. (
2015041211
2H
10M
3D
1D )
IN NS ns
ns IN A 192.168.1.8
www IN A 192.168.1.4
配置192.168.1.zone
$TTL 86400
@ IN SOA ns.mingxiao.info admin.mingxiao.info. (
2015041211
2H
10M
3D
1D )
IN NS ns.mingxiao.info.
8 IN PTR ns.mingxiao.info.
4 IN PTR www.mingxiao.info.# chown root:named mingxiao.info.zone 192.168.1.zone
# chmod 640 mingxiao.info.zone 192.168.1.zone
各主机中/etc/resolv.conf配置,DNS都指向192.168.1.8主机
nameserver 192.168.1.8
#service named start
LAP搭建
进192.168.1.5
安装Apache
1,安装apr
# cd /usr/local
# tar xf apr-1.5.1.tar.bz2
# cd apr-1.5.1
# ./configure --prefix=/usr/local/apr
# make
# make install
2,安装apr-util
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install
3,安装httpd
# tar xf httpd-2.4.10.tar.bz2
# cd httpd-2.4.10
# ./configure \
--prefix=/usr/local/apache \
--sysconfdir=/etc/httpd \
--enable-so \
--enable-rewrite \
--enable-ssl \
--enable-cgi \
--enable-cgid \
--enable-modules=most \
--enable-mods-shared=most \
--enable-mpms-shared=all \
--with-mpm=event \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \出现错误:
configure: error: pcre-config for libpcre not found. PCRE is required anavailabl from
解决办法:
# yum install -y pcre-devel
# make
# make install编辑/etc/httpd/httpd.conf,加入
PidFile "/var/run/httpd.pid"
提供SysV风格的启动脚本:/etc/init.d/httpd
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
编辑 /etc/pki/tls/openssl.cnf
[ CA_default ]
dir = /etc/pki/CA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
#unique_subject = no # Set to 'no' to allow creation of
# several ctificates with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = CN
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = HeNan
localityName = Locality Name (eg, city)
localityName_default = AnYang
0.organizationName = Organization Name (eg, company)
0.organizationName_default = XiaoMing
organizationalUnitName = Organizational Unit Name (eg, section)
organizationalUnitName_default = Tech
生成自签证书
# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3655 这里会让输入一些有关证书的信息,如国家,省份等,以刚才在openssl.cnf配置中填写的默认选项,直接敲回车即可,下两项随意写了。
Common name : ca.mingxiao.info
Email Address : ca@mingxiao.info# touch index.txt
# touch serial
# echo 01 > serial