-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
@@ -0,0 +1,265 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
файл следует переименовать, мы же не pgbench тут гоняем
@@ -0,0 +1,265 @@ | |||
#!/bin/bash | |||
|
|||
USAGE="pgbench1 -t xxxxx -e 0 -s 1 -k xxx -c xxx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше pgbench1 -t TOKEN -e EXPERIMENT_ID -s STEP -k S3_KEY -c S3_SECRET
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ну только не pgbench1, а что-то более логичное)
shopt -s expand_aliases | ||
alias sshdo='ssh -i ~/.ssh/awskey2.pem -o "StrictHostKeyChecking no" "ubuntu@$instanceIP"' | ||
|
||
define upd <<CONF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем нам эти upd и ins, они же для pgbench только
|
||
sshdo "sudo /etc/init.d/postgresql restart" | ||
|
||
#sshdo "sudo -u postgres psql -c 'create database test;'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
всё лишнее надо смело стирать, чтоб глаза не мозолило
sshdo "sudo apt-get install jq" | ||
sshdo "php --version" | ||
sshdo "s3cmd sync s3://p-dumps/tools/logloader.php ./" | ||
sshdo "s3cmd sync s3://p-dumps/tools/config.local.php ./" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем нам конфиг постилы?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это конфиг logloader, а не постилы.
date=$(date -d 'now' '+%Y%m%d') | ||
logdir=/var/log/postgresql | ||
|
||
sshdo "sudo -u postgres vacuumdb postila_ru -j 10 -v --analyze" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это должно было идти ДО прогонки запросов, т.к. тут важно собрать статистику внутреннюю в постгресе (--analyze
), чтобы запросы отрабатывали оптимально
sshdo "echo 'Prepare database'" | ||
sshdo "s3cmd sync s3://p-dumps/dev.imgdata.ru/postila_ru.sql-20180503.bz2 ./" | ||
sshdo "s3cmd sync s3://p-dumps/dev.imgdata.ru/queries.sql ./" | ||
sshdo "bunzip2 ./postila_ru.sql-20180503.bz2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это долги путь, можно было не распаковывать совсем, как-то вот так:
sudo -u postgres -c bzcat ./postila_ru.sql-20180503.bz2 | psql --set ON_ERROR_STOP=on -U postgres postila_ru
|
||
sshdo "echo '================================================'" | ||
sshdo "echo 'Execute queries'" | ||
sshdo "sudo -u postgres psql -d postila_ru -f ./queries.sql" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
хм, а у меня не прогоняется этот шаг, т.к. типа mat view не заполнена:
psql:./queries.sql:148: ERROR: materialized view "a__news_daily_90days_denominated" has not been populated
HINT: Use the REFRESH MATERIALIZED VIEW command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(точнее, прогоняется не до конца, выдаёт вот такую ошибку)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
на самом деле ожидаемо та же проблема:
[local]:5432 nikolay@postila_ru=# select * from a__news_daily_90days_denominated limit 1;
ERROR: materialized view "a__news_daily_90days_denominated" has not been populated
HINT: Use the REFRESH MATERIALIZED VIEW command.
решил её там с помощью REFRESH MATERIALIZED VIEW, чтобы последующие дампы уже ок были.
sshdo "pgbadger -j 4 --prefix '%t [%p]: [%l-1] db=%d,user=%u (%a,%h)' ${logdir}/${version}.log -f stderr -o ~/${version}.json-${date}" | ||
sshdo "ls -al" | ||
|
||
sshdo "s3cmd put ${logdir}/${version}.log s3://p-dumps/dev.imgdata.ru/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
думаю, стоит создать отдельные поддиректории для разных типов данных.
и лучше сжимать и лог, и json, они очень хорошо должны жаться обычным gzip-ом.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну и в названии файлов нужно чтобы отражались:
- версия БД
- ID эксперимента или признак того, что это не экспериментальный прогон, а "чистый" (то, что будет в графе "было")
No description provided.