设为首页 收藏本站
查看: 513|回复: 0

[经验分享] CentOS项目实例之四

[复制链接]

尚未签到

发表于 2018-11-22 09:31:04 | 显示全部楼层 |阅读模式
1. ZZSRV1上的WWW配置
1.1. 磁盘配置
1.1.1. 添加磁盘
添加80GB的磁盘。
# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00012974
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    41943039    20458496   8e  Linux LVM
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-root: 18.8 GB, 18798870528 bytes, 36716544 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes  
没有找到新的磁盘,可以用一下命令刷新
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan
# echo "- - -" > /sys/class/scsi_host/host2/scan
# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00012974
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    41943039    20458496   8e  Linux LVM
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-root: 18.8 GB, 18798870528 bytes, 36716544 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 85.9 GB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
可以看到/dev/sdb  

1.1.2. LVM配置
# fdisk  /dev/sdb
创建一个分区
# fdisk -l /dev/sdb
Disk /dev/sdb: 85.9 GB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x558160b8
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   167772159    83885056   8e  Linux LVM
创建PV
# pvscan
  PV /dev/sda2   VG centos   lvm2 [19.51 GiB / 0    free]
  Total: 1 [19.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 0 [0   ]
# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
# pvscan
PV /dev/sda2   VG centos          lvm2 [19.51 GiB / 0    free]
PV /dev/sdb1                      lvm2 [80.00 GiB]
Total: 2 [99.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 1 [80.00 GiB]
创建VG
# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "centos" using metadata type lvm2
# vgcreate DATAVG /dev/sdb1
  Volume group "DATAVG" successfully created
# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "DATAVG" using metadata type lvm2
  Found volume group "centos" using metadata type lvm2
# vgdisplay DATAVG
  --- Volume group ---
  VG Name               DATAVG
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479  记下此数字
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / 80.00 GiB
  VG UUID               Ff09cK-hwD0-hQMJ-hZX0-O9ju-ZaxL-0M6jCp
创建一个LV,使用VG的全部PE
# lvscan
  ACTIVE            '/dev/centos/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/centos/root' [17.51 GiB] inherit
LV的名称为LV1,使用全部空间
# lvcreate -n LV1 -l 20479 DATAVG
  Logical volume "LV1" created
# lvscan
  ACTIVE            '/dev/DATAVG/LV1' [80.00 GiB] inherit
  ACTIVE            '/dev/centos/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/centos/root' [17.51 GiB] inherit
# lvdisplay /dev/DATAVG/LV1
  --- Logical volume ---
  LV Path                /dev/DATAVG/LV1
  LV Name                LV1
  VG Name                DATAVG
  LV UUID                ru2n62-DgpE-B7Wx-cRgc-xu57-0hgu-ztezb2
  LV Write Access        read/write
  LV Creation host, time zzsrv1.bigcloud.local, 2014-08-11 14:37:08 +0800
  LV Status              available
  # open                 0
  LV Size                80.00 GiB
  Current LE             20479
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2
# vgdisplay DATAVG
  --- Volume group ---
  VG Name               DATAVG
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       20479 / 80.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               Ff09cK-hwD0-hQMJ-hZX0-O9ju-ZaxL-0M6jCp1.1.3. 文件系统配置
# mkfs.ext4 /dev/DATAVG/LV1
创建mount点,设置为自动mount
# mkdir /wwwroot
# vi /etc/fstab
添加如下内容
/dev/DATAVG/LV1        /wwwroot    ext4    defaults      0 0
# mount /wwwroot/
# mount
会看到如下内容
/dev/mapper/DATAVG-LV1 on /wwwroot type ext4 (rw,relatime,data=ordered)  
1.2. 安装
# yum -y install httpd
安装httpd会自动安装依赖包:
apr
apr-util
httpd-tools
mailcap
# rpm -qi httpd
Name        : httpd
Version     : 2.4.6
Release     : 18.el7.centos
Architecture: x86_64
Install Date: Mon 11 Aug 2014 02:44:55 PM CST
Group       : System Environment/Daemons
Size        : 9793373
License     : ASL 2.0
Signature   : RSA/SHA256, Wed 23 Jul 2014 11:21:22 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM  : httpd-2.4.6-18.el7.centos.src.rpm
Build Date  : Wed 23 Jul 2014 10:49:10 PM CST
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem
Vendor      : CentOS
URL         : http://httpd.apache.org/
Summary     : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible web server.1.3. 配置
1.3.1. 默认配置
# rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
# cd /etc/httpd/conf
# ls
httpd.conf  magic
# cp httpd.conf httpd.conf.origin
# more httpd.conf查看配置文件,我们注意到以一配置:
DocumentRoot "/var/www/html"


特别是要注意这个配置
  
      AllowOverride none
      Require all denied
  
这是Apache 2.4的一个新的默认值,拒绝所有的请求!
设置为自动启动
# systemctl enable httpd.service
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'  
在Windows计算机上使用浏览器访问http://192.168.188.11/,成功
  

1.3.2. 生产WEB站点配置
创建两个网站的目录结构及测试用页面文件
# mkdir /wwwroot/www
# echo "www.bigcloud.local" > /wwwroot/www/index.html
# mkdir /wwwroot/crm
# echo "crm.bigcloud.local" > /wwwroot/crm/index.html
配置虚拟机主机
# cd /etc/httpd/
# mkdir vhost-conf.d
# echo "Include vhost-conf.d/*.conf" >> conf/httpd.conf
# vi /etc/httpd/vhost-conf.d/vhost-name.conf  添加如下内容
  
     ServerName www.bigcloud.local
     DocumentRoot /wwwroot/www/
  
  
      Require all granted
  
  

  
     ServerName crm.bigcloud.local
     DocumentRoot /wwwroot/crm/
  
  
     Require ip 192.168.188.0/24
  
  

Apache在系统日志的信息很少,我们经常需要对其自有日志进行分析。
  # tail -f /var/log/httpd/error_log
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-638043-1-1.html 上篇帖子: apache日志分析(python) 下篇帖子: Apache+Tomcat+Session+Memcache 高性能群集搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表