Advertisement
Guest User

Untitled

a guest
May 9th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. #!/bin/sh
  2. supg="sudo -u postgres"
  3. tablespace="benchspace"
  4. database="benchdb"
  5. mountpoint="/var/lib/data/pg"
  6. datadir="dbs"
  7. partition="/dev/cciss/c0d0p3"
  8.  
  9. pguser="mezgani"
  10. pgpassword="<fondep123"
  11.  
  12. pgbench=`which pgbench`
  13.  
  14. mkfsext3=`which mkfs.ext3`
  15. mkfsxfs=`which mkfs.xfs`
  16. mkfsjfs=`which mkfs.jfs`
  17.  
  18. #setting default scale factor 100,000 rows in the accounts table.
  19. pgbench_scale=1
  20.  
  21. #setting default client, 4 client per core
  22. pgbench_concurrent=16
  23. pgbench_transactions=20000
  24.  
  25.  
  26.  
  27. function cleandb(){
  28. ${supg} dropdb ${database}
  29. ${supg} psql -c "DROP tablespace ${tablespace}"
  30. }
  31.  
  32.  
  33. function startbench(){
  34. #scale number max of clients, and transaction of each
  35. #for pgbench_scale in 1, 5, 10, 20, 30, 40, 50, 75, 100, 200, 500; do
  36. for pgbench_scale in 1, 5, 10, 20, 30, 40, 50; do
  37. #cleandb
  38. echo "[1]. Creating tablespace and database"
  39. ${supg} psql -c "CREATE tablespace ${tablespace} location '${mountpoint}/${datadir}'"
  40. ${supg} createdb --owner $pguser --tablespace ${tablespace} ${database}
  41. echo "[2]. Initializing the benchmark database"
  42. #${pgbench} -U ${pguser} -P ${pgpassword} -i -s ${pgbench_scale} ${database}
  43. ${pgbench} -U ${pguser} -i -s ${pgbench_scale} ${database}
  44. echo "[3]. Running pgbench on ${mountpoint}"
  45. #${pgbench} -U ${pguser} -P ${pgpassword} -t ${pgbench_transactions} -c ${pgbench_concurrent} -S ${database} >> bench$i.log
  46. ${pgbench} -U ${pguser} -t ${pgbench_transactions} -c ${pgbench_concurrent} -S ${database} >> bench$i.log
  47. ${supg} psql -c "SELECT pg_size_pretty(pg_database_size('${database}'))" >> bench$i.log
  48. sync; sync; sleep 10
  49. done
  50. }
  51.  
  52. for i in ext3 jfs xfs; do
  53. echo "[1]. Creating the filesystem" $i
  54. case $i in
  55. #'ext3' ) ${mkfsext3} ${partition};;
  56. 'xfs' ) ${mkfsxfs} ${partition};;
  57. 'jfs' ) ${mkfsjfs} ${partition};;
  58. esac
  59.  
  60. mount -t $i ${partition} ${mountpoint}
  61. chown -R postgres:postgres ${mountpoint}
  62. ${supg} mkdir ${mountpoint}/${datadir}
  63. startbench
  64. cleandb
  65. umount ${mountpoint}
  66. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement