1、通过ansible Roles编排实现 httpd 角色的部署
准备:编写主机清单,ssh连接测试,ssh通过密钥登录
ansible appsrvs -m ping 测试success
read -p "请输入ssh连接的网段(如:10.0.0): " net
read -p "请输入连接的IP地址开始数: " sta
read -p "请输入连接的IP地址截止数: " end
read -p "请输入连接主机的pw: " password
rm -f /root/.ssh/*
ssh-keygen -P "" -f /root/.ssh/id_rsa &> /dev/null
rpm -q sshpass &> /dev/null || yum -y install sshpass &> /dev/null
for((i="$sta";i<="$end";i++))
do
ping -c1 -w1 $net.$sta &> /dev/null
if [ $? -eq 0 ];then
sshpass -p $password ssh-copy-id -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa.pub root@$net.$sta &> /dev/null
echo "$net.$sta已连接"
fi
let sta=$sta+1
done
wait
1.mkdir -pv /data/ansible/roles/httpd/{tasks,handlers,files}
2.cd roles/httpd/tasks/
3.vim tasks/main.yml
- include: group.yml
- include: user.yml
- include: install.yml
- include: config.yml
- include: index.yml
- include: service.yml
4.vim tasks/group.yml
- name: create group
group: name=apache system=yes
5.vim tasks/user.yml
- name: create user
user: name=apache system=yes shell=/sbin/nologin home=/var/www/ group=apache
6.vim install.yml
- name: install httpd
yum: name=httpd
7.vim config.yml
- name: config file
copy: src=httpd.conf dest=/etc/httpd/conf/ backup=yes
notify: restart
8.vim index.yml
- name: index.html
copy: src=index.html dest=/var/www/html
9.vim service.yml
- name: start
service: name=httpd state=started enabled=yes
10.[root@centos8 httpd]#cd files/
[root@centos8 files]#echo 123 > index.html
拷贝安装好httpd的机器的一份配置文件
11.[root@centos8 ansible]#ls
role_http.yml roles
vim role_http.yml
---
- hosts: appsrvs
remote_user: root
roles:
- httpd
12.ansible-playbook -C role_http.yml
最后,ansible-playbook role_http.yml
2、简述 MySQL 数据库访问的执行过程。
端口:3306,两种登录方式,本地socket连接,通过ip+端口连接,收到连接请求,将请求转发到连接线程模块,同股票用户模块来进行授权,通过授权后,从线程连接池中取出空闲的被缓存的连接线程和客户端请求对接,如果失败则创建一个新的连接请求.
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 个