2014-10-31 05:42:09 -07:00
explain.depesz.com
==================
Setup
2014-10-31 06:00:30 -07:00
==================
2015-01-06 11:27:27 +03:00
There are three ways to install your own copy:
2018-07-02 21:41:49 +00:00
1. Using Vagrant [ VirtualBox machine, fully automated ]
1. Calling `puppet apply`
1. Manually
2015-01-06 11:27:27 +03:00
First get the source code:
2018-06-19 13:26:51 +02:00
git clone https://gitlab.com/depesz/explain.depesz.com.git
2015-01-06 11:27:27 +03:00
## Vagrant setup
2018-07-02 21:41:49 +00:00
*WARNING:*
The first call of `vagrant up` fetches a ~400MB vbox image from the Internet.
2015-01-06 11:27:27 +03:00
1. Call `vagrant up`
2015-01-06 18:45:08 +03:00
Point your browser on http://192.168.44.55 (or use `/etc/hosts` entry explain.depesz.loc)
2015-01-06 11:27:27 +03:00
## Puppet setup
1. Install puppet on your machine, e.g. Debian installation described [here ](https://docs.puppetlabs.com/guides/install_puppet/install_debian_ubuntu.html ).
2018-07-02 21:41:49 +00:00
1. Open `explain.pp` and fix line 5 with correct project dir value
1. Call `sudo puppet apply --logdest console explain.pp` on your working copy directory.
2015-01-06 11:27:27 +03:00
2019-04-02 20:19:06 +10:00
## Docker Compose setup
*NOTE* This setup should be considered for quick analysis purposes only - while docker-compose
does keep DBs around from run to run, don't rely on it to store your history long term.
```
cd docker
docker-compose up --build
```
2015-01-06 11:27:27 +03:00
## Manual setup
2018-07-02 21:41:49 +00:00
### 1) Mojolicious
You have to have Mojolicious installed on your server.
Mojolicious is a web framework for Perl.
2014-10-31 05:42:09 -07:00
http://mojolicio.us/
2014-10-31 06:00:30 -07:00
2014-10-31 05:42:09 -07:00
Installation can be accomplished with one command line:
curl -L cpanmin.us | perl - -n Mojolicious
2014-10-31 15:55:59 +01:00
2018-07-02 21:41:49 +00:00
See the `Installation` section at http://mojolicio.us/ for details.
2014-10-31 05:42:09 -07:00
2018-07-02 21:41:49 +00:00
### 2) Perl Dependencies:
2014-10-31 05:42:09 -07:00
You will need the following packages installed in your version of Perl:
2014-10-31 06:00:30 -07:00
DBD::Pg
2014-10-31 05:42:09 -07:00
Date::Simple
2019-04-02 21:38:37 +10:00
Email::Sender
2014-10-31 05:42:09 -07:00
Pg::Explain
Email::Valid
2014-10-31 15:55:59 +01:00
2014-10-31 05:42:09 -07:00
2019-04-02 21:38:37 +10:00
Install the above packages using `cpan` then `-i Date::Simple` , `-i Email::Sender` , & etc.
2014-10-31 05:42:09 -07:00
2014-10-31 15:55:59 +01:00
Note that in case of most current Linux distributions, you can install most of
these from binary package repositories. For example, in case of Ubuntu and
Debian, you can:
2018-07-02 21:41:49 +00:00
apt-get install libmojolicious-perl \
2019-04-02 21:38:37 +10:00
libemail-sender-perl \
2018-07-02 21:41:49 +00:00
libdate-simple-perl \
libemail-valid-perl \
libxml-simple-perl \
libdbd-pg-perl
2014-10-31 15:55:59 +01:00
2018-07-02 21:41:49 +00:00
And then only add `Pg::Explain` via CPAN.
2014-10-31 15:55:59 +01:00
2018-07-02 21:41:49 +00:00
### 3) PostgreSQL
You'll need to have PostgreSQL installed in order to record all the explain
plans into history. Consult the [PostgreSQL Wiki ](https://wiki.postgresql.org/wiki/Detailed_installation_guides )
for more information
2014-10-31 05:42:09 -07:00
2018-07-02 21:41:49 +00:00
#### 3A) Create a new database `explain`
This will be were the explain server will store the `users` and `plans` tables
in the default schema `public` .
2014-10-31 05:42:09 -07:00
2018-07-02 21:41:49 +00:00
#### 3B) Run SQL scripts
Log in to the `explain` database and execute the SQL scripts located in this
project's `sql` directory in the following order:
2014-10-31 05:42:09 -07:00
\i create.sql
\i patch-001.sql
\i patch-002.sql
2014-10-31 15:55:59 +01:00
2018-07-02 21:41:49 +00:00
The `create.sql` will create tables in the `explain` database `public` schema,
i.e. `plans` and `users` .
2014-10-31 05:42:09 -07:00
2018-07-02 21:41:49 +00:00
#### 3C) Create a user role
I use `explaind` [explain daemon], for example. Remember to provide it a
password and then configure the `explain.json` file to reflect this new role and
password.
2014-10-31 05:42:09 -07:00
2018-07-02 21:41:49 +00:00
CREATE USER explaind WITH PASSWORD 'explain';
2014-10-31 05:42:09 -07:00
2018-07-02 21:41:49 +00:00
#### 3D) Grant all rights to the tables in `explain` to your role:
2014-10-31 06:00:30 -07:00
2018-07-02 21:41:49 +00:00
GRANT ALL ON plans, users TO explaind;
2014-10-31 06:00:30 -07:00
2018-07-02 21:41:49 +00:00
#### 3E) modify `pg_hba.conf` so that it has the server as "127.0.0.1"
2014-10-31 15:55:59 +01:00
2018-07-02 21:41:49 +00:00
local all all 127.0.0.1 trust
2014-10-31 06:00:30 -07:00
2018-07-02 21:41:49 +00:00
If you do not want to alter `pg_hba.conf` , then you might be able to modify the
`explain.json.dsn` setting to specify the name of the value in the server column
from your `pg_hba.conf` file, e.g. "localhost". This alternative approach has
not been tested. It would be desirable to install this project with the minimal
amount of configuration changes, so I encourage someone to come up with a
solution that removes this step "E".
2014-10-31 06:00:30 -07:00
2018-07-02 21:41:49 +00:00
### 4) Configure `explain.json`
Make sure you have the correct values for your database connection.
See companion documentation file `explain-json-notes.txt`
2014-10-31 06:00:30 -07:00
2018-07-02 21:41:49 +00:00
### 5) Shell
The explain server runs on port 3000. Make sure port 3000 is available and not
in use by another process. You may have to specify a different port (e.g. 3200).
I do not know where you do that, probably in Mojolicious.
2014-10-31 06:00:30 -07:00
In the trunk directory for this project, run in a shell:
2018-07-02 21:41:49 +00:00
./explain.pl daemon
2014-10-31 06:00:30 -07:00
2018-07-02 21:41:49 +00:00
### 6) Browser
Then access the web page `http://localhost:3000` When you access the web page,
remember to login and create an account for yourself so that your explain plans
2014-10-31 06:00:30 -07:00
will be associated with your account.