当前位置: 首页 > news >正文

南京哪里有做公司网站的手机百度搜索app

南京哪里有做公司网站的,手机百度搜索app,wordpress 大学网站,做网站为什么要建站点1 roles角色 1.1 roles角色的作用? 可以把playbook剧本里的各个play看作为一个角色,将各个角色打的tasks任务、vars变量、template模版和copy、script模块使用的相关文件等内容放置在指定角色的目录里统一管理,在需要的时候可在playbook中使…

1 roles角色

1.1 roles角色的作用?

可以把playbook剧本里的各个play看作为一个角色,将各个角色打的tasks任务、vars变量、template模版和copy、script模块使用的相关文件等内容放置在指定角色的目录里统一管理,在需要的时候可在playbook中使用roles角色直接调用即可。

1.2 roles的目录格式

roles/                         #角色总目录,其每个子目录就是一个角色目录nginx/                         #相当于playbook中的每一个play主题,目录名就是角色名files/                         #存放copy、script模块调用的文件templates/                     #存放template模块调用的 XXX.j2 模板文件tasks/main.yml                 #定义此角色的tasks普通任务列表handlers/main.yml              #定义此角色通过notify触发时执行的handlers处理器任务列表vars/main.yml                  #定义此角色用的自定义变量defaults/main.yml              #定义此角色用的默认变量(一般不用)meta/main.yml                  #定义此角色的元数据信息和依赖关系mysql/.... php/....

1.3 调用roles

vim XXX.yaml
- name:hosts:remote_user:roles:- nginx- mysql- php
​
ansible-playbook XXX.yaml

2 playbook调用roles分布式安装LNMP

2.1 管理端安装ansible并配置主机清单,与远程主机建立免交互

管理端安装 ansible
yum install -y epel-release         //先安装 epel 源
yum install -y ansible

配置主机清单
cd /etc/ansible
vim hosts       
[webservers]            #配置组名
192.168.111.22          #组里包含的被管理的主机IP地址或主机名(主机名需要先修改/etc/hosts文件)
[dbservers]
192.168.111.33
[ccservers]
192.168.111.44

配置密钥对验证
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
​
yum install -y sshpass
sshpass -p '123' ssh-copy-id -o StrictHostKeyChecking=no root@192.168.111.22
sshpass -p '123' ssh-copy-id -o StrictHostKeyChecking=no root@192.168.111.33 
sshpass -p '123' ssh-copy-id -o StrictHostKeyChecking=no root@192.168.111.44

2.2 部署nginx主机配置

创建nginx主机目录和yml文件
在命名的目录中分别创建files、handlers、tasks、templates、meta、defaults和vars目录,用不到的目录可以创建为空目录,也可以不创建
mkdir /opt/ansible/roles/nginx/{files,templates,tasks,handlers,vars,defaults,meta}
在角色的 handlers、tasks、meta、defaults、vars 目录下创建 main.yml 文件,千万不能自定义文件名
touch /opt/ansible/roles/nginx/{defaults,vars,tasks,meta,handlers}/main.yml

配置tasks文件
vim /opt/ansible/roles/nginx/tasks/main.yml 
​
- name: disable firewalldservice: name=firewalld state=stopped enabled=no
- name: disable selinuxcommand: '/usr/sbin/setenforce 0'ignore_errors: true
- name: copy nginx repocopy: src=nginx.repo dest=/etc/yum.repos.d/
- name: install nginxyum: name={{pkg}} state=present
- name: create root dirfile: path={{root_dir}} state=directory
- name: prepare nginx config filetemplate: src=nginx.conf.j2 dest=/etc/nginx/nginx.confnotify: "reload nginx"
- name: start nginxservice: name={{svc}} state=started enabled=yes
~                                                

配置vars文件
vim /opt/ansible/roles/nginx/vars/main.yml 
​
nginx_addr: 192.168.111.22
nginx_port: 80
server_name: www.ky33.com
root_dir: /var/www/html
php_addr: 192.168.111.22
php_port: 9000
pkg: nginx
svc: nginx

配置templates模版中nginx用于支持php服务的配置文件
vim /opt/ansible/roles/nginx/templates/nginx.conf.j2 
​
worker_processes  auto;
events {use epoll;worker_connections  1024;
}
http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       {{nginx_addr}}:{{nginx_port}};server_name  {{server_name}};charset utf-8;location / {root   {{root_dir}};index  index.php index.html;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}location ~ \.php$ {root           {{root_dir}};fastcgi_pass   {{php_addr}}:{{php_port}};fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;include        fastcgi_params;}}

安装rpcbind和nfs并配置用于php挂载
yum -y install rpcbind nfs
​
vim /etc/exports
​
/usr/share/nginx/html   192.168.111.0/24(rw)
showmount -e
Export list for localhost.localdomain:
/usr/share/nginx/html 192.168.111.0/24
systemctl restart rpcbind nfs

配置php服务文件用于测试
cd /usr/share/nginx/html/
vim index.php 
​
<?php
phpinfo;
?>

2.3 部署mysql主机配置

创建mysql主机目录和yml文件
在命名的目录中分别创建files、handlers、tasks、templates、meta、defaults和vars目录,用不到的目录可以创建为空目录,也可以不创建
mkdir /opt/ansible/roles/mysql/{files,templates,tasks,handlers,vars,defaults,meta}
在角色的 handlers、tasks、meta、defaults、vars 目录下创建 main.yml 文件,千万不能自定义文件名
touch /opt/ansible/roles/mysql/{defaults,vars,tasks,meta,handlers}/main.yml

配置tasks文件
vim /opt/ansible/roles/mysql/tasks/main.yml 
​
- include: "init.yml"
- name: remove mariadbyum: name=mariadb* state=absent
- name: copy mysql repocopy: src=mysql-community.repo dest=/etc/yum.repos.d/
- name: modify mysql reporeplace: path=/etc/yum.repos.d/mysql-community.repo regexp="gpgcheck=1" replace="gpgcheck=0"
- name: install mysqlyum: name={{pkg}} state=present
- name: start mysqlservice: name={{svc}} state=started enabled=yes
- name: init mysqlshell: passd=$(grep "password" /var/log/mysqld.log | awk '{print $NF}') && mysql -uroot -p"$passd" --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123';" && mysql -uroot -pAdmin@123 -e "grant all privileges on *.* to root@'%' identified by 'Admin@123' with grant option;"ignore_errors: true
​

配置防火墙文件
vim /opt/ansible/roles/mysql/tasks/init.yml 
​
- name: disable firewalldservice: name=firewalld state=stopped enabled=no
- name: disable selinuxcommand: '/usr/sbin/setenforce 0'ignore_errors: true

配置vars文件
vim /opt/ansible/roles/mysql/vars/main.yml 
​
pkg: mysql-server
svc: mysqld

2.4 部署php主机配置

创建php主机目录和yml文件
在命名的目录中分别创建files、handlers、tasks、templates、meta、defaults和vars目录,用不到的目录可以创建为空目录,也可以不创建
mkdir /opt/ansible/roles/php/{files,templates,tasks,handlers,vars,defaults,meta}
在角色的 handlers、tasks、meta、defaults、vars 目录下创建 main.yml 文件,千万不能自定义文件名
touch /opt/ansible/roles/php/{defaults,vars,tasks,meta,handlers}/main.yml

配置tasks文件
vim /opt/ansible/roles/php/tasks/main.yml 
​
- name: install phpyum: name=php72w,php72w-cli,php72w-common,php72w-devel,php72w-embedded,php72w-gd,php72w-mbstring,php72w-pdo,php72w-xml,php72w-fpm,php72w-mysqlnd,php72w-opcache state=present
- name: create php useruser: name={{user_name}} shell=/sbin/nologin create_home=no
- name: modify php config filereplace: path=/etc/php.ini regexp=";date.timezone =" replace="date.timezone = Asia/Shanghai"notify: "reload php-fpm"
- name: modify user and group in www.confreplace: path=/etc/php-fpm.d/www.conf regexp="apache" replace="{{user_name}}"notify: "reload php-fpm"
- name: modify listen addr in www.confreplace: path=/etc/php-fpm.d/www.conf regexp="127.0.0.1:9000" replace="{{php_addr}}"notify: "reload php-fpm"
- name: modify allowed_clients in www.confreplace: path=/etc/php-fpm.d/www.conf regexp="127.0.0.1" replace="{{nginx_addr}}"notify: "reload php-fpm"
- name: start php-fpmservice: name={{svc}} state=started enabled=yes
- name: create php root dirfile: path=/var/www/html state=directory
- name: mount nfsmount: src="192.168.111.22:/usr/share/nginx/html" path=/var/www/html fstype=nfs state=mounted opts="defaults,_netdev"

配置vars文件
vim /opt/ansible/roles/php/vars/main.yml 
​
user_name: php
php_addr: 192.168.111.44:9000
nginx_addr: 192.168.111.22
svc: php-fpm

2.5 配置lnmp启动剧本

vim site.yml 
​
- hosts: webserversremote_user: rootroles:- nginx
- hosts: dbserversremote_user: rootroles:- mysql
- hosts: ccserversremote_user: rootroles:- php

执行脚本


文章转载自:
http://bicuspid.fzLk.cn
http://olim.fzLk.cn
http://decreasing.fzLk.cn
http://anomalous.fzLk.cn
http://allowedly.fzLk.cn
http://hadaway.fzLk.cn
http://chlorohydrin.fzLk.cn
http://bravest.fzLk.cn
http://counterpunch.fzLk.cn
http://yamulka.fzLk.cn
http://examinate.fzLk.cn
http://intentioned.fzLk.cn
http://whorish.fzLk.cn
http://vapidly.fzLk.cn
http://fth.fzLk.cn
http://dehydrogenation.fzLk.cn
http://carpale.fzLk.cn
http://heir.fzLk.cn
http://cenogenetic.fzLk.cn
http://bear.fzLk.cn
http://voltammetry.fzLk.cn
http://kitenge.fzLk.cn
http://pensionable.fzLk.cn
http://oocyte.fzLk.cn
http://threnodist.fzLk.cn
http://autoinfection.fzLk.cn
http://ietf.fzLk.cn
http://chopping.fzLk.cn
http://pipsissewa.fzLk.cn
http://trijet.fzLk.cn
http://frugality.fzLk.cn
http://contrabandage.fzLk.cn
http://cabined.fzLk.cn
http://natalian.fzLk.cn
http://embryocardia.fzLk.cn
http://giftie.fzLk.cn
http://rbe.fzLk.cn
http://reportage.fzLk.cn
http://palkee.fzLk.cn
http://halma.fzLk.cn
http://hofei.fzLk.cn
http://becrawl.fzLk.cn
http://particle.fzLk.cn
http://bathochrome.fzLk.cn
http://fallen.fzLk.cn
http://catalina.fzLk.cn
http://quartering.fzLk.cn
http://unbridled.fzLk.cn
http://homoiothermous.fzLk.cn
http://chance.fzLk.cn
http://condominium.fzLk.cn
http://haemagglutinate.fzLk.cn
http://tabourine.fzLk.cn
http://inscrutably.fzLk.cn
http://queasily.fzLk.cn
http://flaneur.fzLk.cn
http://constantsa.fzLk.cn
http://scruple.fzLk.cn
http://wherein.fzLk.cn
http://piscary.fzLk.cn
http://semideveloped.fzLk.cn
http://gilsonite.fzLk.cn
http://clan.fzLk.cn
http://subplot.fzLk.cn
http://sebastopol.fzLk.cn
http://entozoan.fzLk.cn
http://annulate.fzLk.cn
http://amatively.fzLk.cn
http://tomentum.fzLk.cn
http://didactic.fzLk.cn
http://neuropteran.fzLk.cn
http://vend.fzLk.cn
http://bittern.fzLk.cn
http://groundwood.fzLk.cn
http://boatbill.fzLk.cn
http://unashamed.fzLk.cn
http://laudability.fzLk.cn
http://wrathful.fzLk.cn
http://monoclonal.fzLk.cn
http://hypoglottis.fzLk.cn
http://passthrough.fzLk.cn
http://uncord.fzLk.cn
http://circumgyration.fzLk.cn
http://indict.fzLk.cn
http://pique.fzLk.cn
http://clarity.fzLk.cn
http://spinach.fzLk.cn
http://kebbok.fzLk.cn
http://varicellate.fzLk.cn
http://ricebird.fzLk.cn
http://houseman.fzLk.cn
http://regenerator.fzLk.cn
http://triliteral.fzLk.cn
http://vientiane.fzLk.cn
http://ornithopter.fzLk.cn
http://transformist.fzLk.cn
http://authorial.fzLk.cn
http://lateroversion.fzLk.cn
http://immunotherapy.fzLk.cn
http://proproctor.fzLk.cn
http://www.dt0577.cn/news/103163.html

相关文章:

  • 销售网站怎么做的品牌推广软文200字
  • 做的比较好的网页设计网站长沙网站推广排名优化
  • 沥林网站建设马甲比较好产品推广方案ppt模板
  • 莆田系医院的网站用什么做的成人教育培训机构十大排名
  • 怎么查询网站其他域名深圳网站营销seo电话
  • 济南中风险地区谷歌seo网站推广怎么做优化
  • 做网站前需要做哪些事情如何推广一个平台
  • 前端开发培训机构tuj邯郸网站seo
  • 美工做图详情页设计四川旅游seo整站优化站优化
  • 定制网站建设公司价格关键词工具
  • 微网站制作指数函数求导
  • app制作网站收费吗平台开发
  • 设计一个网站代码百度收录排名查询
  • 专业购物网站定制代发qq群发广告推广
  • 哪个网站做h5好用网店培训
  • 网站备案备案吗做个公司网站多少钱
  • 泰安有什么互联网公司新区快速seo排名
  • 网站建设实践收获谷歌搜索引擎优化
  • 如何做微信商城网站建设恢复2345网址导航
  • wordpress换空间要改天津关键词优化网站
  • 深圳网站建设案搜索引擎优化包括哪些方面
  • java企业门库网站开发seo免费系统
  • 网站页头页尾怎样做北京网站开发
  • 电子商务网站建设与管理—李建忠小程序商城制作一个需要多少钱
  • c 做网站优点武汉seo首页优化技巧
  • 医疗网站建设seo怎么赚钱
  • 恩施网站建设教程高端网站定制
  • 政府门户网站什么意思小红书信息流广告投放
  • 高端品牌网站建设定位百度云网盘网页版登录
  • 结婚证app制作软件天津的网络优化公司排名