Deploying a Database Cluster through Vagrant with ClusterControl


, Vagrant, , , , ( dev-). ClusterControl Vagrant.





Vagrant : VirtualBox, KVM, Hyper-V, Docker, VMware AWS. VirtualBox, — Vagrant.





VirtualBox , Vagrant . .





ClusterControl Vagrant

ClusterControl



:





  • Vagrantfile



    — .





  • deploy-cc.sh



    — bash- ClusterControl



    .





Vagrantfile



.





$ mkdir ~/vagrant/clustercontrol
$ cd ~/vagrant/clustercontrol
      
      



Vagrantfile



:





$ vim Vagrantfile
      
      



:





Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 443, host: 8443
  config.vm.network :private_network, ip: "192.168.11.11"
  config.vm.hostname = "cc.local"
  config.vm.provision "shell" do |s|
    s.inline = "yum install -y vim wget"
  end
  config.vm.provision "shell", path: "deploy-cc.sh"
 
  config.vm.provider :virtualbox do |vb|
    vb.customize [
      "modifyvm", :id,
      "--memory", "4096",
    ]
  end
end
      
      



deploy-cc.sh



. :





$ vim deploy-cc.sh
      
      



:





Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 443, host: 8443
  config.vm.network :private_network, ip: "192.168.11.11"
  config.vm.hostname = "cc.local"
  config.vm.provision "shell" do |s|
    s.inline = "yum install -y vim wget"
  end
  config.vm.provision "shell", path: "deploy-cc.sh"
 
  config.vm.provider :virtualbox do |vb|
    vb.customize [
      "modifyvm", :id,
      "--memory", "4096",
    ]
  end
end
      
      



. :





$ vagrant status
      
      



, :





$ vagrant up
      
      



, , Vagrant . . ClusterControl



http://127.0.0.1:8080/ https://127.0.0.1:8443/. 8080 HTTP-, 8443 — HTTPS, Vagrantfile



forwarded_port



.





 

ClusterControl



, . Vagrant . Galera Cluster , Percona XtraDB Cluster 8.0, :





ProxySQL MySQL. . Vagrantfile



. :





$ mkdir ~/vagrant/clustercontrol/percona-xtradb-cluster-80/
$ cd ~/vagrant/clustercontrol/percona-xtradb-cluster-80/
      
      



Vagrantfile



.





$ vim ~/vagrant/clustercontrol/percona-xtradb-cluster-80/Vagrantfile
      
      



:





nodes = [
  { :hostname => 'db1', :ip => '192.168.11.21', :ram => 1024, :guestport => 3306, :hostport => 13306 },
  { :hostname => 'db2', :ip => '192.168.11.22', :ram => 1024, :guestport => 3306, :hostport => 23306 },
  { :hostname => 'db3', :ip => '192.168.11.23', :ram => 1024, :guestport => 3306, :hostport => 33306 },
  { :hostname => 'proxy1', :ip => '192.168.11.26', :ram => 512, :guestport => 6033, :hostport => 16033 },
  { :hostname => 'proxy2', :ip => '192.168.11.27', :ram => 512, :guestport => 6033, :hostport => 26033 }
]
 
Vagrant.configure("2") do |config|
  nodes.each do |node|
    config.vm.define node[:hostname] do |nodeconfig|
      nodeconfig.vm.box = 'centos/7'
      nodeconfig.vm.hostname = node[:hostname] + ".local"
      nodeconfig.vm.network :private_network, ip: node[:ip]
      nodeconfig.vm.network "forwarded_port", guest: node[:guestport], host: node[:hostport]
 
      memory = node[:ram] ? node[:ram] : 512;
      nodeconfig.vm.provider :virtualbox do |vb|
        vb.customize [ "modifyvm", :id, "--memory", memory.to_s ]
        vb.customize [ "modifyvm", :id, "--audio", "none" ]
      end
 
      nodeconfig.vm.provision "shell" do |s|
        s.inline = "yum install -y wget vim"
      end
    end
  end
 
  (1..3).each do |i|
    config.vm.define "db#{i}" do |dbnode|
      dbnode.vm.provision "shell", path: "authorize.sh"
    end
  end
 
  (1..2).each do |i|
    config.vm.define "proxy#{i}" do |dbnode|
      dbnode.vm.provision "shell", path: "authorize.sh"
    end
  end
 
end
      
      



authorize.sh



:





CC_IP=192.168.11.11
curl -s http://${CC_IP}/cc.pub >> /home/vagrant/.ssh/authorized_keys
      
      



ClusterControl



, deploy-cc.sh



vagrant. SSH , , ClusterControl



.





:





$ vagrant up
      
      



, . vagrant status:





$ vagrant status
      
      







Percona XtraDB Cluster, ClusterControl



. ClusterControl



http://127.0.0.1:8080/clustercontrol, Deploy -> MySQL Galera :





SSH (SSH User) vagrant, authorized_keys



Vagrant authorize.sh



.





, . Vagrant VirtualBox , , , NAT. NAT- . Vagrant SSH- . IP-, Vagrantfile



, eth1, eth2 .., "Define MySQL Servers", :





IP- IP-, Vagrantfile ( IP- eth1 ). IP- , SSH  ClusterControl



. , "Deploy" . 





:





IP- SSH. ProxySQL ClusterControl -> Manage -> Load Balancers -> ProxySQL -> Deploy ProxySQL (192.168.11.26), :





"Use Native Clustering", ProxySQL. "Deploy ProxySQL". ClusterControl -> Activity -> Jobs. (192.168.11.27). IP- ( IP- ) Keepalived, ClusterControl -> Manage -> Load Balancers -> Keepalived -> Deploy Keepalived IP- (192.168.11.20) eth1, :





, -.





:





$ cd ~/vagrant/clustercontrol/percona-xtradb-cluster-80
$ vagrant halt
      
      



ClusterControl



ClusterControl



:





$ cd ~/vagrant/clustercontrol
$ vagrant halt
      
      



vagrant halt



vagrant destroy



. vagrant up



.






« ».









- : «MySQL NDB Cluster — ».












All Articles