zoukankan      html  css  js  c++  java
  • 第十二周作业

    1、通过ansible Roles编排实现 httpd 角色的部署

    答:

    •  创建roles所需目录,结构如下
    [root@centos8 ~]#tree -L 2 /data/roles
    /data/roles
    └── httpd
        ├── files
        ├── handlers
        ├── tasks
        ├── templates
        └── vars
    
    6 directories, 0 files
    [root@centos8 ~]#
    • 编写tasks目录下的yml文件
    [root@centos8 tasks]#tree 
    .
    ├── config.yml
    ├── index.yml
    ├── install.yml
    ├── main.yml
    ├── service.yml
    └── user.yml
    
    0 directories, 6 files
    #main.yml
    [root@centos8 tasks]#vim main.yml
    - include: user.yml - include: install.yml - include: config.yml - include: index.yml - include: service.yml
    #user.yml
    [root@centos8 tasks]#vim user.yml
    - name: create user user: name=apache system=yes shell=/sbin/nologin home=/var/www
    #install.yml
    [root@centos8 tasks]#vim install.yml 
    
    - name: install httpd                                                                                                                                                     
    yum: name=httpd
    #config.yml
    [root@centos8 tasks]#vim config.yml
    - name: config file centos6 copy: src=centos6/httpd.conf dest=/etc/httpd/conf/ backup=yes when: ansible_distribution_major_version == "6" notify: restart - name: config file centos7,8 copy: src=httpd.conf dest=/etc/httpd/conf/ backup=yes when: ansible_distribution_major_version != "6" notify: restart
    #index.yml
    [root@centos8 tasks]#vim index.yml
    - name: index.html copy: src=index.html dest=/var/www/html/
    #service.yml
    [root@centos8 tasks]#vim service.yml
    - name: start httpd service: name=httpd state=started
    • 准备好配置文件(centos6和centos7、8的配置文件是不同的)和网页文件index.html
    [root@centos8 httpd]#tree files/
    files/
    ├── centos6
    │   └── httpd.conf
    ├── httpd.conf
    └── index.html
    
    1 directory, 3 files
    [root@centos8 httpd]#
    • 编写handlers的yml文件
    [root@centos8 httpd]#vim handlers/main.yml 
    
    - name: restart                                                                                                                                                           
      service: name=httpd state=restarted
    • 在roles目录的同级目录下编写总的yml文件
    #role_httpd.yml
    [root@centos8 data]#vim role_httpd.yml
    --- - hosts: webservs roles: - httpd
    • 使用ansible进行部署
    [root@centos8 data]#ansible-playbook role_httpd.yml 
    
    PLAY [webservs] **********************************************************************************************************************************************************
    
    TASK [Gathering Facts] ***************************************************************************************************************************************************
    ok: [10.0.0.6]
    ok: [10.0.0.7]
    ok: [10.0.0.8]
    
    TASK [httpd : create user] ***********************************************************************************************************************************************
    changed: [10.0.0.7]
    changed: [10.0.0.6]
    changed: [10.0.0.8]
    
    TASK [install httpd] *****************************************************************************************************************************************************
    changed: [10.0.0.6]
    changed: [10.0.0.7]
    changed: [10.0.0.8]
    
    TASK [httpd : config file centos6] ***************************************************************************************************************************************
    skipping: [10.0.0.7]
    skipping: [10.0.0.8]
    ok: [10.0.0.6]  #这里应该是10.0.0.6上原本就有之前没删干净的配置文件,所以没复制
    
    TASK [httpd : config file centos7,8] *************************************************************************************************************************************
    skipping: [10.0.0.6]
    changed: [10.0.0.7]
    ok: [10.0.0.8]  #这里应该是10.0.0.8上原本就有之前没删干净的配置文件,所以就没有复制
    
    TASK [httpd : index.html] ************************************************************************************************************************************************
    changed: [10.0.0.6]
    changed: [10.0.0.7]
    changed: [10.0.0.8]
    
    TASK [start httpd] *******************************************************************************************************************************************************
    changed: [10.0.0.6]
    changed: [10.0.0.7]
    changed: [10.0.0.8]
    
    RUNNING HANDLER [httpd : restart] ****************************************************************************************************************************************
    changed: [10.0.0.7]
    
    PLAY RECAP ***************************************************************************************************************************************************************
    10.0.0.6                   : ok=6    changed=4    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
    10.0.0.7                   : ok=7    changed=6    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
    10.0.0.8                   : ok=6    changed=4    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
    
    [root@centos8 data]#curl 10.0.0.7
    webpage base ansible
    [root@centos8 data]#curl 10.0.0.8
    webpage base ansible
    [root@centos8 data]#curl 10.0.0.6
    webpage base ansible

    2、简述 MySQL 数据库访问的执行过程。

     答:

    • 客户端连接MYSQL服务器
    • 选择MYSQL数据库
    • 执行SQL语句
     

    3、S E L E C T 语句的完整语法较复杂,但至少包括的部分是 ( B )

    A.仅 S E L E C T

    B.S E L E C T ,F R O M

    C.S E L E C T ,G R O U P

    D.S E L E C T ,I N T O

     

    4、一张表的主键个数为 ( C )

    A.至多 3 个   B.没有限制  C.至多 1 个  D.至多 2 个

  • 相关阅读:
    sql 随机获取100条数据
    NPOI导出信息
    JavaScript打印页面
    生僻字在页面上不显示(䶮)
    C# 下载文件并使用指定名称展示
    layui 表格列编辑获取编辑前的值然后重新赋值,并通过键盘控制编辑位置
    C# 网络图片转base64
    C# WebApi debug模式下编译没有问题,切换到release模式下编译就有异常,但是依旧能生成成功,再切回到debug模式也会报错,也可以生成成功
    HTTP/2
    Class的继承
  • 原文地址:https://www.cnblogs.com/jojohyj/p/13548908.html
Copyright © 2011-2022 走看看