添加磁盘
在一台新的服务器上,设置环境,配置yum源,安装httpd服务,添加对应防火墙端口,给硬盘分区666MB格式化,挂载到/homework下,永久生效:
思路
1.检查环境
2.配置置yum源
4.安装服务
5.添加防火墙
6.添加硬盘
7.分区格式化
8.挂载
过程:
1.检查环境
getenforce setenforce 0
#开机关闭selinux
A: vi /etc/selinux/config ###SELINUX=disabled B: echo -e "SELINUX=disabled\nSELINUXTYPE=targedited" > /etc/selinux/config C: cat > /etc/selinux/config << QQQ > SELINUX=disabled > SELINUXTYPE=targeted > QQQ
#查看防火墙状态(因为默认开启,所以可以省略这一步)
systemctl status firewalld systemctl enable firewalld systemctl restart firewalld
2.配置IP
ip a
A: vi /etc/sysconfig/network-scripts/ifcfg-ens33 ################ NAME=ens33 DEVICE=ens33 ONBOOT=yes BOOTPROTO=none IPADDR=192.168.59.103 NETMASK=255.255.255.0 GATEWAY=192.168.59.2 DNS1=192.168.59.2 ################## Systemctl restart network B: echo "NAME=ens33 DEVICE=ens33 ONBOOT=yes BOOTPROTO=none IPADDR=192.168.59.103 NATEMASK=255.255.255.0 GATEWAY=192.168.59.2 DNS1=192.168.59.2" > /etc/sysconfig/network-scripts/ifcfg-ens33 systemctl restart network
3.配置yum源
mkdir /iso mount /dev/cdrom /iso A: vim /etc/fstab ################## /dev/sr0 /iso iso9660 defaults 0 0 ################## B: Echo "/dev/sr0 /iso iso9660 defaults 0 0" >> /etc/fstab mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak A: vim /etc/yum.repos.d/iso.repo ################## [iso] Name=iso Baseurl=file:///iso Disable=1 Gpgcheck=0 ################## B:cat>/etc/yum.repos.d/iso.repo <<QQQ [iso] Name=iso Baseurl=file:///iso Disable=1 Gpgcheck=0 QQQ C: echo -e "[iso]\nname=iso\baseurl=file:///iso\nenable=1\ngpgcheck=0 " > /etc/yum.repos.d/iso.repo
4.安装服务
yum -y install httpd vim net-tools rm -rf /etc/httpd/conf.d/welcome.conf curl www.baidu.com > /var/www/html/index.html vim /var/www/html/index.html(修改主页) systemcul start httpd systemcul enable httpd
5.添加防火墙
systemcul status firewalld A: firewall-cmd --add-service=http firewall-cmd --add-service=http --permanent B: firewall-cmd --add-port=80/tcp firewall-cmd --add-port=80/tcp --permanent firewall-cmd --reload
6.添加硬盘
A: echo "- - -" > /sys/class/scsi_host/host0/scan echo "- - -" > /sys/class/scsi_host/host1/scan echo "- - -" > /sys/class/scsi_host/host2/scan B: echo "scsi add-single-device 0 0 2 0" > /proc/scsi/scsi echo "scsi add-single-device 0 0 3 0" > /proc/scsi/scsi echo "scsi add-single-device 0 0 4 0" > /proc/scsi/scsi
7.分区格式化
fdisk /dev/sdb <<QQQ 空格(表示的是Enter键) n 空格(表示的是Enter键) 空格(表示的是Enter键) 空格(表示的是Enter键) +666M 空格(表示的是Enter键) w QQQ mkfs.xfs /dev/sdb1
8.挂载
mkdir /work mount /dev/sdb1 /work echo "/dev/sdb1 /work xfs defaults 0 0" >> /etc/fstab
作者:无荨
-------------------------------------------
个性签名:学IT,就要做到‘活到老学到老’!
如果觉得这篇文章对你有小小的帮助的话,别忘记点个“推荐”哦!