记录一下从无到有的项目平台架构过程,目前团队缺人因此啥都得自己动手~

平台初始化过程中主要涉及到几方面的事情
1、服务器硬件方面
涉及服务器采购,部署和内网搭建的事情;这部分要考虑未来服务必须具备跨机房容灾的能力,因此至少采购两个以上idc机房的服务器,另外内网至少使用100M光纤专线直连;
2、服务器软件方面
主要涉及服务器命名、服务器内网互联和外网屏蔽、服务器目录部署规划、基础库安装、基础软件安装、内网DNS搭建等工作;
2.1、服务器命名
按照[机房]-[产品线]-[模块].[子机房].[平台名].com命名,比如:xs-cloud-lvs00.xs01.xxx.com表示萧山机房的云产线lvs服务模块的机器;
2.2、服务器目录部署
主要防止目录结构混乱导致后期op维护时被混淆;
项目主目录/home/xxx下,local(用于部署线上服务模块和基础模块),libs(各种基础脚本、类库存放),data(所有数据文件存放),opbin(rd和op的个人目录,比如:opbin/用户名/xxx),opdir(线上手动操作脚本放置),opdir/downloads(软件安装包目录),opdir/noah(上线和回滚脚本、配置、模块放置)
2.3、基础库安装
yum安装 gcc,g++,vim-enhanced,python-devel,readline-devel,zlib-devel,libxml2-devel,curl-devel,sysstat,openssl-devel,bzip2-devel
2.4、基础软件安装
1)java环境安装
安装源:xs-cloud-bak00.xs01.xxx.com / 84上 /home/xxx/opdir/downloads/java.tar.gz
安装方法:解压缩后,拷贝java目录到/home/xxx/local/

2)python和paramiko安装
python安装: yum install python (2.6.6版本)
pycrypto安装:
源代码位于xs-cloud-bak00.xs01.xxx.com / 84上 /home/xxx/opdir/downloads/pycrypto-2.4.1.tar.gz
安装步骤:解压缩后 python setup.py build
python setup.py install

paramiko安装
源代码位于xs-cloud-bak00.xs01.xxx.com / 84上 /home/xxx/opdir/downloads/paramiko-1.7.6.tar.gz
安装步骤:解压缩后 python setup.py build
python setup.py install

3)mysql一键安装
安装源:xs-cloud-bak00.xs01.xxx.com / 84上 /home/xxx/opdir/downloads/mysql_install.tar.gz
安装到位置:/home/xxx/local/mysql
安装方法:解压缩后,运行mysql_install.sh
参数:./mysql_install.sh mysql-5.0.51b/ /home/xxx/local/mysql 3306

4)redis安装
安装源:xs-cloud-bak00.xs01.xxx.com / 84上 /home/xxx/opdir/downloads/redis-2.8.9.tar.gz
安装到位置:/home/xxx/local/redis
安装方法:
make
./install.sh

5)php安装
安装源:xs-cloud-bak00.xs01.xxx.com / 84上 /home/xxx/opdir/downloads/php.tar.gz
安装到位置:/home/xxx/local/php
安装方法:解压后
./configure –prefix=/home/xxx/local/php –with-mysql=/home/xxx/local/mysql –with-mysqli=/home/xxx/local/mysql/bin/mysql_config –with-config-file-path=/home/xxx/local/php/etc/ –with-mbstring –enable-mbstring=all –enable-pcntl –enable-fastcgi –enable-fpm
make
make install
最后拷贝php安装目录下的php.ini到/home/xxx/local/php/etc

6)php扩展安装(memcache, redis, curl, gd)
curl扩展安装
源码位置:/home/xxx/opdir/downloads/php/ext/curl
安装方法:
phpize
./configure –with-curl=DIR
make & make install

7)redis扩展安装
源码位置:/home/xxx/opdir/downloads/php/ext/owlient-phpredis-90ecd17
安装方法:
phpize
./configure –with-php-config=/home/xxx/local/php/bin/php-config
make & make install

8)memcache扩展安装
源码位置:/home/xxx/opdir/downloads/php/ext/mongo-1.5.4
安装方法:
./configure –with-php-config=/home/xxx/local/php/bin/php-config
make && make install

9)freetype安装
wget “http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2″
tar jxvf freetype-2.4.0.tar.bz2
cd freetype-2.4.0
./configure –prefix=/home/xxx/libs/freetype && make && make install

10)jpegsrc安装
wget “http://www.ijg.org/files/jpegsrc.v9.tar.gz”
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9
CFLAGS=”-O3 -fPIC” ./configure –prefix=/home/xxx/libs/jpeg –enable-shared –enable-static && make && make install

11)libpng安装
wget “http://downloads.sourceforge.net/project/libpng/libpng12/1.2.50/libpng-1.2.50.tar.gz?r=http%3A%2F%2Fwww.libpng.org%2Fpub%2Fpng%2Flibpng.html&ts=1376631135&use_mirror=nchc”
tar zxvf libpng-1.2.50.tar.gz
cd libpng-1.2.50
CFLAGS=”-O3 -fPIC” ./configure –prefix=/home/xxx/libs/libpng && make && make install

12)gd安装
源码位置:/home/xxx/opdir/downloads/php/ext/gd
phpize
./configure –with-php-config=/home/xxx/local/php/bin/php-config –with-jpeg-dir=/home/xxx/libs/jpeg –with-png-dir=/home/xxx/libs/libpng –with-freetype-dir=/home/xxx/libs/freetype
make & make install

13)httpguard安装

https://www.lxconfig.com/thread-119-1-1.html

14)libiconv安装
wget “http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz”
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure –prefix=/home/xxx/libs/libiconv && make && make install

15)libxml安装
wget “ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz”
tar zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure –prefix=/home/xxx/libs/libxml && make && make install

16)另一种直接安装方法
./configure –prefix=/home/xxx/local/php –with-mysql=/home/xxx/local/mysql –with-mysqli=/home/xxx/local/mysql/bin/mysql_config –with-config-file-path=/home/xxx/local/php/etc/ –enable-mbstring=all –enable-pcntl –enable-fpm –with-bz2 –with-curl –enable-ftp –enable-sockets –disable-ipv6 –with-gd –with-jpeg-dir=/home/xxx/libs/jpeg –with-png-dir=/home/xxx/libs/libpng –with-freetype-dir=/home/xxx/libs/freetype –enable-gd-native-ttf –with-iconv-dir=/home/xxx/libs/libiconv –enable-calendar –with-gettext –with-libxml-dir=/home/xxx/libs/libxml –with-zlib –enable-dom –enable-xml –enable-bcmath
make
make install

2.5、智能DNS安装(安装到 bj-cloud-bind00.bj01.xxx.com上,步骤10.8,10.9来不及可以先不配置)
源码位置:xs-cloud-bak00.xs01.xxx.com / 84上 /home/xxx/opdir/downloads/bind-9.9.5rc2.tar.gz
安装bind方法:
1)切换到root用户
2)解压缩bind-9.9.5rc2.tar.gz
3)./configure –prefix=/usr/local/bind9 –with-dlz-mysql=/home/xxx/local/mysql –enable-threads=no && make && make install
4)数据库创建bind用户
登陆:mysql -uroot -p
创建数据库:create database bind;
创建两张表:

创建用户:CREATE USER ‘bind’@’%’ IDENTIFIED BY ‘123456’;
授权用户:grant all privileges on bind.* to ‘bind’@’%’ identified by ‘123456’;
插入测试数据:

5)编辑/usr/local/bind9/etc/named.conf

编辑named.conf
只保留key “rndc-key” {…},其余删除
在key “rndc-key” {…}后插入如下配置:

6)创建cnc.cl和cnet.cl配置
cnc.cl文件内容:

7)启动和测试
启动方法:/usr/local/bind9/sbin/named -gc /usr/local/bind9/etc/named.conf
测试方法:修改本机/etc/resolv.conf 中的 nameserver 127.0.0.1
测试方法:ping www.aaa.com 看ip是否是192.168.199.2

8)配置xxx 20台服务器ip和域名到智能DNS的关联Mysql表中(录入电信和联通数据表中)
9)修改20台服务器的/etc/resolv.conf的nameserver