ansible分布式部署lamp架构

ansible分离部署lamp架构

lamp分离部署

1、安装环境:

系统 IP地址 安装服务 主机名
控制节点 ContOS 8.2 192.168.56.129 ansible control
受控主机 ContOS 8.2 192.168.56.130 apache server1
受控主机 ContOS 8.2 192.168.56.131 php server2
受控主机 ContOS 8.2 192.168.56.132 mysql server3

在这之前每台机器要配置好网络仓库或者本地仓库

2、在control上编写清单文件

[root@control ~]# cd  /etc/ansible/
[root@control ansible]# vim  ta 
[server1]
192.168.56.130  ansible_user=root  ansible_password=1

[server2]
192.168.56.131  ansible_user=root  ansible_password=1
[server3]
192.168.56.132  ansible_user=root  ansible_password=1

查看是否ping同:

[root@control ansible]# ansible all -m ping
192.168.56.130 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.56.131 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.56.132 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "ping": "pong"
}

3、在server1、2、2上安装python

[root@control ansible]# ansible all -m yum -a 'name=python38 state=latest'
192.168.56.130 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "msg": "",
    "rc": 0,
    "results": [
        "Installed: python38-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64",
        "Installed: python38-setuptools-41.6.0-4.module+el8.2.0+5978+503155c0.noarch",
        "Installed: python38-pip-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch"
    ]
}
192.168.56.131 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "msg": "",
    "rc": 0,
    "results": [
        "Installed: python38-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64",
        "Installed: python38-setuptools-41.6.0-4.module+el8.2.0+5978+503155c0.noarch",
        "Installed: python38-pip-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch"
    ]
}
192.168.56.132 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "msg": "",
    "rc": 0,
    "results": [
        "Installed: python38-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64",
        "Installed: python38-setuptools-41.6.0-4.module+el8.2.0+5978+503155c0.noarch",
        "Installed: python38-pip-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch",
        "Installed: python38-libs-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64",
        "Removed: python38-libs-3.8.6-3.module_el8.4.0+665+abc3a503.x86_64"
    ]
}

4、在server1、2、2上关闭防火墙

//暂停防火墙
[root@control ansible]# ansible all -m service -a 'name=firewalld state=stopped'
192.168.56.131 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "name": "firewalld",
    "state": "stopped",
    "status": {
        "ActiveEnterTimestamp": "Mon 2021-07-19 16:52:40 CST",
        "ActiveEnterTimestampMonotonic": "4669816",
        "ActiveExitTimestamp": "Mon 2021-07-19 20:47:26 CST",
        "ActiveExitTimestampMonotonic": "14090605593",
        "ActiveState": "inactive",
        "After": "system.slice polkit.service dbus.socket sysinit.target dbus.service basic.target",
        "AllowIsolate": "no",
        "AllowedCPUs": "",
        "AllowedMemoryNodes": "",
        "AmbientCapabilities": "",
        "AssertResult": "yes",
        "AssertTimestamp": "Mon 2021-07-19 16:52:39 CST",
        "AssertTimestampMonotonic": "4084673",
        "Before": "shutdown.target network-pre.target multi-user.target",
        "BlockIOAccounting": "no",
        "BlockIOWeight": "[not set]",
        "BusName": "org.fedoraproject.FirewallD1",
        "CPUAccounting": "no",
        "CPUAffinity": "",
        "CPUQuotaPerSecUSec": "infinity",
        "CPUSchedulingPolicy": "0",
        "CPUSchedulingPriority": "0",
        "CPUSchedulingResetOnFork": "no",
        "CPUShares": "[not set]",
        "CPUUsageNSec": "[not set]",
        "CPUWeight": "[not set]",
        "CacheDirectoryMode": "0755",
        "CanIsolate": "no",
        "CanReload": "yes",
        "CanStart": "yes",
        "CanStop": "yes",
        
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ceph是一个可靠的、数据自动重均衡、自动恢复的SDS(软件定义存储)分布式存储系统,功能主要有三大块:块存储、对象存储、文件系统。Ceph不但是提供了统一存储,并且同时还充分利用了客户端的计算能力,在存储每一个数据时,都会通过计算得出该数据存储的位置,尽量将数据分布均衡,同时由于Ceph的设计,采用了CRUSH算法、HASH环等方法,使得它不存在传统的单点故障的问题,且随着规模的扩大性能并不会受到影响。不管是私有云还是公有云,随着云架构的发展,Ceph 成为了OpenStack、Proxmox标配的后端存储,不光如此,就连目前最火的容器编排 Kubernetes 持久存储也都支持 Ceph ,让 Ceph 成为当前主流的存储系统,而对 Ceph 存储的学习也就变的刻不容缓。 该课程属于比较基础的 Ceph 存储课程,旨在让大家能快速上手对 Ceph 集群的部署以及操作,主要讲解以下几个方面: 1.     架构的介绍2.     集群的多种部署方式3.     块存储部署,客户端使用及快照、克隆和镜像4.     对象存储的部署及简单使用5.     Ceph FS 文件系统的部署、客户端使用及导出为NFS6.     集群的操作和管理,包括服务,集群扩展,缩减和集群维护7.     Ceph 基础知识的介绍,包括集群map,PG和身份验证8.     Ceph 集群的监控
Ansible是一个强大的自动化运维工具,常用于Linux服务器的配置和部署。在LAMP(Linux, Apache, MySQL, PHP)架构部署,你可以使用Ansible来管理整个环境的配置,包括安装软件包、配置服务、数据库等。Ansible配置文件通常使用YAML(一种人类可读的数据序列化语言)编写,它的核心是playbooks,这是一种包含一系列任务的文本文件。 在Ansible中,一个基本的LAMP部署playbook可能包含以下几个部分: 1. `hosts`: 定义要部署到的服务器列表,可以是主机名或IP地址。 2. `tasks`: 包含一系列`block`,每个`block`代表一个操作,例如安装软件包(`apt`或`yum`)、创建用户或目录、配置Apache或MySQL等。 3. `roles`: 如果有多个任务可以复用,可以将它们组织成角色(role),提高代码的可重用性和可维护性。 4. `vars`: 可以定义变量,如数据库用户名、密码等,这些可以在多个任务中引用。 5. `handlers`: 当某个任务完成后,可能会触发其他任务执行,如重启服务。 一个基本的LAMP部署playbook示例可能如下: ```yaml --- - name: Deploy LAMP stack hosts: web_servers vars: mysql_root_password: 'your_mysql_password' php_version: '7.4' tasks: - name: Install OS packages apt: name: - apache2 - mysql-server - php{{ php_version }} state: present - name: Configure Apache template: src: apache.conf.j2 dest: /etc/apache2/sites- name: Start and enable Apache service: name: apache2 state: started enabled: yes - name: Secure MySQL mysql_user: name: root password: "{{ mysql_root_password }}" priv: '*.*:ALL' grant: 'GRANT' - name: Restart MySQL for changes service: name: mysql state: restarted handlers: - name: restart_apache service: name: apache2 state: restarted ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值