Ansible分离部署LAMP架构

总结:绘上一张Kakfa架构思维大纲脑图(xmind)

image

其实关于Kafka,能问的问题实在是太多了,扒了几天,最终筛选出44问:基础篇17问、进阶篇15问、高级篇12问,个个直戳痛点,不知道如果你不着急看答案,又能答出几个呢?

若是对Kafka的知识还回忆不起来,不妨先看我手绘的知识总结脑图(xmind不能上传,文章里用的是图片版)进行整体架构的梳理

梳理了知识,刷完了面试,如若你还想进一步的深入学习解读kafka以及源码,那么接下来的这份《手写“kafka”》将会是个不错的选择。

  • Kafka入门

  • 为什么选择Kafka

  • Kafka的安装、管理和配置

  • Kafka的集群

  • 第一个Kafka程序

  • Kafka的生产者

  • Kafka的消费者

  • 深入理解Kafka

  • 可靠的数据传递

  • Spring和Kafka的整合

  • SpringBoot和Kafka的整合

  • Kafka实战之削峰填谷

  • 数据管道和流式处理(了解即可)

image

image

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

root@192.168.129.133’s password:

Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘root@192.168.129.133’”

and check to make sure that only the key(s) you wanted were added.

[root@master ~]# ssh-agent bash

[root@master ~]# ssh-add

Enter passphrase for /root/.ssh/id_rsa:

Identity added: /root/.ssh/id_rsa (root@master)

192.168.129.133安装httpd


[root@master ~]# ansible httpd -m yum -a ‘name=httpd* state=installed’

192.168.129.133 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: true,

“msg”: “”,

“rc”: 0,

“results”: [

“Installed: mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64”,

“Installed: cyrus-sasl-devel-2.1.27-1.el8.x86_64”,

“Installed: expat-devel-2.2.5-3.el8.x86_64”,

“Installed: apr-1.6.3-11.el8.x86_64”,

“Installed: apr-devel-1.6.3-11.el8.x86_64”,

“Installed: libdb-devel-5.3.28-40.el8.x86_64”,

“Installed: apr-util-1.6.1-6.el8.x86_64”,

“Installed: httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64”,

“Installed: apr-util-bdb-1.6.1-6.el8.x86_64”,

“Installed: openldap-devel-2.4.46-11.el8.x86_64”,

“Installed: apr-util-devel-1.6.1-6.el8.x86_64”,

“Installed: httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64”,

“Installed: apr-util-openssl-1.6.1-6.el8.x86_64”,

“Installed: centos-logos-httpd-85.8-1.el8.noarch”,

“Installed: httpd-devel-2.4.37-39.module_el8.4.0+778+c970deab.x86_64”,

“Installed: httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch”,

“Installed: httpd-manual-2.4.37-39.module_el8.4.0+778+c970deab.noarch”

]

}

//开启服务与开机自启

[root@master ~]# ansible httpd -m service -a “name=httpd state=started enabled=yes”

192.168.129.133 | SUCCESS => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: false,

“enabled”: true,

“name”: “httpd”,

“state”: “started”,

“status”: {

“ActiveEnterTimestamp”: “Mon 2021-07-19 19:12:12 CST”,

“ActiveEnterTimestampMonotonic”: “1076238167”,

“ActiveExitTimestampMonotonic”: “0”,

……略

192.168.129.135安装mariadb


[root@master ~]# ansible mysql -m yum -a ‘name=mariadb state=present’

192.168.129.135 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: true,

“msg”: “”,

“rc”: 0,

“results”: [

“Installed: mariadb-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64”,

“Installed: mariadb-common-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64”,

“Installed: mariadb-connector-c-3.0.7-1.el8.x86_64”,

“Installed: mariadb-connector-c-config-3.0.7-1.el8.noarch”

]

}

//安装mariadb-server

[root@master ~]# ansible mysql -m yum -a ‘name=mariadb-server state=present’

192.168.129.135 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: true,

“msg”: “”,

“rc”: 0,

“results”: [

“Installed: mariadb-errmsg-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64”,

“Installed: mariadb-gssapi-server-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64”,

“Installed: mariadb-server-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64”,

“Installed: mariadb-server-utils-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64”,

“Installed: perl-DBD-MySQL-4.046-3.module+el8.1.0+2938+301254e2.x86_64”,

“Installed: mariadb-backup-3:10.3.17-1.module+el8.1.0+3974+90eded84.x86_64”

]

}

//开启服务于开机自启

[root@master ~]# ansible mysql -m service -a ‘name=mariadb state=started enabled=yes’

192.168.129.135 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: true,

“enabled”: true,

“name”: “mariadb”,

“state”: “started”,

“status”: {

“ActiveEnterTimestampMonotonic”: “0”,

“ActiveExitTimestampMonotonic”: “0”,

……略

192.168129.137安装php


[root@master ~]# ansible php -m yum -a ‘name=php state=present’

192.168.129.137 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: true,

“msg”: “”,

“rc”: 0,

“results”: [

“Installed: apr-util-bdb-1.6.1-6.el8.x86_64”,

“Installed: httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64”,

“Installed: apr-util-openssl-1.6.1-6.el8.x86_64”,

“Installed: centos-logos-httpd-85.8-1.el8.noarch”,

“Installed: httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch”,

“Installed: httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64”,

“Installed: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch”,

“Installed: php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64”,

“Installed: php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64”,

“Installed: php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64”,

“Installed: mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64”,

“Installed: php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64”,

“Installed: apr-1.6.3-11.el8.x86_64”,

“Installed: apr-util-1.6.1-6.el8.x86_64”

]

}

//安装php相关组件

[root@master ~]# ansible php -m yum -a ‘name=php-* state=present’

192.168.129.137 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: true,

“msg”: “”,

“rc”: 0,

……略

修改apache的配置


[root@master ~]# ansible httpd -m lineinfile -a ‘path=/etc/httpd/conf/httpd.conf line=“<VirtualHost :80>\nDocumentRoot “/var/www/html/www1”\nServerName www.192.168.129.133.com\nProxyRequests off\nProxyPassMatch ^/(..php)$ fcgi://192.168.129.137:9000/var/www/html/www1/$1\n<Directory “/var/www/html/www1”>\nOptions None\nAllowOverride None\nOrder allow,deny\nAllow from all\n\n”’

192.168.129.133 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“backup”: “”,

“changed”: true,

“msg”: “line added”

}

//在http主机上查看

[root@httpd conf]# cat /etc/httpd/conf/httpd.conf

<VirtualHost *:80>

DocumentRoot “/var/www/html/www1”

ServerName www.192.168.129.133

ProxyRequests Off

ProxyPassMatch ^/(.*.php)$ fcgi://192.168.129.137:9000/var/www/html/www1$1

<Directory “/var/www/html/www1”>

Options none

AllowOverride none

Require all granted

[root@master ~]# ansible httpd -m lineinfile -a ‘path=/etc/httpd/conf/httpd.conf regexp=“^AddType " insertafter=”^AddType application/x-" line=“AddType application/x-httpd-php .php”’

192.168.129.133 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“backup”: “”,

“changed”: true,

“msg”: “line added”

}

[root@master ~]# ansible httpd -m lineinfile -a ‘path=/etc/httpd/conf/httpd.conf regexp=“^AddType " insertafter=”^AddType application/x-" line=“AddType application/x-httpd-php-source .phps”’

192.168.129.133 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“backup”: “”,

“changed”: true,

“msg”: “line replaced”

}

[root@master ~]# ansible httpd -m lineinfile -a ‘path=/etc/httpd/conf/httpd.conf regexp=“^DirectoryIndex” line=“DirectoryIndex index.html index.php”’

192.168.129.133 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“backup”: “”,

“changed”: true,

“msg”: “line added”

}

[root@httpd]# vi /etc/httpd/conf/httpd.conf

probably should define those extensions to indicate media types:

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php-source .phps

AddType application/x-httpd-php .php

Proxyrequests Off

ProxyPassMatch ^/(.*.php)$ fcgi://192.168.129.137:9000/var/www/html/$1

//重启服务

[root@master ~]# ansible httpd -m service -a ‘name=httpd state=restarted’

192.168.129.133 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“changed”: true,

“name”: “httpd”,

“state”: “started”,

“status”: {

……略

修改php的配置文件


[root@master ~]# ansible php -a ‘mkdir /var/www/html/’

192.168.129.137 | CHANGED | rc=0 >>

[root@master ~]# ansible php -m lineinfile -a “path=/var/www/html/index.php line=<?php\n phpinfo();\n?> create=yes”

[root@master ~]# ansible php -m lineinfile -a ‘path=/etc/php-fpm.d/www.conf regexp=“^listen =” line=“listen = 192.168.129.137:9000”’

192.168.129.137 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“backup”: “”,

“changed”: true,

“msg”: “line replaced”

}

[root@master ~]# ansible php -m lineinfile -a ‘path=/etc/php-fpm.d/www.conf regexp=“^listen.allowed_clients =” line=“listen.allowed_clients = 192.168.129.133”’

192.168.129.137 | CHANGED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“backup”: “”,

“changed”: true,

“msg”: “line replaced”

最后

由于篇幅限制,小编在此截出几张知识讲解的图解

P8级大佬整理在Github上45K+star手册,吃透消化,面试跳槽不心慌

P8级大佬整理在Github上45K+star手册,吃透消化,面试跳槽不心慌

P8级大佬整理在Github上45K+star手册,吃透消化,面试跳槽不心慌

P8级大佬整理在Github上45K+star手册,吃透消化,面试跳槽不心慌

P8级大佬整理在Github上45K+star手册,吃透消化,面试跳槽不心慌

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

GED => {

“ansible_facts”: {

“discovered_interpreter_python”: “/usr/libexec/platform-python”

},

“backup”: “”,

“changed”: true,

“msg”: “line replaced”

最后

由于篇幅限制,小编在此截出几张知识讲解的图解

[外链图片转存中…(img-pbr1hewc-1715810334591)]

[外链图片转存中…(img-XfTiXTv4-1715810334592)]

[外链图片转存中…(img-BdYtLAJu-1715810334592)]

[外链图片转存中…(img-bwH5oipf-1715810334592)]

[外链图片转存中…(img-Mz5t6lHE-1715810334593)]

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

需要这份系统化的资料的朋友,可以点击这里获取

  • 14
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
继“Java开发微信朋友圈PC版系统-架构1.0”之后,debug这段时间日撸夜撸,终于赶在春节放假前给诸位带来了这一系统的架构2.0版本,特此分享给诸位进行学习,以掌握、巩固更多的技术栈以及项目和产品开发经验,同时也为即将到来的金三银四跳槽季做准备! 言归正传,下面仍然以问答的方式介绍下本门课程的相关内容! (1)问题一:这是一门什么样的课程? 很明显,本门课程是建立在架构1.0,即 第1门课程 的基础上发布的,包含了架构1.0的内容,即它仍然是一门项目、产品实战课,基于Spring Boot2.X + 分布式中间件开发的一款类似“新浪微博”、“QQ空间”、“微信朋友圈”PC版的互联网社交软件,包含完整的门户网前端 以及 后台系统管理端,可以说是一套相当完整的系统! (2)问题二:架构2.0融入了哪些新技术以及各自有什么作用? 本课程对应着系统架构2.0,即第2阶段,主要目标:基于架构1.0,优化系统的整体性能,实现一个真正的互联网社交产品;其中,可以学习到的技术干货非常多,包括:系统架构设计、Spring Boot2.X、缓存Redis、多线程并发编程、消息中间件RabbitMQ、全文搜索引擎Elastic Search、前后端消息实时通知WebSocket、分布式任务调度中间件Elastic Job、Http Restful编程、Http通信OKHttp3、分布式全局唯一ID、雪花算法SnowFlake、注册中心ZooKeeper、Shiro+Redis 集群Session共享、敏感词自动过滤、Java8 等等; A.  基于Elastic Search实现首页列表数据的初始化加载、首页全文检索;B.  基于缓存Redis缓存首页朋友圈“是否已点赞、收藏、关注、评论、转发”等统计数据;整合Shiro实现集群部署模式下Session共享;C.  多线程并发编程并发处理系统产生的废弃图片、文件数据;D.  基于Elastic Job切片作业调度分布式多线程清理系统产生的废弃图片;E.  基于RabbitMQ解耦同步调用的服务模块,实现服务模块之间异步通信;F.  基于WebSocket实现系统后端 与 首页前端 当前登录用户实时消息通知;G.  基于OKHttp3、Restful风格的Rest API实现ES文档、分词数据存储与检索;H.  分布式全局唯一ID 雪花算法SnowFlake实现朋友圈图片的唯一命名;I.  ZooKeeper充当Elastic Job创建的系统作业的注册中心;J.  为塑造一个健康的网络环境,对用户发的朋友圈、评论、回复内容进行敏感词过滤;K.  大量优雅的Java8  Lambda编程、Stream编程;  (3)问题三:系统运行起来有效果图看吗?
使用Ansible分离部署LNMP可以让你更轻松地管理和部署LNMP服务器。以下是一些基本步骤: 1. 安装Ansible 2. 创建Ansible inventory文件,包含LNMP服务器的IP地址。 3. 创建Ansible playbook文件,指定要安装的软件包。 4. 在Ansible playbook文件中定义任务,例如安装Nginx、MySQL和PHP。 5. 运行Ansible playbook文件,Ansible将自动在LNMP服务器上安装和配置软件。 下面是一个可能的示例Ansible playbook文件: ``` --- - hosts: lnmp_servers become: true vars: nginx_version: 1.18.0 mysql_version: 5.7 php_version: 7.4 tasks: - name: Install Nginx yum: name: nginx-{{ nginx_version }} state: present - name: Start Nginx service: name: nginx state: started - name: Install MySQL yum: name: mysql-server-{{ mysql_version }} state: present - name: Start MySQL service: name: mysqld state: started - name: Install PHP yum: name: php-{{ php_version }} php-fpm-{{ php_version }} state: present - name: Start PHP-FPM service: name: php-fpm state: started ``` 在这个示例中,我们假设我们有一个名为"lnmp_servers"的Ansible组,其中包含我们要部署LNMP的服务器的IP地址。此外,我们定义了要安装的软件包的版本号,并在任务中安装和启动Nginx、MySQL和PHP。 运行Ansible playbook文件的命令是: ``` ansible-playbook -i inventory_file playbook_file.yml ``` 其中,inventory_file是你的Ansible inventory文件的路径,playbook_file.yml是你的Ansible playbook文件的路径。 这就是使用Ansible分离部署LNMP的基本步骤。你可以根据你的具体需求进行修改和定制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值