Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- supg="sudo -u postgres"
- tablespace="benchspace"
- database="benchdb"
- mountpoint="/var/lib/data/pg"
- datadir="dbs"
- partition="/dev/cciss/c0d0p3"
- pguser="mezgani"
- pgpassword="<fondep123"
- pgbench=`which pgbench`
- mkfsext3=`which mkfs.ext3`
- mkfsxfs=`which mkfs.xfs`
- mkfsjfs=`which mkfs.jfs`
- #setting default scale factor 100,000 rows in the accounts table.
- pgbench_scale=1
- #setting default client, 4 client per core
- pgbench_concurrent=16
- pgbench_transactions=20000
- function cleandb(){
- ${supg} dropdb ${database}
- ${supg} psql -c "DROP tablespace ${tablespace}"
- }
- function startbench(){
- #scale number max of clients, and transaction of each
- #for pgbench_scale in 1, 5, 10, 20, 30, 40, 50, 75, 100, 200, 500; do
- for pgbench_scale in 1, 5, 10, 20, 30, 40, 50; do
- #cleandb
- echo "[1]. Creating tablespace and database"
- ${supg} psql -c "CREATE tablespace ${tablespace} location '${mountpoint}/${datadir}'"
- ${supg} createdb --owner $pguser --tablespace ${tablespace} ${database}
- echo "[2]. Initializing the benchmark database"
- #${pgbench} -U ${pguser} -P ${pgpassword} -i -s ${pgbench_scale} ${database}
- ${pgbench} -U ${pguser} -i -s ${pgbench_scale} ${database}
- echo "[3]. Running pgbench on ${mountpoint}"
- #${pgbench} -U ${pguser} -P ${pgpassword} -t ${pgbench_transactions} -c ${pgbench_concurrent} -S ${database} >> bench$i.log
- ${pgbench} -U ${pguser} -t ${pgbench_transactions} -c ${pgbench_concurrent} -S ${database} >> bench$i.log
- ${supg} psql -c "SELECT pg_size_pretty(pg_database_size('${database}'))" >> bench$i.log
- sync; sync; sleep 10
- done
- }
- for i in ext3 jfs xfs; do
- echo "[1]. Creating the filesystem" $i
- case $i in
- #'ext3' ) ${mkfsext3} ${partition};;
- 'xfs' ) ${mkfsxfs} ${partition};;
- 'jfs' ) ${mkfsjfs} ${partition};;
- esac
- mount -t $i ${partition} ${mountpoint}
- chown -R postgres:postgres ${mountpoint}
- ${supg} mkdir ${mountpoint}/${datadir}
- startbench
- cleandb
- umount ${mountpoint}
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement