timescaledb/sql/setup/setup_node.sh
Erik Nordström 036c40886c Simplify cluster setup
Setting up single node is now:

```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select setup_single_node();
```

To setup a cluster do (on meta node):
```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select set_meta();
```

on data node:
```
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
select join_cluster('metadb', 'metahost');
```

This assumes that the commands are issued by the same user on both the
meta node and the data node. Otherwise the data node also has to
specify the user name to use when connecting to the meta node.
2017-02-07 12:22:36 +01:00

32 lines
643 B
Bash
Executable File

#!/bin/bash
# To avoid pw writing, add localhost:5432:*:postgres:test to ~/.pgpass
set -u
set -e
PWD=`pwd`
DIR=`dirname $0`
POSTGRES_HOST=${POSTGRES_HOST:-localhost}
POSTGRES_USER=${POSTGRES_USER:-postgres}
if [ "$#" -ne 1 ]; then
echo "usage: $0 nodename"
exit 1
fi
INSTALL_DB=$1
echo "Connecting to $POSTGRES_HOST as user $POSTGRES_USER and with db $INSTALL_DB"
cd $DIR
psql -U $POSTGRES_USER -h $POSTGRES_HOST -v ON_ERROR_STOP=1 <<EOF
DROP DATABASE IF EXISTS "$INSTALL_DB";
CREATE DATABASE "$INSTALL_DB";
\c "$INSTALL_DB"
CREATE EXTENSION IF NOT EXISTS iobeamdb CASCADE;
SELECT _iobeamdb_internal.setup_main();
EOF
cd $PWD