建站服务器
centos7新功能
centos7 单用户模式
centos7里不再有0-6启动级别,而是4个target
graphical.target 多人模式,支持图形和命令行两种登录,对应之前的3,5级别
multi-user.target 多人模式,只支持命令行登录,对应之前的3级别
rescue.target 单人模式,对应之前的1级别
emergency.target 单人模式,不过系统进入后根目录是只读的
centos7采用的是grub2,和之前的方式有所不同
在对应的内核条目上,按下"e",会进入edit模式,搜寻ro那一行,以linux16开头的,按“end”键到最后,输入rd.break,再按ctrl x进入
进去后重新挂载 /sysroot/,增加写权限
mount -o remount,rw /sysroot/
切换到原始系统下
chroot /sysroot/
passwd
修改密码输入新密码
touch /.autorelabel //这句是为了selinux生效
退出单用户的方法是
先ctrl d 退出,然后reboot
1.3centos7救援模式
设置光驱启动
选择troubleshooting
选择rescure a centos system
选择continue
chroot /mnt/sysimage
passwd
1.4 设置ip
网卡名字不再是eth0、eth2
dhclient先自动获取ip
没有 ifconfig命令,要使用 ip add 查看ip
要想继续使用 ifconfig,需要安装 net-tools
yum install -y net-tools
编辑配置文件
vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
里面配置和centos6一样
1.5 设置主机名 && 设置命令自动补全
hostname 查看主机名
hostnamectl set-hostname test1
hostnamectl status //查看主机名状态
cat /etc/hostname //查看配置文件
centos7支持命令参数补全
安装 bash-completion
yum install -y bash-completion
source /etc/profile
1.6centos7服务相关
centos7 不再有chkconfig工具了,而是使用systemd
使某服务自启动 systemctl enable httpd.service
不自启动 systemctl disable httpd.service
查看服务状态 systemctl status httpd.service
查看所有服务 systemctl list-units –type=service
启动服务 systemctl start httpd.service
停止服务 systemctl stop httpd.service
重启服务 systemctl restart httpd.service
启动脚本路径 /usr/lib/systemd/system/
检查一个服务是否为开机启动 systemctl is-enabled httpd
1.7centos7 systemd-unit
systemd管理服务的机制的特点:
支持服务并列启动,不用顺序启动,从而开机时间缩短
支持自动检测服务依赖的服务
systemd 可以管理所有系统资源。不同的资源统称为 unit(单位)。
unit 一共分成12种类型
service unit:系统服务 target unit:多个 unit 构成的一个组
device unit:硬件设备 mount unit:文件系统的挂载点
automount unit:自动挂载点 path unit:文件或路径
scope unit:不是由 systemd 启动的外部进程
slice unit:进程组 snapshot unit:systemd 快照,可以切回某个快照
socket unit:进程间通信的 socket swap unit:swap 文件
timer unit:定时器
列出正在运行的 unit systemctl list-units
列出所有unit,包括没有找到配置文件的或者启动失败的
systemctl list-units –all
列出所有没有运行的 unit systemctl list-units –all –state=inactive
列出所有加载失败的 unit systemctl list-units –failed
列出所有正在运行的、类型为 service 的 unit
systemctl list-units –type=service
显示某个 unit 是否正在运行 systemctl is-active application.service
显示某个 unit 是否处于启动失败状态
systemctl is-failed application.service
显示某个 unit 服务是否建立了启动链接
systemctl is-enabled application.service
1.8centos7 systemd-target
target类似于centos6里面的启动级别,但target支持多个target同时启动。target其实是多个unit的组合,系统启动说白了就是启动多个unit,为了管理方便,就使用target来管理这些unit。
查看当前系统的所有 target
systemctl list-unit-files –type=target
查看一个 target 包含的所有 unit
systemctl list-dependencies multi-user.target
查看启动时的默认 target systemctl get-default
设置启动时的默认 target systemctl set-default multi-user.target
切换 target 时,默认不关闭前一个 target 启动的进程,
systemctl isolate 命令改变这种行为,关闭前一个 target 里面所有不属于后一个 target 的进程
systemctl isolate multi-user.target
1.9centos7 target关联unit
主配置文件 /etc/systemd/system.conf
开机会先加载/etc/systemd/system/default.target
所有的service和target在 /usr/lib/systemd/system/
ls -l /etc/systemd/system/defaut.target 是一个软连接
软连接到了/usr/lib/systemd/system/multi-user.target
它会加载/usr/lib/systemd/system/multi-user.target.wants下面的service
查看一个service属于哪个target,需要cat 具体的service文件
cat /usr/lib/systemd/system/sshd.service
看里面[install]部分
2.0centos7 继续使用centos6的iptables管理机制
centos7不再使用iptables,而是使用firewalld
若不想使用firewalld,继续使用iptables,可以停掉firewalld,并且安装iptables-services包
systemctl stop firewalld
systemctl disable firewalld
yum install -y iptables-services
systemctl enable iptables
systemctl start iptables
firewalld
的使用
centos6上使用的静态防火墙,规则保存在/etc/sysconfig/iptalbes, 更新规则,需要重新加载或者重启iptables服务,相当于是把之前的规则全部清空,再把配置文件里面的规则加载。
而centos7使用了动态防火墙,即firewalld,这种防火墙方案不再像之前,更改了规则不需要重新加载配置。
无论是firewalld还是之前的iptables服务,底层都是使用iptables工具来配置规则的。
fiewa
电脑中如何修改360浏览器划词默认使用的搜索引擎各大企业邮箱地址数据库链接异常-虚拟主机/数据库问题查询企业网站二级域名的方法“出售”域名被卖了!买家连同商标一起拿下代理服务器好还是云服务器好阿里云服务器怎么运行php云服务器里面可以做重定向吗