1、通过ansible Roles编排实现 httpd 角色的部署
1. 创建role相关目录
[11:29:41 root@Anabile-1 /data/ansible]#mkdir -pv roles/httpd/{files,tasks,handlers,templates,vars}
mkdir: created directory 'roles'
mkdir: created directory 'roles/httpd'
mkdir: created directory 'roles/httpd/files'
mkdir: created directory 'roles/httpd/tasks'
mkdir: created directory 'roles/httpd/handlers'
mkdir: created directory 'roles/httpd/templates'
mkdir: created directory 'roles/httpd/vars'
[11:29:52 root@Anabile-1 /data/ansible]#tree
.
└── roles
└── httpd
├── files
├── handlers
├── tasks
├── templates
└── vars
[11:31:25 root@Anabile-1 /data/ansible/roles/httpd]#vim tasks/main.yml
- include: group.yml
- include: user.yml
- include: install.yml
- include: config.yml
- include: index.yml
- include: service.yml
[11:34:49 root@Anabile-1 /data/ansible/roles/httpd]#vim tasks/group.yml
- name: create apache user
user: name=apache system=yes shell=/sbin/nologin home=/var/www uid=88 group=apache
[11:34:55 root@Anabile-1 /data/ansible/roles/httpd]#vim tasks/install.yml
- name: install httpd pachage
yum: name=httpd
[11:35:42 root@Anabile-1 /data/ansible/roles/httpd]#vim tasks/config.yml
- name: config file
copy: src=httpd.conf dest=/etc/httpd/conf backup=yes
notify: restart
[11:38:11 root@Anabile-1 /data/ansible/roles/httpd]#vim tasks/index.yml
- name: index.html
copy: src=index.html dest=/var/www/html
[11:38:39 root@Anabile-1 /data/ansible/roles/httpd]#vim tasks/service.yml
- name: start service
service: name=httpd state=started enabled=yes
[11:40:06 root@Anabile-1 /data/ansible/roles/httpd]#vim handlers/main.yml
- name: restart
service: name=httpd state=restarted
3. 准备httpd.conf 和 index.tml文件, 存放在files目录下
4. 在剧本中调用角色
[11:42:05 root@Anabile-1 /data/ansible]#vim role_httpd.yml
---
#httpd role
- hosts: websrvs
remote_user: root
roles:
- httpd
5. 运行剧本
[11:42:56 root@Anabile-1 /data/ansible]#ansible-playbook role_httpd.yml
2、简述 MySQL 数据库访问的执行过程
MySQL的访问控制由两个功能模块共同组成, 一个是用户管理模块, 负责检查用户是否可以登录到mysql, 另一个是访问控制模块,用来管理用户在登录到数据库后可以进行的操作
1. 客户端发起登录请求, 提供用户名,密码,主机信息
2. 用户管理模块查询mysql.user表,验证用户信息, 如果验证通过, 则用户成功登录进数据库, 否则连接拒绝
3. 登录成功后, 用户执行命令, 访问控制模块解析命令所需权限, 查找grant表相关授权信息, 如果匹配成功则将命令发往后端执行,然后将结果返还用户. 如果匹配时报,则请求被拒绝
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 个