Install MHA on RHEL6 / CentOS6 for mySQL

Configure Proxy for Internet

#export http_proxy=http://proxy.xxxx.intra:00
#export https_proxy=https://proxy.xxxx.intra:00

Note: My environment is using a proxy server for Internet access, if you have direct access to internet ignore this step.

Configure RedHat subscription for yum

#subscription-manager register –username admin-example –password secret –auto-attach

Download epel-release package on machine

#wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

Note: the package will be downloaded on the path you are standing – verify from “pwd” command

Install epel-package

#yum install -y epel-release-latest-6.noarch.rpm

Install perl packages

#yum -y install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-Config-IniFiles ncftp perl-Params-Validate perl-CPAN perl-Test-Mock-LWP.noarch perl-LWP-Authen-Negotiate.noarch perl-devel

Install more perl packages

#yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

Download MHA Packages (Node & Manager)

https://code.google.com/p/mysql-master-ha/wiki/Downloads?tm=2

– MHA Manager 0.56 rpm RHEL6 – mha4mysql-manager-0.56-0.el6.noarch.rpm
– MHA Node 0.56 rpm RHEL6 – mha4mysql-node-0.56-0.el6.noarch.rpm

Once downloaded copy to server via WinSCP or SSH (somehow it is not working properly in wget for me)

Install MHA Packages

#yum -y install mha4mysql-node-0.56-0.el6.noarch.rpm

#yum -y install mha4mysql-manager-0.56-0.el6.noarch.rpm

Note: Move to directory where packages are downloaded

Advertisements

ANSIBLE 2.0.2.0 – Basic Cheat Sheet – CentOS 6

Ansible,com
Ansible.com

To install Ansible:

# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpminstall epel-release

# yum install epel-release-6-8.noarch.rpm

# yum update

# yum install ansible -y

Add remote hosts:

$ vim /etc/ansible/hosts

192.168.0.1 (your remote server IP) or
hostname.hostname.local (your remote server hostname)

Ping remote hosts: (if using ssh keys for authentication –ask-pass is not required)

$ ansible all -m ping –ask-pass

Ping remote hosts with specific account: (if using ssh keys for authentication –ask-pass is not required)

$ ansible all -m ping –ask-pass -u root

Execute command on remote server shell:

$ ansible all -m shell -a “mkdir /home/ansible/testdirectory” –ask-pass -u root

Remove file from remote server:

$ ansible all -m file -a “dest=/tmp/test.sh state=absent” –ask-pass -u root

Install apache on remote server:

$ ansible all -m yum -a “name=httpd state=latest” -u root

Change file permissions:

$ ansible all -m file -a “dest=/home/ansible/testfile.txt mode=600 owner=ansible group=anisble”

Confirm if package installed but do not update

$ ansible all -m yum -a “name=telnet state=present”

Confirm package is latest version

$ ansible all -m yum -a “name=telnet state=latest”

Confirm package is not installed

$ ansible all -m yum -a “name=telnet state=absent”

Start service

$ ansible all -m service -a “name=httpd state=started”

Restart service

$ ansible all -m service -a “name=httpd state=restarted”

Stop serivce

$ ansible all -m service -a “name=httpd state=stopped”

 

Gathering Facts

$ ansible all -m setup

Distribute Linux flavors in Ansible host file:

$ vim /etc/ansible/hosts

[RHEL]
192.168.1.1
rhel.redhat.test
[SUSE]
192.168.1.2
suse.opensuse.test

Only send instructions on RHEL hosts:

$ ansible RHEL  -m shell -a “mkdir /home/ansible/testfolder” 

Ansible use YaML for Automation and known as Playbook in Ansible

create a playbook i.e an .yaml file eg: telnetPlaybook.yaml


– hosts: SUSE
remote_user: root
tasks:
– zypper: name=telnet state=latest
– hosts: RHEL
remote_user: root
tasks:
– yum: name=telnet state=latest

Run playbook with Ansible: (-f switch allow the execution to be performed on multiple hosts parallel)

$ ansible-playbook telnetPlaybook.yaml -f 10

Ansible Modules (-m): These are few but there is huge list.

command – execute commands and this is default module of Ansible.
copy – copy files
shell – use remote shell to execute
file – file operations
ping – ping remote hosts
yum – Redhat package manager
git – use GIT
user – user creation, manipulation
service – manage services

If you find it interesting, spread the word 🙂