Yulia Portnova | 0f99119 | 2015-04-24 16:56:52 +0300 | [diff] [blame] | 1 | #!/bin/bash |
Yulia Portnova | 2b4af7b | 2015-05-07 15:49:33 +0300 | [diff] [blame] | 2 | |
| 3 | while [[ $# > 1 ]] |
| 4 | do |
| 5 | key="$1" |
| 6 | |
| 7 | case $key in |
| 8 | warehouses) |
| 9 | WAREHOUSES="$2" |
| 10 | shift |
| 11 | ;; |
| 12 | *) |
| 13 | echo "Unknown option $key" |
| 14 | exit 1 |
| 15 | ;; |
| 16 | esac |
| 17 | shift |
| 18 | done |
| 19 | |
Yulia Portnova | 0f99119 | 2015-04-24 16:56:52 +0300 | [diff] [blame] | 20 | # install and configure mysql |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 21 | |
Yulia Portnova | 0f99119 | 2015-04-24 16:56:52 +0300 | [diff] [blame] | 22 | DATABASE_PASSWORD=wally |
| 23 | DATBASE_USER=root |
| 24 | DB_NAME=tpcc |
| 25 | |
| 26 | # not prompting db password |
| 27 | debconf-set-selections <<MYSQL_PRESEED |
| 28 | mysql-server mysql-server/root_password password $DATABASE_PASSWORD |
| 29 | mysql-server mysql-server/root_password_again password $DATABASE_PASSWORD |
| 30 | mysql-server mysql-server/start_on_boot boolean true |
| 31 | MYSQL_PRESEED |
| 32 | |
| 33 | apt-get install -y mysql-server |
| 34 | apt-get install -y libmysqld-dev |
| 35 | apt-get install -y make |
| 36 | |
| 37 | # disable mysql profile in apparmor |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 38 | #sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ |
| 39 | #sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld |
Yulia Portnova | 0f99119 | 2015-04-24 16:56:52 +0300 | [diff] [blame] | 40 | |
| 41 | # allows us not to access mysql without specifying password |
| 42 | cat <<EOF >$HOME/.my.cnf |
| 43 | [client] |
| 44 | user=$DATABASE_USER |
| 45 | password=$DATABASE_PASSWORD |
| 46 | host=$DATABASE_HOST |
| 47 | EOF |
| 48 | |
| 49 | cd ~ |
Yulia Portnova | b1a1507 | 2015-05-06 14:59:25 +0300 | [diff] [blame] | 50 | apt-get -y install bzr |
Yulia Portnova | 0f99119 | 2015-04-24 16:56:52 +0300 | [diff] [blame] | 51 | bzr branch lp:~percona-dev/perconatools/tpcc-mysql |
| 52 | cd tpcc-mysql/src |
| 53 | make |
| 54 | |
| 55 | cd .. |
| 56 | mysql -e "CREATE DATABASE $DB_NAME;" |
| 57 | mysql "$DB_NAME" < create_table.sql |
| 58 | mysql "$DB_NAME" < add_fkey_idx.sql |
| 59 | |
Yulia Portnova | 2b4af7b | 2015-05-07 15:49:33 +0300 | [diff] [blame] | 60 | ./tpcc_load localhost "$DB_NAME" "$DATBASE_USER" "$DATABASE_PASSWORD" "$WAREHOUSES" |