27
Wordpress 24/7 Масштабируемость, доступность, надежность, восстановление после сбоев

Wordpress 24/7

  • Upload
    -

  • View
    153

  • Download
    0

Embed Size (px)

Citation preview

Wordpress 24/7 Масштабируемость, доступность, надежность, восстановление после сбоев

Web Server DB

Source code

Скажем «нет» FTP

Git, Mercurial, SVN

Только свой код

Wordpress

Oursite.com

> git commit, > git push

> git submodule add wordpress

wp-content

config.php

index.php

База данных

Репликация

Масштабирование

Балансировка

Galera Replication

Node3.sql Node1.sql Node2.sql

HA Proxy

Установка Galera на Node1.sql sudo apt-get update

sudo apt-get install python-software-properties

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db

sudo add-apt-repository 'deb http://mirror.jmu.edu/pub/mariadb/repo/5.5/ubuntu precise main‘

sudo apt-get update sudo apt-get install mariadb-galera-server galera

sudo apt-get install rsync

sudo nano /etc/mysql/conf.d/cluster.cnf

# Galera Cluster Configuration

wsrep_cluster_name=“wp_cluster" wsrep_cluster_address="gcomm://first_ip,second_ip,third_ip“

# Galera Node Configuration

wsrep_node_address=“first_ip"

wsrep_node_name=“Node1.sql"

Maintenance Configuration

sudo nano /etc/mysql/debian.cnf

[client]

host = localhost

user = debian-sys-maint

password = 03P8rdlknkXr1upf

socket = /var/run/mysqld/mysqld.sock

[mysql_upgrade]

host = localhost

user = debian-sys-maint

password = 03P8rdlknkXr1upf

socket = /var/run/mysqld/mysqld.sock

basedir = /usr

Запуск Galera Cluster

sudo service mysql stop

sudo service mysql start --wsrep-new-cluster # первая нода

sudo service mysql start #все остальные

Распределенное хранилище

Большой объем

Отказоустойчиовость

Node1.glusterFs Node2.glusterFs Node3.glusterFs

Client

mount -t glusterfs node0.glusterfs:/volume1 /data

gluster volume create volume1 replica 3 transport tcp node1.glusterfs:/data/cluster

node2.glusterfs:/data/cluster node3.glusterfs:/data/cluster

Установка glusterFS sudo apt-get update

sudo apt-get install python-software-properties

sudo add-apt-repository ppa:semiosis/ubuntu-glusterfs-3.4

sudo apt-get update

sudo apt-get install glusterfs-server

sudo gluster peer probe Node1.glusterFs

sudo gluster volume create volume1 replica 2 transport tcp gluster0.droplet.com:/gluster-storage gluster1.droplet.com:/gluster-storage force

sudo gluster volume start volume1

Установка

Масштабирование

Балансировка нагрузки

Hardware

OS

Hypervisor

VM1 VM2

App1 App2 App3 App4

Hardware

OS

Docker

App1 App2 App3 App4

Версионность

Легкость настройки

Экономия ресурсов

SRP (Single responsibility principle)

Dockerfile # Pull base image.

FROM dockerfile/ubuntu

# Install Nginx.

RUN \

add-apt-repository -y ppa:nginx/stable && \

apt-get update && \

apt-get install -y nginx && \

rm -rf /var/lib/apt/lists/* && \

echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \

chown -R www-data:www-data /var/lib/nginx

# Define mountable directories.

VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]

# Define working directory.

WORKDIR /etc/nginx

# Define default command.

CMD ["nginx"]

# Expose ports.

EXPOSE 80

EXPOSE 443

Доступ к исходному коду

Доступ к данным

Доступ к базе

Web server {1..n}

Балансировка

Масштабирование

Container Volume

Host file system /Folder

# Dockerfile

FROM busybox

VOLUME /var/lib/mysql

CMD /bin/sh

GIT GlusterFS MySql Galera Cluster

/sourcecode /wp-content

source vol content vol

:80

GIT GlusterFS MySql Galera Cluster

/sourcecode /wp-content

source vol content vol

:80

nginx

GIT GlusterFS MySql Galera Cluster

/sourcecode /wp-content

source vol content vol

:80

nginx nginx nginx

GIT GlusterFS MySql Galera Cluster

/sourcecode /wp-content

source vol content vol

:80

nginx nginx nginx

HAProxy

GIT GlusterFS MySql Galera Cluster

/sourcecode /wp-content

source vol content vol

:80

nginx nginx nginx

HAProxy cerf

cerf cerf cerf

src

cont

HAProxy

nginx

nginx

nginx

nginx cerf

sess

memcached

nginx

nginx

GIT

GlusterFS

MySql Galera

Cluster

cerf

cerf

cerf

cerf

cerf

cerf cerf

Автоматизация

Failover

Логирование

Спасибо за внимание!

tonnyeremin.com

@TonnyErjomin

[email protected]