一、iSCSI存储搭建
存储架构概述
- DAS(直连式存储)
- NAS(网络附加存储)
- SAN(存储区域网络)
- IP SAN:使用iSCSI协议
- FC SAN:使用光纤网络
iSCSI服务端配置
- 创建分区:使用
fdisk
或parted
命令。 - 安装iSCSI服务:
yum install targetcli -y
- 启动并设置iSCSI服务自动启动:
systemctl start target
与systemctl enable target
- 配置防火墙允许TCP端口3260:
firewall-cmd --permanent --add-port=3260/tcp
- 使用
targetcli
配置iSCSI存储:- 创建后备存储:
/backstores/block create server0 /dev/sdb1
- 创建iSCSI目标:
/iscsi create iqn号
- 关联LUN和iSCSI目标:
/iscsi/iqn号/tpg1/luns create /backstores/block/server0
- 创建端口:
/iscsi/iqn号/tpg1/portals create 192.168.10.1 3260
- 设置访问控制列表:
/iscsi/iqn号/tpg1/acls create +客户端的iqn号
- 保存配置并退出:
saveconfig
与exit
- 创建后备存储:
iSCSI客户端配置
- 安装iSCSI客户端工具:
yum install iscsi-initiator-utils -y
- 配置iSCSI初始化器名称:
/etc/iscsi/initiatorname.iscsi
- 重启iSCSI服务:
systemctl restart iscsi
- 使用
iscsiadm
发现并登录iSCSI目标:- 发现目标:
iscsiadm --mode discoverydb --type sendtargets --portal 192.168.16.147 --discover
- 登录设备:
iscsiadm --mode node --targetname iqn.1994-05.com.redhat:99fff0992692 --portal 192.168.16.147:3260 --login
- 发现目标:
iSCSI设备使用
- 将iSCSI设备分区并格式化:例如
/dev/sdb1
格式化为ext4
- 挂载设备:
mount /dev/sdb1 /mnt/iscsi
- 自动挂载:编辑
/etc/fstab
添加相应条目
二、HTTP服务搭建
HTTP服务端配置
- 安装HTTP服务:
yum install httpd httpd-manual -y
- 启动并设置HTTP服务自动启动:
systemctl start httpd
与systemctl enable httpd
- 配置防火墙允许HTTP服务:
firewall-cmd --permanent --add-service=http
- 编辑HTTP配置文件:
/etc/httpd/conf/httpd.conf
- 设置网站根目录:
/var/www/html/
- 创建并编辑网页文件:
vim /var/www/html/index.html
- 重启HTTP服务以应用更改:
systemctl restart httpd
虚拟主机配置
- 创建虚拟目录:
mkdir /var/www/virtual
- 编辑虚拟主机配置文件:
/etc/httpd/conf.d/vhost.conf
- 配置虚拟主机:
<VirtualHost *:80> ServerName server.example.com DocumentRoot /var/www/html </VirtualHost> <VirtualHost *:80> ServerName desktop.example.com DocumentRoot /var/www/virtual </VirtualHost>
- 重启HTTP服务以应用更改:
systemctl restart httpd
客户端配置
- 配置本地DNS解析或
/etc/hosts
文件:192.168.16.147 server.example.com 192.168.16.147 desktop.example.com
- 在Windows客户端,编辑
C:\Windows\System32\drivers\etc\hosts
文件。