第12周作业
1、通过ansible Roles编排实现 httpd 角色的部署
#创建相关角色目录
[root@centos8 ~]#mkdir -pv /data/ansible/roles/httpd/{tasks,handlers,files}
#创建相关角色文件
[root@centos8 ~]#cd /data/scripts/ansible/roles/httpd/
#main.yml 是task的入口文件
[root@centos8 ~]#vi tasks/main.yml
- include: service.yml
- include: group.yml
- include: user.yml
- include: install.yml
- include: config.yml
- include: index.yml
- include: service.yml
[root@centos8 httpd]#vi tasks/group.yml
- name: create apache group
group: name=apache system=yes gid=80
[root@centos8 httpd]#vi tasks/user.yml
- name: create apache user
user: name=apache system=yes shell=/sbin/nologin home=/var/www/ uid=80 group=apache
[root@centos8 httpd]#vi tasks/install.yml
- name: install httpd package
yum: name=httpd
[root@centos8 httpd]#vi tasks/config.yml
- name: config file
copy: src=httpd.conf dest=/etc/httpd/conf/ backup=yes
notify: restart
[root@centos8 httpd]#vi tasks/index.yml
- name: index.html
copy: src=index.html dest=/var/www/html/
[root@centos8 httpd]#cat tasks/service.yml
- name: start service
service: name=httpd state=started enabled=yes
[root@centos8 httpd]#cat handlers/main.yml
- name: restart
service: name=httpd state=restarted
#在files目录下准备两个文件
[root@centos8 httpd]#ls files/
httpd.conf index.html
[root@centos8 ~]#tree /data/scripts/ansible/roles/httpd
/data/scripts/ansible/roles/httpd
├── files
│ ├── httpd.conf
│ └── index.html
├── handlers
│ └── main.yml
└── tasks
├── config.yml
├── group.yml
├── index.yml
├── install_httpd.yml
├── install.yml
├── main.yml
├── service.yml
└── user.yml
3 directories, 11 files
#在playbook中调用角色
[root@centos8 ~]#vi /data/scripts/ansible/role_httpd.yml
---
#httpd role
- hosts: webservers
remote_user: root
roles:
- httpd
#运行playbook
ansible-playbook role_httpd.yml
2、简述 MySQL 数据库访问的执行过程。
连接层---SQL层---存储引擎层
用户通过TCP/IP或者socket请求连接mysql,经过连接层判断连接合法性,分配连接相应线程;
SQL层经过,语句、语义、语法、SQL类型、权限等判断;
查询缓存查找,找到则直接返回给用户数据;
如果缓存未找到,将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 个