ablog

不器用で落着きのない技術者のメモ

Amazon Linux 2 に PostgreSQL 9.2 をインストールする

Amazon Linux 2 に PostgreSQL 9.2 をインストールして、psql や pgbench で Redshift(ra3.4xlarge x 2ノード) にクエリを実行できることを確認した。

$ sudo yum install -y postgresql postgresql-contrib postgresql-devel
(中略)
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql-9.2.24-6.amzn2.x86_64                                                                                        1/5
  Installing : libxslt-1.1.28-6.amzn2.x86_64                                                                                           2/5
  Installing : uuid-1.6.2-26.amzn2.0.1.x86_64                                                                                          3/5
  Installing : postgresql-contrib-9.2.24-6.amzn2.x86_64                                                                                4/5
  Installing : postgresql-devel-9.2.24-6.amzn2.x86_64                                                                                  5/5
  Verifying  : postgresql-contrib-9.2.24-6.amzn2.x86_64                                                                                1/5
  Verifying  : postgresql-9.2.24-6.amzn2.x86_64                                                                                        2/5
  Verifying  : postgresql-devel-9.2.24-6.amzn2.x86_64                                                                                  3/5
  Verifying  : uuid-1.6.2-26.amzn2.0.1.x86_64                                                                                          4/5
  Verifying  : libxslt-1.1.28-6.amzn2.x86_64                                                                                           5/5

Installed:
  postgresql.x86_64 0:9.2.24-6.amzn2       postgresql-contrib.x86_64 0:9.2.24-6.amzn2       postgresql-devel.x86_64 0:9.2.24-6.amzn2

Dependency Installed:
  libxslt.x86_64 0:1.1.28-6.amzn2                                     uuid.x86_64 0:1.6.2-26.amzn2.0.1
  • psql と pgbench のバージョンを確認する
$ psql -V
psql (PostgreSQL) 9.2.24
$ pgbench -V
pgbench (PostgreSQL) 9.2.24
  • Redshift に psql で接続してクエリを実行できることを確認する
$ psql "host=redshift-cluster-4.******.ap-northeast-1.redshift.amazonaws.com user=awsuser dbname=dev port=5439"
Password:
psql (9.2.24, server 8.0.2)
WARNING: psql version 9.2, server version 8.0.
         Some psql features might not work.
SSL connection (cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256)
Type "help" for help.

dev=# select schemaname, tablename, tableowner from pg_tables;
     schemaname     |                tablename                | tableowner
--------------------+-----------------------------------------+------------
 pg_catalog         | pg_default_acl                          | rdsdb
 pg_catalog         | pg_conf                                 | rdsdb
 pg_catalog         | pg_library                              | rdsdb
 pg_catalog         | pg_shdepend                             | rdsdb
 pg_catalog         | pg_statistic_indicator                  | rdsdb
(以下略)
dev=# \q
  • pgbench で Redshift にクエリを実行できることを確認する
$ echo 'select schemaname, tablename, tableowner from pg_tables;' > pg_tables.sql
$ pgbench -r -c 1 -j 1 -n -t 100 -f pg_tables.sql -U awsuser -h redshift-cluster-4.********.ap-northeast-1.redshift.amazonaws.com -d dev -p 5439
(中略)
transaction type: Custom query
scaling factor: 1
query mode: simple
number of clients: 1
number of threads: 1
number of transactions per client: 100
number of transactions actually processed: 100/100
tps = 80.742052 (including connections establishing)
tps = 81.755253 (excluding connections establishing)
statement latencies in milliseconds:
        12.224070       select schemaname, tablename, tableowner from pg_tables;