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

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

    设置SSH免密码登陆
    v
    im ansible_ssh.sh
    #!/bin/bash
    [ -f ~/.ssh/id_rsa ] || ssh-keygen -f ~/.ssh/id_rsa -P "" -q
    rpm -q sshpass &> /dev/null || yum -y install sshpass &> /dev/null
    prefix=10.0.0.
    passwd=tianze


    for i in {12..13};do
    {
        sshpass -p $passwd ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa root@$prefix$i &> /dev/null
    }&
    done
    wait

    bash ansible_ssh.sh
    安装ansible
    yum -y install ansible  ##事先需要配置好epel源  
    vim /etc/ansible/hosts  ##文件末尾添加以下内容 主机清单
    [webservers]  ##主机组
    10.0.0.8

    10.0.0.18

    创建角色相关的目录: 

    mkdir -pv 、/data/ansible/roles/httpd/{tasks,handlers,files}

    创建角色相关的文件:

    cd /data/ansible/roles/httpd/

    main.yml是task的入口文件

    [root@centos8-1 httpd]$vim tasks/main.yml
    - include: group.yml
    - include: user.yml
    - include: install.yml
    - include: config.yml
    - include: index.yml
    - include: service.ym

    [root@centos8-1 httpd]$vim tasks/group.yml
    - name:create group
    group: name=apache system=yes gid=80

    [root@centos8-1 httpd]$vim tasks/user.yml

    - name: create apache user
    user: name=apache system=yes shell=/sbin/nologin home=/var/www/ uid=80 group=apache

    [root@centos8-1 httpd]$vim tasks/install.yml

    - name: install httpd package
    yum: name=httpd

    [root@centos8-1 httpd]$vim tasks/config.yml

    - name: config file
    copy: src=httpd.conf dest=/etc/httpd/conf/ backup=yes
    notify: restart

    root@centos8-1 httpd]$vim tasks/index.yml

    - name: index.html
    copy: src=index.html dest=/var/www/html/

    [root@centos8-1 httpd]$vim tasks/service.yml

    - name: start service
    service: name=httpd state=started enabled=yes

    [root@centos8-1 httpd]$vim handlers/main.yml

    - name: restart
    service: name=httpd state=restarted

    在files目录下准备两个文件(可也用yum -y install httpd安装后把文件copy到files目录下)

    [root@centos8-1 ansible]$ls files/
    httpd.conf index.html

    yum -y install httpd

    [root@centos8-1 ansible]$cp /etc/httpd/conf/httpd.conf /roles/httpd/files/

    [root@centos8-1 ansible]$echo The is httpd based roles > /roles/httpd/files/index.html

    [root@centos8-1 ansible]$tree /data/ansible/roles/httpd/
    /data/ansible/roles/httpd/
    ├── files
    │   ├── httpd.conf
    │   └── index.html
    ├── handlers
    │   └── main.yml
    └── tasks
    ├── config.yml
    ├── group.yml
    ├── index.yml
    ├── install.yml
    ├── main.yml
    ├── service.yml
    └── user.yml

    3 directories, 10 files

    在playbook中调用角色

    [root@centos8-1 ansible]$vim /data/ansible/role_httpd.yml

    ---
    - hosts: db
    remote_user: root

    roles:
    - httpd

    运行playbook

    [root@centos8-1 ansible]$ansible-playbook /data/ansible/role_httpd.yml


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

    • 客户端发送一条查询给服务器;
    • 服务器先检查查询缓存,如果命中了缓存,则立刻返回存储在缓存中的结果。否则进入下一阶段。
    • 服务器段进行SQL解析、预处理,在优化器生成对应的执行计划;
    • mysql根据优化器生成的执行计划,调用存储引擎的API来执行查询。
    • 将结果返回给客户端。


    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 个

    把生命浪费在美好的事物上
  • 相关阅读:
    ASP.NET编程的十大技巧
    C#学习心得(转)
    POJ 1177 Picture (线段树)
    POJ 3067 Japan (树状数组)
    POJ 2828 Buy Tickets (线段树)
    POJ 1195 Mobile phones (二维树状数组)
    HDU 4235 Flowers (线段树)
    POJ 2886 Who Gets the Most Candies? (线段树)
    POJ 2418 Cows (树状数组)
    HDU 4339 Query (线段树)
  • 原文地址:https://www.cnblogs.com/tz66/p/13512537.html
Copyright © 2011-2022 走看看