一、项目需求:
Tarena公司,已经购买域名tarena.com。目前想实现以下服务
官网服务:www.tarena.com
邮件服务:mail.tarena.com
文件服务:ftp.tarena.com
二、项目规划:
1、设备及网络选型:
设备选型:四台Dell R710服务器,一台思科WS-2960S-24TS-S交换机,一台思科2951路由器
网络选型:由于公司业务为职业教育培训,其主要潜在目标群为大学生,所以需要要教育网访问。 而且考虑到服务器严重故障时可以第一时间派工程师到现场抢修。所以建议使用北京机房的全线BGP。
机柜报价 |
北京地区 |
北京周边地区 |
4500-6000元/个/月 |
3000-3500元/个/月 |
|
带宽报价 |
||
全线BGP |
350-500元/M/月 |
250-400元/M/月 |
双线BGP |
250-400元/M/月 |
200-300元/M/月 |
单线 |
130-250元/M/月 |
130-150元/M/月 |
2、网络拓扑:
3、机架摆放:
4、ip地址、主机名规划:
主机名 |
IP地址 |
安装系统 |
moni01.tarena.com |
192.168.1.253/24 |
CentOS 5.10 x86_64 |
web01.tarena.com |
192.168.1.11/24 |
|
web02.tarena.com |
192.168.1.12/24 |
|
mail01.tarena.com |
192.168.1.251/24 |
5、系统版本、分区规划:
系统版本:CentOS 5.10
分区规划:300G
moni01.tarena.com
分区 |
大小 |
挂载点 |
/dev/sda1 |
200M |
/boot |
/dev/sda2 |
200G |
/ |
/dev/sda3 |
8192M |
swap |
/dev/vg_data/lv_data(/dev/sda5) |
6G |
/data |
web01-02.tarena.com/ mail01.tarena.com
分区 |
大小 |
挂载点 |
/dev/sda1 |
200M |
/boot |
/dev/sda2 |
200G |
/ |
/dev/sda3 |
8192M |
swap |
/dev/sda5 |
剩余可用空间 |
/data |
6、账户规划:
账户 |
UID |
GID |
宿主目录 |
sw |
801 |
800 |
/home/sw |
qihaipeng |
802 |
800 |
/home/qihapeng |
wangdejing |
803 |
800 |
/home/wangdejing |
web |
10001 |
10000 |
/home/web |
mailadmin |
10002 |
10000 |
/home/mail |
dev |
10003 |
10000 |
/home/dev |
7、服务规划:
主机名 |
搭建服务 |
moni01.tarena.com(跳板机) |
dns:为整个项目提供dns解析,作为主dns |
ntp:作为时间服务器,为整个网络主机同步时间 | |
ftp:提供yum源和公共下载,允许运维将新网站内容传到moni1上 | |
web01.tarena.com |
http:共同提供公司静态网站服务 |
web02.tarena.com |
|
mail01.tarena.com |
mail:提供mail 服务,允许公司人员通过web收发邮件 |
nfs:提供公共区域共享,作为web服务器的网站根目录 | |
dns:提供备用dns服务 |
8、其他:
YUM规划:源位置moni1.tarena.com /data/ftp/iso/{RedHat,CentOS}/5.10
Cron:每天7:00自动同步ntp时间,3:00备份web服务器网站,备份文件名webdb-yyyymmdd.tgz
所有服务器默认服务器级别,服务自启动,禁止直接ssh root登录
三、项目实施:
1、基础环境:以moni01.tarena.com为例,其他主机配置类似
1.1分区(仅在moni01上分逻辑卷,其他服务器分区安装系统时已经分好):
[[email protected]locahost ~]#fdisk /dev/sda
[[email protected]locahost ~]#vgcreate vg_data /dev/sda5
[[email protected]locahost ~]#lvcreate -L 6G -n lv_data vg_data
[[email protected]locahost ~]#mkdir /data
[[email protected]locahost ~]#vim /etc/fstab
8 /dev/vg_data/lv_data /data ext3 defaults 0 0
[[email protected]locahost ~]#mount /data
1.2.ip,网关,主机名,dns地址,yum源地址,hosts:
[[email protected]locahost ~]#vim /etc/sysconfig/network-scripts/ifcfg-eth0
[[email protected]localhost ~]#vim /etc/sysconfig/network
[[email protected]localhost ~]#hostname moni01.tarena.com
[[email protected] ~]#vim /etc/resolv.conf
[[email protected] ~]#vim /etc/hosts
[[email protected] ~]#mkdir /data/ftp
[[email protected] ~]#cp -rp /misc/cd/* /data/ftp/iso/CentOs/5.10
[[email protected] ~]#vim /etc/yum.repos.d/rh5.repo(从模板复制)
1 [rhel-yum] 2 name=CentOS-5 3 baseurl=file:///data/ftp/iso/CentOs/5.10/Server 4 gpgcheck=1 5 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 6 enabled=1
1.3.建立帐号(建一个为例)
[[email protected] ~]#groupadd -g 800 yunwei
[[email protected] ~]#useradd -u 801 -g 800 sw
[[email protected] ~]#echo “******”|passwd sw --stdin
1.4.修改ssh配置文件不允许root登录
[[email protected] ~]#vim /etc/ssh/sshd.conf
42 PermitRootLogin no
service sshd restart
chkconfig sshd on
1.5.修改开机级别,禁用组合键重启
[[email protected] ~]#vim /etc/inittab
27 id:3:initdefault: 34 #exec /sbin/shutdown -r now "Control-Alt-Delete pressed"
2.服务平台搭建:
2.1.moni01服务器配置
2.1.a.安装服务,开机自起 (其他服务器类似,下面开启服务和自启命令省略)
[sw@moni01 ~]$su -
[[email protected] ~]# yum -y install bind-chroot bind caching-nameserver vsftpd ntp
[[email protected] ~]# service named start
[[email protected]1 ~]# service ntpd start
[[email protected] ~]# service vsftpd start
[[email protected] ~]# chkconfig named on
[[email protected] ~]# chkconfig ntpd on
[[email protected] ~]# chkconfig vsftpd on
2.1.b.配置,重启
[[email protected] ~]#cd /var/named/chroot/etc //配置主DNS
[[email protected]moni01 etc]# cp -p named.caching-nameserver.conf named.conf
[[email protected]moni01 etc]# cp -p named.rfc1912.zones named.rfc1912.zones.bak
[[email protected]moni01 etc]# vim named.conf
... 15 listen-on port 53 { 192.168.1.253; }; ... 27 allow-query { any; }; 28 allow-query-cache { any; }; 29allow-transfer { 192.168.1.251; }; ... 37 match-clients { any; }; 38 match-destinations { any; }; 40 include "/etc/named.rfc1912.zones"; [[email protected] etc]# vim named.rfc1912.zones ... 51 zone "tarena.com" IN { 52 type master; 53 file "tarena.com.zone"; 54 };
[[email protected]moni01 etc]# cd /var/named/chroot/var/named/
[[email protected]moni01 named]# cp -p named.local tarena.com.zone
[[email protected]moni01 named]# vim tarena.com.zone
1 $TTL 86400 2 @ IN SOA localhost. root.localhost. ( 3 2014062801 ; Serial 4 28800 ; Refresh 5 14400 ; Retry 6 3600000 ; Expire 7 86400 ) ; Minimum 8 IN NS moni01.tarena.com. 9 IN NS mail01.tarena.com. 10 IN MX mail01.tarena.com. 11 www IN A 192.168.1.11 12 www IN A 192.168.1.12 13 mail01 IN A 192.168.1.251 14 @ IN A 192.168.1.253 15 moni01 IN A 192.168.1.253 16 web01 IN A 192.168.1.11 17 mail IN CNAME mail01 18 web02 IN A 192.168.1.12 19 ftp IN A 192.168.1.253
[[email protected]moni01 ~]# service named restart
[[email protected]moni01 ~]# vim /etc/ntp.conf //配置NTP
... 10 restrict 192.168.1.0 mask 255.255.255.0 nomodify ... 27 server 127.127.1.0 ...
[[email protected]moni01 ~]# service ntpd restart
[[email protected]moni01 ~]# cp /etc/vsftpd/{vsftpd.conf,vsftpd.conf.bak} //配置FTP服务
[[email protected]moni01 ~]# vim /etc/vsftpd/vsftpd.conf
... 12 anonymous_enable=YES ... 121 chroot_local_user=yes 122 local_root=/data/ftp 123 userlist_deny=NO 124 max_clients=20 125 max_per_ip=2
[[email protected]moni01 ~]# vim /etc/vsftpd/user_list
16 sw 17 qihaipeng 18 wangdejing 19 web 20 dev 21 ftp 22 anonymous
[[email protected]moni01 ~]# service vsftpd restart
[[email protected]moni01 ~]# setfacl -m g:800:rwx /data/ftp
[[email protected]moni01 ~]# setfacl -m g:1000:rwx /data/ftp
2.2.web服务器配置(web01、02配置相同,只以web01为例)
2.2.a.安装服务,开机自起
[sw@web01 ~]$su -
[[email protected]web01 ~]#yum -y install httpd ntp portmap nfs-utils
[[email protected]web01 ~]# chkconfig ntpd off
2.2.b.配置,重启服务
[[email protected] ~]#cp /etc/httpd/conf/{httpd.conf,http.conf.bak} //配置http服务
[[email protected] ~]#vim /etc/httpd/conf/httpd.conf
... 74 KeepAlive on 265 ServerName www.tarena.com:80 ...
[[email protected] ~]#service httpd restart
[[email protected] ~]#vim /etc/fstab //挂载远程web内容
192.168.1.251:/web /var/www/html nfs default 0 0
[[email protected] ~]#mount /var/www/html
[root@web01 ~]# crontab -e //时间同步计划任务
* 7 * * * ntpdate 192.168.1.253
[root@web01 ~]# service crond restart
2.3.mail01服务器配置
2.3.a.安装服务,开机自起
[sw@mail01 ~]$su -
[[email protected] ~]#yum -y install postfix bind-chroot bind caching-nameserver \
ntp portmap nfs-utils squirrelmail dvecot cyrus-sasl
[root@mail01 ~]# chkconfig ntpd off
[root@mail01 ~]# chkconfig crond on
2.3.b配置,重启服务
[[email protected]mail01 ~]#mkdir -p 755 /web //配置nfs共享
[[email protected]mail01 ~]#setfacl -m g:800:rwx /web
[[email protected]mail01 ~]#setfacl -m g:1000:rwx /web
[[email protected]mail01 ~]#vim /etc/exports
/web 192.168.1.*(ro)
[root@mail01 ~]# service portmap restart
[root@mail01 ~]#service nfs restart
[root@mail01 ~]# mkdir /bak //配置计划任务
[root@mail01 ~]# crontab -e
* 7 * * * ntpdate 192.168.1.253 * 3 * * * tar -zcf /bak/webdb-$(date-\\%Y\\%m\\%d).tgz /web
[root@mail01 ~]# service crond restart
[[email protected]01 ~]# netstat -anptul | grep :25 //配置邮件服务
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 4653/master
[[email protected]01 ~]# cd /etc/postfix/
[[email protected]01 postfix]# postconf -n > mail.txt
[[email protected]01 postfix]# cp main.cf main.cf.bak
[[email protected]01 postfix]# mv mail.txt main.cf
[[email protected]01 ~]# cp /usr/lib64/sasl2/smtp.conf /etc/sasl2/smtpd.conf
[[email protected]01 ~]# service saslauthd restart
[[email protected]01 postfix]# vim main.cf
... 8 #inet_interfaces = localhost 20 myhostname = mail01.tarena.com 21 mydomain = tarena.com 22 myorigin = $mydomain 23 mydestination = $mydomain 24 home_mailbox = Maildir/ 25 mynetworks = 127.0.0.1 26 smtpd_sasl_auth_enable = yes 27 smtpd_sasl_security_options = noanonymous 28 smtpd_recipient_restrictions = 29 permit_mynetworks,permit_sasl_authenticated, 31 reject_unauth_destination
[[email protected]01 ~]# service postfix restart
[[email protected]01 ~]# vim /etc/squirrelmail/config.php
... 26 $squirrelmail_default_language = ‘zh_CN‘; 28 $domain = ‘tarena.com‘; 29 $imapServerAddress = ‘192.168.1.251‘; ... 32 $smtpServerAddress = ‘192.168.1.251‘; ...
[[email protected]01 ~]# service httpd restart
[[email protected]01 ~]# cd /var/named/chroot/etc //配置从dns
[[email protected]01 etc]# cp -p named.caching-nameserver.conf named.conf
[[email protected]01 etc]# cp -p named.rfc1912.zones named.rfc1912.zones.bak
[[email protected]01 etc]# vim named.conf
15 listen-on port 53 { 192.168.1.251; }; ... 27 allow-query { any; }; 28 allow-query-cache { any; }; 29 allow-transfer { none; }; ... 37 match-clients { any; }; 38 match-destinations { any; }; 40 include "/etc/named.rfc1912.zones";
[[email protected] etc]# vim named.rfc1912.zones
... 51 zone "tarena.com" IN { 52 type slave; 53 file "slaves/tarena.com.zone"; 54 masters { 192.168.1.253; }; 55 };
[[email protected]01 ~]# service named restart
本实验设计还有哪些不完善?
1、数据挂载点要另外一块硬盘,home目录单独分区方便备份
2、在跳板机上要进行帐号审核,存放到日志文件中并备份, 开发等帐号可临时开通,降低操作风险和入侵风险
3、防火墙访问控制
4、ssh普通用户登录后可用sudo命令来临时以root身份执行命令
5、重复配置服务器时,相同操作可以编写脚本实现
6、每个服务器都存放用户,会加大风险
Tarena公司网站项目实施方案,布布扣,bubuko.com