Centos8搭建Mini Server笔记

系统安全设置

配置防火墙

service firewalld start #重启防火墙

firewall-cmd --list-all #查看防火墙规则

firewall-cmd --permanent --add-port=80/tcp #开放80端口,HTTP

firewall-cmd --permanent --add-port=67/udp #开放67端口,DHCP
firewall-cmd --permanent --add-protocol=igmp #支持IGMP协议,路由发现协议
firewall-cmd --reload #重启防火墙

还有另一种方法,设置service,service列表在/usr/lib/firewalld/services目录中

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=samba
firewall-cmd --permanent --add-service=hdcp
firewall-cmd --permanent --add-service=llmnr

修改防火墙配置文件 /etc/firewalld/zones/public.xml



  Public
  For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
  
  
  
  
  
  
  
  
  
  
  
  

禁止root远程ssh登陆

修改/etc/ssh/sshd_config文件,将其中的PermitRootLogin改成no,

然后重新启动ssh服务/bin/systemctl restart sshd.service

系统设置

挂载的数据硬盘设置自动休眠

  • hdparm -B 127 /dev/sdb1
  • hdparm -S 60 /dev/sdb1

挂载的数据硬盘设置自动休眠(二)

在crontab中添加定时任务,每隔15分钟,关闭磁盘

*/15 * * * * (sdparm --command=stop /dev/sdc >> /tmp/sdparm.log)

设置 supervisord 开机启动

systemctl enable supervisord.service

设置用户 i 可以无密码获得sudo权限

添加 i ALL=(ALL) NOPASSWD: ALL 到 /etc/sudoers

centos 配置无线网卡

参考 https://www.cnblogs.com/asker009/p/10212045.html

安装配置rsyslog

  • sudo yum install rsyslog

查看CPU温度、硬盘温度

  • yum install lm_sensors hddtemp
  • sensors
  • hddtemp /dev/sdb

更新系统时间

yum install -y ntpdate

ntpdate ntp1.aliyun.com

hwclock --systohc

可选的时间服务器 www.pool.ntp.org/zone/cn

cn.ntp.org.cn #中国
edu.ntp.org.cn #中国教育网
ntp1.aliyun.com #阿里云
ntp2.aliyun.com #阿里云
cn.pool.ntp.org #最常用的国内NTP服务器

优化

创建swap文件

sudo -i
dd if=/dev/zero of=/opt/swapfile bs=1024 count=4194304
chown root:root /opt/swapfile
chmod 0600 swapfile
mkswap /opt/swapfile
swapon /opt/swapfile
echo "/opt/swapfile   none  swap  sw    0 0" >> /etc/fstab
swapon -s

卸载订阅管理器 rhsmcertd服务

rhsmcertd服务,即Red Hat Subscription Manager CERTification Daemon

systemctl stop rhsmcertd.service # 停止订阅服务
systemctl disable rhsmcertd.service # 取消订阅服务开机启动
yum remove subscription-manager

问题汇总

USB安装centos8,无法正常启动安装程序

解决方法: 刻录时,把UltraISO的写入方式改为为RAW

Linux wget遭遇证书不可信(Wget error: ERROR: The certificate of is not trusted.)

解决方法:
安装ca-certificates,并同步系统时间为最新。

  • yum install -y ca-certificates
  • ntpdate -u 0.north-america.pool.ntp.org

Error "curl: (60) Peer certificate cannot be authenticated with known CA certificates"

同上一个问题的解决方法

无法 mount ntfs磁盘

  • yum install epel-release
  • yum install ntfs-3g

umount: /mnt: target is busy.

  • 执行sync把buffer的数据写入磁盘
  • ls /mnt 查看占用/mnt的进程,并kill掉
  • 重新执行 umount /mnt

根目录变为只读,只能root登陆

重新挂载根目录, mount -o remount, rw /
一般为/etc/fstab 配置错误导致。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注