• RHCE之路从服务器,selinux


    第十一天

    从服务器

    在从服务器上安装bind

    [root@b ~]# systemctl stop firewalld.service
    [root@b ~]# setenforce 0
    [root@b ~]# mount /dev/sr0 /mnt
    mount: /mnt: WARNING: device write-protected, mounted read-only.
    [root@b ~]# yum install bind -y

    完全区域传送 ---复制整个区域文件

    主服务器配置

    [root@a ~]# vim /etc/named.conf

    1. options {
    2. listen-on port 53 { 192.168.10.129; };
    3. directory "/var/named";
    4. allow-query { any; };
    5. allow-transfer { 192.168.10.132; };
    6. };
    7. zone "baidu.com" IN {
    8. type master;
    9. file "named.baidu.com";
    10. };
    11. zone "qq.com" IN {
    12. type master;
    13. file "named.baidu.com";
    14. };
    15. zone "10.168.192.in-addr.arpa" IN {
    16. type master;
    17. file "named.baidu.com";
    18. };

    从服务器配置

    [root@b ~]# vim /etc/named.conf

    1. options {
    2. listen-on port 53 { 192.168.10.132; };
    3. directory "/var/named/slaves";
    4. };
    5. zone "baidu.com" IN {
    6. type slave;
    7. file "named.baidu.com";
    8. masters { 192.168.10.129; };
    9. };
    10. zone "qq.com" IN {
    11. type slave;
    12. file "named.qq.com";
    13. masters { 192.168.10.129; };
    14. };
    15. zone "10.168.192.in-addr.arpa" IN {
    16. type slave;
    17. file "named.192";
    18. masters { 192.168.10.129; };
    19. };

    从服务器配置好后,主服务器也要重启服务

    [root@a ~]# systemctl restart named

    [root@b ~]# systemctl restart named

    增量区域传送 --- 仅复制区域里变化的文件

    主服务器

    [root@a ~]# vim /var/named/named.baidu.com

    1. $TTL 1D
    2. @ IN SOA @ admin.admin.com. (
    3. 2022110401 --- 版本号+1
    4. 1M
    5. 1M
    6. 3H
    7. 1D )
    8. NS dns.baidu.com.
    9. NS dns.qq.com.
    10. NS slave.baidu.com. --- 添加从服务器信息
    11. NS slave.qq.com.
    12. dns A 192.168.10.129
    13. www A 192.168.10.100
    14. slave A 192.168.10.132
    15. 100 PTR www.baidu.com.
    16. 100 PTR www.qq.com.

     [root@a ~]# vim /var/named/named.192

    1. $TTL 1D
    2. @ IN SOA @ admin (
    3. 1M
    4. 1M
    5. 1M
    6. 3M
    7. 1M )
    8. IN NS dns.baidu.com.
    9. IN NS dns.qq.com.
    10. IN NS slave.qq.com.
    11. IN NS slave.baidu.com.
    12. 132 IN PTR slave.baidu.com.
    13. 132 IN PTR slave.qq.com.
    14. 129 IN PTR dns.baidu.com.
    15. 129 IN PTR dns.qq.com.
    16. 100 IN PTR www.baidu.com.

    配置好后,主从服务器重启服务

    DNS的转发服务

     

     selinux

    查看文件的安全上下文:

    [root@a ~]# ls -Z
        system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
    unconfined_u:object_r:admin_home_t:s0 Desktop
    unconfined_u:object_r:admin_home_t:s0 Documents
    unconfined_u:object_r:admin_home_t:s0 Downloads
        system_u:object_r:admin_home_t:s0 initial-setup-ks.cfg
    unconfined_u:object_r:admin_home_t:s0 Music
    unconfined_u:object_r:admin_home_t:s0 Pictures
    unconfined_u:object_r:admin_home_t:s0 Public
    unconfined_u:object_r:admin_home_t:s0 Templates
    unconfined_u:object_r:admin_home_t:s0 Videos

    安全上下文分为四个字段

    Identify:role:type: --- 最后一个字段是和MLS和MCS相关的东西,代表灵敏度,一般用s0、s1、s2来命名,数字代表灵敏 度的分级。数值越大、灵敏度越高

    更改标签 --- 临时生效

    [root@b ~]# ll    -Z    /var/www/html/index.html
    -rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 7 Nov  5 23:26 /var/www/html/index.html

    [root@b ~]# chcon    -t    httpd_sys_content_t /var/www/html/index.html


    [root@b ~]# ll    -Z    /var/www/html/index.html
    -rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 7 Nov  5 23:26 /var/www/html/index.html

    回滚 --- 将标签恢复到默认值

    [root@b ~]# restorecon /var/www/html/index.html


    [root@b ~]# ll -Z /var/www/html/index.html
    -rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 7 Nov  5 23:26 /var/www/html/index.html

    更改标签 --- 永久生效

    [root@b ~]# semanage fcontext -a -t httpd_sys_content_t /var/www/html/index.html

    在linux上配置邮件客户端

    [root@a ~]# yum install mailx -y

    [root@a ~]# vim /etc/mail.rc --- 在末尾添加

    set from= xxxxxx@xxx.com
    set smtp= smtp.xxx.com
    set smtp-auth-user= xxxxxx@xxx.com
    set smtp-auth-password= 邮箱的授权码
    set smtp-auth=login --- 默认login

    获得授权码的方式(QQ邮箱)https://jingyan.baidu.com/article/7e4409532c5d3e6ec0e2efb0.html

     如果空间不足就发邮件给邮箱的脚本

    [root@a ~]# vim a.sh

    1. mem=`df -h | grep -w / | tr -s " " | cut -d " " -f 4 |cut -c 1-2`
    2. if [ $mem -lt 13 ];then
    3. echo "空间不足" | mail -s "预警" xxxxx@xxxx.com
    4. else
    5. echo "$mem=空间大小"

    [root@a ~]# bash  a.sh

    空间如果小于13则发送内容为“空间不足”,主题为“预警”的邮件给邮箱

     

    VDO

     

    stratis管理文件分层存储

    # dnf install -y stratisd stratis-cli

    # systemctl enable --now stratisd.service
    # stratis pool create redhat /dev/nvme0n2
    # 池的名字---redhat      /dev/nvme0n2---池中加入的设备
    # stratis pool list
    # stratis pool add-data redhat /dev/nvme0n3 --- 池中添加另一个设备
    # stratis filesystem create redhat rhce --- 创建文件系统rhce
    # stratis filesystem list --- 查看文件系统
    # mkdir /mnt/stratis --- 创建挂载目录
    # mount /stratis/redhat/rhce /mnt/stratis
    # stratis filesystem create redhat rhce1 --- 一个池中可以构建多个文件系统
    # stratis filesystem list redhat
    # stratis filesystem snapshot redhat rhce snap01 --- 快照
    # stratis filesystem list

    挂载快照读取数据
    # mkdir /mnt/snap
    # mount /stratis/redhat/snap01 /mnt/snap/
    # stratis filesystem destroy redhat rhce1 --- 删除文件系统
    # stratis filesystem destroy redhat snap01
    注意:文件系统需要先卸载才能删除
    # umount /mnt/snap
    # stratis filesystem destroy redhat snap01
    删除池
    # umount /mnt/snap
    # stratis filesystem destroy redhat snap01
    # stratis filesystem destroy redhat rhce
    # stratis pool destroy redhat
  • 相关阅读:
    24 - 内存持续上升,我该如何排查问题?
    弘辽科技:淘宝14天降权会恢复吗?多久能恢复正常?
    GO语言基础
    浏览器自动化 - <iframe>标签下的自由切换
    初识springmvc
    亚商投资顾问 早餐FM/1027新航季国际客运航班量840班
    Axure RP暗黑色高保真中后台原型组件模板库及组件库素材
    Linux基本指令及其使用
    itss认证条件是什么?
    Golang | Leetcode Golang题解之第112题路径总和
  • 原文地址:https://blog.csdn.net/qq_39744805/article/details/127712361