Skip to content

Commit

Permalink
fio example commit
Browse files Browse the repository at this point in the history
  • Loading branch information
denglei committed Aug 30, 2014
1 parent 2256394 commit 46a3357
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions fio_install/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
本文介绍使用ansible的playbook功能在centos或者redhat 6系列系统里安装sysbench测试数据库负载情况.
7 changes: 7 additions & 0 deletions fio_install/fio_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
- fio_install
2 changes: 2 additions & 0 deletions fio_install/roles/common/handlers/main.yml
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 fio_install/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 fio_install/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 dmidecode libselinux-python
poll: 0
2 changes: 2 additions & 0 deletions fio_install/roles/fio_install/files/check_disk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
awk -v result=`df -h|egrep -Ev '(Filesystem|shm|boot|mapper|/$)'|awk '{print $NF}'|head -n 1` 'BEGIN{if(result=="") {print "/tmp"} else {print result}}'
Binary file not shown.
12 changes: 12 additions & 0 deletions fio_install/roles/fio_install/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
galaxy_info:
author: Deng Lei
description: Install Fio
license: MIT
min_ansible_version: 1.6
platforms:
- name: CentOS
versions:
- 6
categories:
- Test
dependencies: []
50 changes: 50 additions & 0 deletions fio_install/roles/fio_install/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
- name: Install Fio Require Software To Redhat Client
yum: name=libaio-devel state=latest
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Only_install_fio
- name: Copy Fio Software To Redhat Client
copy: src={{ item }} dest=/tmp/{{ item }} owner=root group=root
with_items:
- fio-{{ fio_version }}.tar.gz
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Only_install_fio
- name: Uncompression Fio Software In Redhat Client
shell: tar zxf /tmp/fio-{{ fio_version }}.tar.gz -C /tmp/
ignore_errors: yes
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Only_install_fio
- name: Install Fio Software In Redhat Client
shell: "cd /tmp/fio-{{ fio_version }}; make && make install"
ignore_errors: yes
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Only_install_fio
- name: Delete Old Software In Redhat Client
shell: rm -rf /tmp/fio-{{ fio_version }}.tar.gz /tmp/fio-{{ fio_version }}
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Only_install_fio
- name: Get the current time In Redhat Client
command: date +%Y%m%d%H%M
register: time
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Onlytest
- name: Copy Test Disk Script In Redhat Client
copy: src=check_disk.sh dest=/tmp/check_disk.sh owner=root group=root mode=0755
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Onlytest
- name: Get Test Disk info In Redhat Client
shell: /bin/bash /tmp/check_disk.sh
register: test_disk
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Onlytest
- name: Start Fio Random Write And Read Test In Redhat Client
shell: /usr/local/bin/fio -filename={{ test_disk.stdout }}/{{ filename }} -direct={{ direct }} -iodepth {{ iodepth }} -thread -rw={{ rw }} -rwmixread={{ rwmixread }} -ioengine={{ ioengine }} -bs={{ bs }} -size={{ size }} -numjobs={{ numjobs }} -runtime={{ runtime }} -group_reporting -name={{ name }} -ioscheduler={{ ioscheduler }} --output=/tmp/{{ ansible_hostname }}-fio-{{ time.stdout }}.log
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Onlytest
- name: Copy Fio Test Result from Redhat Client
fetch: src=/tmp/{{ ansible_hostname }}-fio-{{ time.stdout }}.log dest=/tmp/{{ ansible_hostname }}-fio-{{ time.stdout }}.log flat=yes
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Onlytest
- name: Delete Fio Test Log In Redhat Client
shell: rm -rf {{ test_disk.stdout }}/{{ filename }} /tmp/{{ ansible_hostname }}-fio-{{ time.stdout }}.log /tmp/check_disk.sh
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
tags: Onlytest
1 change: 1 addition & 0 deletions fio_install/roles/fio_install/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- include: install.yml
14 changes: 14 additions & 0 deletions fio_install/roles/fio_install/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fio_dir: /tmp/fio_log
fio_version: 2.1.11
filename: random_write_read
direct: 1
iodepth: 1
rw: randrw
rwmixread: 70
ioengine: psync
bs: 16K
size: 2G
numjobs: 30
runtime: 1000
name: random_read_write
ioscheduler: noop

0 comments on commit 46a3357

Please sign in to comment.