Anúncio
Anúncio

Mais conteúdo relacionado

Apresentações para você(20)

Similar a Deployer PHP et MariaDB dans Azure - TechDays(20)

Anúncio

Mais de Christophe Villeneuve(20)

Anúncio

Deployer PHP et MariaDB dans Azure - TechDays

  1. techdays• 2015 #mstechdays techdays.microsoft.fr Déployez votre site PHP / MariaDB, simplement et rapidement dans Azure Christophe Villeneuve Serge Frezefond ● @hellosct1 @sfrezefond
  2. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Qui ? << Christophe VilleneuveSerge Frezefond
  3. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Les 4 axes du jour ● Les fondamentaux du déploiement ● Les notions à connaître ● Les différentes possibilités de communiquer ● Automatisation
  4. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Les fondamentaux Azure Websites
  5. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Azure WebSites dans le Cloud SaaS (utilisateurs) PaaS (Développeurs) IaaS (Administrateurs) • Logiciels applicatifs • Infrastructure logicielle • Systèmes d’exploitation • Virtualisation • Serveurs physiques • Réseaux • Data center
  6. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure API Drupal en localhost (1/2) $ apt-get install git $ apt-get install apache2 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin $ sudo /etc/init.d/apache2 restart $ apt-get install drush Source : Livre : 'Drupal Avancé' – Editions Eyrolles PC
  7. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure API Drupal en localhost (2/2) $ drush dl drupal $ cd drupal-demo $ cd sites/default $ mkdir files $ chmod 755 files $ cp default.settings.php settings.php $ chmod 666 settings.php $ cd drupal-demo $ drush site-install standard --account-name=admin --account-pass=admin --db- url=mysql://YourMySQLUser:RandomPasswo rd@localhost/YourMySQLDatabase PC
  8. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Résultat PC
  9. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Préparation Azure Website (1/2) ● https://manage.windowsazure.com Websites
  10. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Préparation Azure Website(2/2) ● Résultat Websites
  11. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Déploiement dev → Azure ● git init ● git add . ● git commit -m "initial commit" ● git remote add azure [URL for remote repository] ● git push [URL repository] master PC Websites
  12. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Déploiement BDD MySQL Sites web configurer → chaînes de connexion ● Database=remote_db_name; Data Source=remote_host; User Id=remote_username; Password=remote_password ● mysqldump -u local_username --password=local_password drupal | mysql -h remote_host -u remote_username --password=remote_password remote_db_name PC SQL Database
  13. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Vérification ● URL : http://hello-drupal-demo.azurewebsites.net/ 2 solutions : ● Mise à jour de settings.php git commit -m 'update setting' ● Visual Studio Online Option PHP Websites
  14. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Visual Studio online (1/2) ● Sites web configurer ● Sites web tableau de bord Websites Visual Studio Online
  15. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Visual Studio Online (2/2) ● https://hello-drupal-demo.scm.azurewebsites.net/dev/wwwroot/ Websites Visual Studio Online
  16. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Résultat
  17. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Son environnement Machine Virtuelle
  18. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure VM ● Créer une machine Virtuelle Virtual Machines
  19. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Mode terminal Vérification distribution linux $ apt-get install git $ apt-get install apache2 libapache2-mod-php5 mysql-server libapache2-mod-auth- mysql php5-mysql phpmyadmin $ sudo /etc/init.d/apache2 restart ..etc... Installation AMP Virtual Machines
  20. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MySQL → MariaDB ● Vérification $ mysql -u root -p show databases; ● Repositories https://downloads.mariadb.org/mariadb/repositories
  21. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MySQL → MariaDB (1/2) https://downloads.mariadb.org/mariadb/repositories sudo apt-get install software-properties-common sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db sudo add-apt-repository 'deb http://ftp.igh.cnrs.fr/pub/mariadb/repo/10.0/ubuntu utopic main'
  22. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MySQL → MariaDB (2/2) sudo apt-get update sudo apt-get install mariadb-server $ mysql -u root -p <enter password> show databases;
  23. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Résultat
  24. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Test → prod (1/4) ● Sites web tableau de bord → Ajouter un nouvel emplacement ● Saisir un nom Virtual Machines Virtual Machines
  25. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Test → prod (2/4) ● Résultat ● Echanger (swap) Virtual Machines Virtual Machines
  26. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Test → prod (3/4) ● Résultat ● Echanger (swap) Virtual Machines Virtual Machines
  27. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Test → prod (4/4) ● Choix Virtual Machines Virtual Machines
  28. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Performance ● Sites web Mettre à l'échelle → capacité Virtual Machines Virtual Machines
  29. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Rappel
  30. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB ● A MySQL fork ● Developed by original creators of MySQL ● Adopted by Linux Distributions (Now default for RedHat 7 and Suse) ● 100% open source ● Supported by big names that actively contribute: Google, Booking.com,...
  31. MariaDB 10.0 Scalability ● Advanced parallel replication ● Sharding ● MaxScale proxy (future) Performance ● Enhanced optimization ● Improved and special purpose storage engines ● Carefully tuned and enhanced server internals ● Advanced performance monitoring Availability ● HA clustering - integrating Galera cluster ● More online operations, less planned downtime NoSQL ● Interoperable storage engines such as Cassandra and Connect ● Dynamic columns and JSON processing ● HandlerSocket API Operations ● Comprehensive diagnostics built-in to the DB ● APIs and open architecture for easier integration Security ● Role-based access control ● Authentication plugins ● Sophisticated auditing capabilities
  32. © MariaDB Corporation Ab Global Transaction ID (GTID) ● New MariaDB exclusive global event ID unique across multiple independent replication streams. ○ DomainID added to SeqNum-ServerID to uniquely label replication events. ○ Slaves save their replication status in a crash- safe table, transactionally synced to the slave’s binlog. ○ Replication streams always strictly ordered, but independent streams may be interleaved on the slave. ● Much simpler failover to new master with complex topologies. ● Supports multi-source and parallel replication. A1 A2 A3 A4 A5 B1 B2 B3 B4 B5 A1 A2 B1 A3 B2 B3 A4 A 4 B 3 Crash-safe Replication State XX DomainID 32-bit YYYY SeqNum 64-bit ZZ ServerID 32-bit MariaDB GTID
  33. © MariaDB Corporation Ab Parallel Slave Replication ● Sponsored by Google. ● Allows slaves to process update events in parallel. ○In same consistente order as the master ○Out of order across domain ID ( require GTID) consistente per domain ● Preliminary benchmarks: almost 10x faster at 12 threads.
  34. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Multi-Source Replication ● Collects data for analytics using built-in replication. ● Aids in administration example: consolidated backups of multiple databases. ● Uses MariaDB 10’s improved Global Transaction ID (GTID). Online E- Commerce Application Master S S S S Content Management System Click-stream data Data WarehouseSlave ETL Master S S S S Master S S S S
  35. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB Dynamic (& Virtual) Columns ● Store unstructured data in MariaDB tables with a simple API. ● Use MariaDB’s indexing and transactions to manipulate “document” style data fast and consistently. ● Nest sets of dynamic columns inside of other dynamic columns - hierarchical structuring. ● Include multiple rows with dynamic columns in transactions. ● Virtual Columns allows to create function based columns Cust ID Account Balance Dyn_Col_BLOBs 2035 $154.04 NAME: John Smith|LOC: 45.35243, -74.98348|IMAGE: x27A8B8C ... 2036 $929.10 NAME: Jane Doe|LOC: 45.35243, -74.98348|AGE: 32| GENDER: F... 2037 $377.53 NAME: Carol Jones|AGE: 43|GENDER: F||IMAGE: xA9674DE678 ...
  36. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB Dynamic Column Example MariaDB [test]> create table t1 (id int auto_increment primary key, -> name varchar(40), -> type enum ("shirt", "phone", "computer"), -> price decimal(10,2), -> dynstr mediumblob); MariaDB [test]> insert into t1 (name, type, price, dynstr) values ("Funny shirt", "shirt", 10.0, COLUMN_CREATE(1, "blue", 10, "XL")), … MariaDB [test]> select id, name, type, price, length(dynstr) … +----+-------------------------+----------+--------+------| 1 | Funny shirt | shirt | 10.00 | 17 | 1,10 | …
  37. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB Dynamic Column Example MariaDB [test]> MariaDB [test]> select name, COLUMN_GET(dynstr, 1 as char(10)) from t1 where COLUMN_EXISTS(dynstr, 1); +-------------------------+-----------------------------------+ | name | COLUMN_GET(dynstr, 1 as char(10)) | +-------------------------+-----------------------------------+ | Funny shirt | blue | | nokia | black | | htc Desire hd | black | | BM/Lenovo Thinkpad X60s | black | +-------------------------+-----------------------------------+ 4 rows in set (0.00 sec)
  38. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB Security ● Pluggable authentication (5.2) – PAM Plugin – Allow other authentication methods ● Audit Plugin (10.0) – Track user access to data in real time ● Roles (10.0) – Assign users to roles
  39. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Les différentes possibilités de communiquer
  40. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB 10 Interoperability : CONNECT Storage Engine ● From 3rd party developer. ● Maps diverse data to tables. ● JOIN mapped data to DB tables. ● Flat files including CSV. ● Tables in external Dbs. ● Generated tables (PIVOT etc.) ● Plug-in API for your own mappings. Application Spi der MariaDB Parser/Optimizer/Connection Pool CONNECT Engine Other Engines Database Tables Powerful tool for data integration, federation. .log XML CSV
  41. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure JSON Table Type (1/2) [ { "ISBN": "9782212090819", "LANG": "fr", "SUBJECT": "applications", "AUTHOR": [ { "FIRSTNAME": "Jean-Christophe", "LASTNAME": "Bernadac" }, … ], "TITLE": "Construire une application XML", "PUBLISHER": { …
  42. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure JSON Table Type (2/2)  create table jsampall ( ISBN char(15), Language char(2) field_format='LANG', Subject char(32) field_format='SUBJECT', Author char(128) field_format='AUTHOR:[" and "]', Title char(32) field_format='TITLE', Publisher char(20) field_format='PUBLISHER:NAME', Location char(16) field_format='PUBLISHER:PLACE', Year int(4) field_format='DATEPUB') engine=CONNECT table_type=JSON File_name='biblio3.jsn';
  43. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure JSON Table Type : Query Result select title, author, publisher, location from jsampall;  Title author publisher location Construire application XML Jean Bernadac and François Knab Eyrolles Paris XML en Action William J. Pardi Microsoft Press Paris
  44. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure JSON Table Type : The Jpath Specification Specification Array Type Description [n] All Take the nth value of the array. Ignore it if n is 0. [X] or [x] All Expand. Generate one row for each array value. ["string”] StringConcatenate all values separated by the specified string. [+] Numeric Make the sum of all the array values. [*] Numeric Make the product of all array values. [!] Numeric Make the average of all the array values. [>] or [<] All Return the greatest or least value of the array. [#] All Return the number of values in the array. [] All Sum if numeric, else concatenation separated by “, “. All Take the first value if an array.
  45. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Automatisation & Réplication
  46. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB Galera Cluster Synchronous Replication Cluster ● Read & Write access to any node ● Client can connect to any node ● There can be several nodes ● Automatic node provisioning ● Replication is synchronous Galera Replication MariaDB MariaDB MariaDB
  47. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB Galera Cluster and Standard replication Mgc1 Mgc2 Mgc3 Srv1 Srv2 Srv2 Galera Cluster MariaDB Multi Source Asynchronous replication Synchronous replication
  48. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB Galera Cluster and Standard replication Mgc1 Mgc2 Mgc3 Slave Asynchronous replication Synchronous replication Slave can easily bind to new master with GTID Galera Cluster
  49. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB MaxScale Proxy • Connection Load Balancing • RW splitting • Galera Connection Load Balancing • MaxScale monitors the backends status • Other usages : filtering, auditing, query rewriting … MaxScale Technology Preview
  50. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure MariaDB MaxScale BinLog Server ● A binlog server carries binlog / no databases ● Small lag / Small drain on master ● Easy reconfiguration of topology
  51. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure ● VM Creation from image Galery ● VM Disks / Affinity group ● Virtual Network ● End Points / Load Balancer ● Storage / Containers ● Image Creation in Gallery Azure actions can be fully scripted in IaaS mode
  52. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  53. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  54. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  55. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  56. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  57. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  58. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  59. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  60. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  61. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  62. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Sous titre
  63. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure
  64. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure Azure actions can be fully scripted in IaaS mode $ azure network vnet create --address-space 10.0.0.0 --cidr 8 --subnet-name mariadb --subnet-start-ip 10.0.0.0 --subnet-cidr 24 --affinity-group galeraag galeravnet …
  65. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure $ azure vm create -v --vm-name sfmariadb5 --virtual-network-name galeravnet2 --subnet-names mariadbsn2 --affinity-group galeraag --vm-size large --ssh 22 --ssh-cert ./myCert.pem --no-ssh-password sfmariadb5 5112500ae3b842c8b9c604889f8753c3__OpenLogic- CentOS-66-20150128 azureuser …
  66. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure // Adding load balancing $ azure vm endpoint create --lb-set-name mysql mariadb1 3306 $ azure vm endpoint create --lb-set-name mysql mariadb2 3306 $ azure vm endpoint create --lb-set-name mysql mariadb3 3306
  67. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure $ sudo yum install MariaDB-Galera-server MariaDB-client galera $ sudo service mysql start $ sudo /usr/bin/mysql_secure_installation // create user for gal era cluster $ mysql -u root -pmanager1 <<EOF DELETE FROM mysql.user WHERE user=''; GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'dbpass'; GRANT USAGE ON *.* to sst_user@'%' IDENTIFIED BY 'dbpass'; GRANT ALL PRIVILEGES on *.* to sst_user@'%'; FLUSH PRIVILEGES; EOF
  68. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure // /etc/my.cnf.d/server.cnf wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_address="gcomm://10.0.0.9,10.0.0.11,10.0.0.13" wsrep_cluster_name='galera_cluster' wsrep_node_address='10.0.0.9' wsrep_node_name=’sfmariadb1' … $ sudo /etc/init.d/mysql start --wsrep-new-cluster $ sudo /etc/init.d/mysql start $ sudo /etc/init.d/mysql start
  69. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Azure Load Balancing : Web & MariaDB Network Load Balancer Windows Azure Datacenter ← HTTP load balancing Network Load Balancer ← MariaDB load balancing
  70. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure ● Using configuration tools ● Instead of manual install : yum/apt install Pupet / Chef / Ansible ● Vagrant provider for Azure : create VM, deploy and configure software ● Docker : can create VM
  71. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure : Ansible ● hosts: db user: root tasks: – name: get epel-repo … – name: copy mariadb repo file copy: src=/etc/ansible/files/MariaDB.repo dest=/etc/yum.repos.d/MariaDB.repo – name: install mariadb galera server yum: name=MariaDB-Galera-server state=latest
  72. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure : Ansible ● hosts: cluster1 user: root tasks: – name: is mysql running? … – name: bootstrap by starting mysql with gcomm:// action: shell service mysql start –wsrep_new_cluster when: is_mysql_running.rc > 0
  73. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure How to deploy MariaDB in Azure : Ansible ● hosts: cluster2:cluster3 tasks: – name: if the cluster is not started already, start it action: service name=mysql state=started – hosts: cluster1 user: root tasks: – name: Create user for MaxScale …
  74. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Deploy more complex MariaDB architectures Configuration can be automated ● Master Slave (multi levels) ● Galera Cluster (with replication for more HA) ● Load Balancer (Azure, HaProxy, MaxScale) ● Sharded configuration(MariaDB Spider)
  75. tech.days 2015#mstechdaysDéployez votre site PHP / MariaDB, simplement et rapidement dans Azure Operate MariaDB in the cloud ● Backup – Mysqldump, xtrabackup ● Monitoring – Open Source solutions : Nagios, ZABBIX, – Proprietary tools :Monyog – Use insight ? To test ● Azure Storage / Archive can be used to push MariaDB backups
  76. tech.days 2015#mstechdays Activez vos bénéfices Azure jusqu’à 115€ de ressources mensuelles offertes 115€ /mois x5 membres x3 ans = 4 175€ de ressources offertes http://azure.com http://aka.ms/azurepourmsdn 150€ de ressources offertes Sans engagement Pour tous Un mois d’essai offert http://www.microsoft.com/bizspark/ Les Ressources Azure Pour les startups Bizspark = 49 000€ de ressources offertes pendant un an Pour les abonnés MSDN
  77. tech.days 2015#mstechdays L’accompagnement Azure
  78. Questions Serge Frezefond @sfrezefond @hellosct1 Christophe Villeneuve
Anúncio