Skip to content

Commit

Permalink
add redis master and slave install by version 2.6.17
Browse files Browse the repository at this point in the history
  • Loading branch information
denglei committed Mar 27, 2015
1 parent 0aa9b7e commit 690402b
Show file tree
Hide file tree
Showing 34 changed files with 1,424 additions and 0 deletions.
1 change: 1 addition & 0 deletions redis_master_slave_install_2.6.17/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
本文介绍使用ansible的playbook功能在centos或者redhat 6系列系统里安装2.6.17版本redis主从.
7 changes: 7 additions & 0 deletions redis_master_slave_install_2.6.17/redis_delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: "{{host}}"
remote_user: "{{user}}"
gather_facts: True
# sudo: True
roles:
- redis_delete
8 changes: 8 additions & 0 deletions redis_master_slave_install_2.6.17/redis_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- hosts: "{{host}}"
remote_user: "{{user}}"
gather_facts: True
# sudo: True
roles:
- common
- redis_install
6 changes: 6 additions & 0 deletions redis_master_slave_install_2.6.17/redis_slave_delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- hosts: "{{host}}"
remote_user: "{{user}}"
gather_facts: True
roles:
- redis_slave_delete
7 changes: 7 additions & 0 deletions redis_master_slave_install_2.6.17/redis_slave_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: "{{host}}"
remote_user: "{{user}}"
gather_facts: True
roles:
- common
- redis_slave_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: restart ntpd
service: name=ntpd state=restarted
16 changes: 16 additions & 0 deletions redis_master_slave_install_2.6.17/roles/common/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
galaxy_info:
author: Deng Lei
description: Install initializtion Software
license: MIT
min_ansible_version: 1.6
platforms:
- name: CentOS
versions:
- 5
- 6
- name: Ubuntu
versions:
- precise
categories:
- system
dependencies: []
3 changes: 3 additions & 0 deletions redis_master_slave_install_2.6.17/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Install initializtion require software
shell: yum -y install make cmake bc gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers libxslt-devel libevent-devel ntp libtool-ltdl bison libtool vim-enhanced tar wget readline-devel libyaml-devel patch telnet lrzsz sysstat screen parted rsync libselinux-python dmidecode ntpdate sar openssh-clients
poll: 0
12 changes: 12 additions & 0 deletions redis_master_slave_install_2.6.17/roles/redis_delete/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
galaxy_info:
author: Deng Lei
description: Delete Redis
license: MIT
min_ansible_version: 1.6
platforms:
- name: CentOS
versions:
- 6
categories:
- Service
dependencies: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- name: Stop Redis Service In Redhat Client
shell: /usr/bin/redis-cli -h {{ ansible_default_ipv4.address }} -p {{ redis_port }} shutdown
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Delete Redis Soft Line In Redhat Client
shell: rm -rf /usr/bin/{{ item }}
with_items:
- redis-cli
- redis-server
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Delete Redis Dir In Redhat Client
shell: rm -rf {{ redis_dir }}/redis-{{ redis_version }}
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Delete Boot Start In Redhat Client
shell: sed -i '/{{ redis_port }}*/d' /etc/rc.local
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- include: delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
/usr/bin/redis-cli -h {{ ansible_default_ipv4.address }} -p {{ redis_port }} shutdown
rm -rf /usr/bin/redis-server /usr/bin/redis-cli
rm -rf {{ redis_dir }}/redis-{{ redis_version }}
sed -i '/{{ redis_port }}*/d' /etc/rc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
redis_dir: /data
redis_version: 2.6.17
redis_port: 6379
redis_conf_dir: /data/redis-2.6.17/conf
redis_db_dir: /data/redis-2.6.17/db
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
galaxy_info:
author: Deng Lei
description: Install Redis
license: MIT
min_ansible_version: 1.6
platforms:
- name: CentOS
versions:
- 6
categories:
- Service
dependencies: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Copy Redis Software To Redhat Client
copy: src=redis-{{ redis_version }}.tar.gz dest=/tmp/redis-{{ redis_version }}.tar.gz owner=root group=root
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Create Redis Install Dir
file: dest={{ redis_dir }} state=directory
- name: Uncompression Redis Software To Redhat Client
shell: tar zxf /tmp/redis-{{ redis_version }}.tar.gz -C /data/
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Copy Redis Config To Redhat Client
template: src=redis.conf dest={{ redis_conf_dir }}/redis_{{ redis_port }}.conf owner=root group=root mode=0644
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Delete Redis compression Software In Redhat Client
shell: rm -rf /tmp/redis-{{ redis_version }}.tar.gz
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- name: Create Soft Link In Redhat Client
shell: ln -s {{ redis_dir }}/redis-{{ redis_version }}/redis-server/src/{{ item }} /usr/bin/{{ item }}
with_items:
- redis-cli
- redis-server
ignore_errors: True
- name: Check Boot Start In Redhat Client
shell: grep -c '/usr/bin/redis-server {{ redis_conf_dir }}/redis_{{ redis_port }}.conf' /etc/rc.local
register: redis_boot
ignore_errors: True
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: Add Boot Start In Redhat Client
shell: echo "/usr/bin/redis-server {{ redis_conf_dir }}/redis_{{ redis_port }}.conf" >>/etc/rc.local
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6 and redis_boot|int ==0
- name: Start Redis Service In Redhat Client
shell: /usr/bin/redis-server {{ redis_conf_dir }}/redis_{{ redis_port }}.conf
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- include: copy.yml
- include: install.yml
- include: delete.yml
Loading

0 comments on commit 690402b

Please sign in to comment.