Skip to content

Instantly share code, notes, and snippets.

@hkwi
Last active August 29, 2015 14:00
Show Gist options
  • Save hkwi/11280448 to your computer and use it in GitHub Desktop.
Save hkwi/11280448 to your computer and use it in GitHub Desktop.
# apt-get install postgres-xc
# /etc/init.d/postgres-xc start
# su postgres-xc -c createdb testdb

ごちゃごちゃ言われることがある。/etc/init.d/postgres-xc で restart を 2 回やれば回復するだろう。

createdb: database creation failed: ERROR:  No Datanode defined in cluster
HINT:  You need to define at least 1 Datanode with CREATE NODE.

あるいは明示的にこうやっても良いようだ。

$ psql -U postgres-xc postgres
> pgxc_pool_reload();
$ psql -U postgres-xc testdb
> \l -- データベース一覧
> \d -- テーブル一覧

distributed ではなく distribute "xxx" ではなく 'xxx'

create table hoge  ( a varchar(255) );
create table hoge2 ( a varchar(255) ) distribute by replication;
insert into hoge  values ('xxx');
insert into hoge2 values ('xxx');
kawai@ubuntu:~$ psql -U postgres-xc -p 15432 testdb
psql (PGXC 1.1, based on PG 9.2.4)
Type "help" for help.

testdb=# select * from hoge2;
  a
-----
 xxx
(1 row)

testdb=# select * from hoge;
 a
---
(0 rows)

testdb=# ^D\q
kawai@ubuntu:~$ psql -U postgres-xc -p 15433 testdb
psql (PGXC 1.1, based on PG 9.2.4)
Type "help" for help.

testdb=# select * from hoge;
  a
-----
 xxx
(1 row)

testdb=# select * from hoge2;
  a
-----
 xxx
(1 row)

testdb=# ^D\q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment