Giter VIP home page Giter VIP logo

lxc_playbooks's Introduction

lxc_playbooks

Chaque répertoire contient en général un script shell/bash permettant depuis un hôte exécutant LXC d'automatiser certaines d'environnements containérisés sous LXC/LXD.

make_galera_cluster

Usage

Le script vous permet de créer un cluster MariaDB inspiré du très bon article de Florian BURNEL en 3 min sous LXC

Configuration

3 noeuds MariaDB vont être créés sous ubuntu 20.04

Dans mon script Bash, j'ai configuré les IPs que je souhaitais utiliser pour mes 3 noeuds, bien évidemment en dehors de mon pool DHCP LXC Pour voir si vous avez un range DHCP configuré, la commande est LXC :

$ lxc network show lxdbr0

# vous devriez avoir une sortie standard comme celle-ci si vous avez restreint le pool DHCP :

config:
  ipv4.address: 10.58.157.1/24
  ipv4.dhcp.ranges: 10.58.157.50-10.58.157.200 <= ici
  ipv4.nat: "true"
  ipv6.address: none
description: ""
name: lxdbr0
type: bridge
used_by:
- /1.0/profiles/default
managed: true
status: Created
locations:
- none

# par defaut, LXC prend un réseau complet donc /24
C'est donc moi qui ait configuré ce range via :

lxc network set lxdbr0 ipv4.dhcp.ranges 10.58.157.50-10.58.157.200


Les 3 IPs qui seront utilisées sont spécifiés sur la ligne du script bash :

CONTAINER_BASE_NAME="galera"
CONTAINER_COUNT=3
CONTAINER_IPS=("10.58.157.5" "10.58.157.6" "10.58.157.7")

J'ai choisi également de construire les noms de chaque noeud MariaDB sous la forme : galera1, galera2 et galera3 d'où les 2 variables supplémentaires.

Execution

Maintenant vous savez comment cela marche : Il suffit de lancer le script :

### ATTENTION : Le script toute trace de précédent container nommé galera1, 2 ou 3 !!!

$ ./create_galera_cluster.sh

3 min après vous avez un cluster MariaDB opérationnel :)

Vérification

$ for i in $(lxc ls -f csv -cn|grep galera);do echo "$i:"; lxc exec $i -- ss -tlpn|grep mysql;echo;done

galera1:
LISTEN    0         80                 0.0.0.0:3306             0.0.0.0:*        users:(("mysqld",pid=2953,fd=30))                                              
LISTEN    0         128                0.0.0.0:4567             0.0.0.0:*        users:(("mysqld",pid=2953,fd=11))                                              

galera2:
LISTEN    0         80                 0.0.0.0:3306             0.0.0.0:*        users:(("mysqld",pid=2958,fd=31))                                              
LISTEN    0         128                0.0.0.0:4567             0.0.0.0:*        users:(("mysqld",pid=2958,fd=11))                                              

galera3:
LISTEN    0         80                 0.0.0.0:3306             0.0.0.0:*        users:(("mysqld",pid=2954,fd=32))                                              
LISTEN    0         128                0.0.0.0:4567             0.0.0.0:*        users:(("mysqld",pid=2954,fd=11))                                             

$ lxc ls

+----------+---------+---------------------+----------------------------------------------+-----------+-----------+
|   NAME   |  STATE  |        IPV4         |                     IPV6                     |   TYPE    | SNAPSHOTS |
+----------+---------+---------------------+----------------------------------------------+-----------+-----------+
| galera1  | RUNNING | 10.58.157.5 (eth0)  |                                              | CONTAINER | 0         |
+----------+---------+---------------------+----------------------------------------------+-----------+-----------+
| galera2  | RUNNING | 10.58.157.6 (eth0)  |                                              | CONTAINER | 0         |
+----------+---------+---------------------+----------------------------------------------+-----------+-----------+
| galera3  | RUNNING | 10.58.157.7 (eth0)  |                                              | CONTAINER | 0         |
+----------+---------+---------------------+----------------------------------------------+-----------+-----------+

Fini !

lxc_playbooks's People

Contributors

vegeta2206 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.