LoginSignup
1
1

More than 5 years have passed since last update.

Postgres9.3 に Redis_Fdw 入れてみる。for Mac

Last updated at Posted at 2014-02-18

ずっと9.2だったPostgrSqlを9.3.2へbrewを使用し切り替えたので、
少し前に入れようとしエラーで断念したRedis_fdwに再度挑戦してみました。

まずはredis_fdwに必要な hiredis をインストール


$ git  clone https://github.com/redis/hiredis.git
Cloning into 'hiredis'...
remote: Reusing existing pack: 2172, done.
remote: Total 2172 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2172/2172), 717.79 KiB | 362.00 KiB/s, done.
Resolving deltas: 100% (1248/1248), done.
Checking connectivity... done

$ cd hiredis/

$ make install
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.c
cc -shared -Wl,-install_name,libhiredis.0.10.dylib -o libhiredis.dylib  net.o hiredis.o sds.o async.o
ar rcs libhiredis.a net.o hiredis.o sds.o async.o
mkdir -p /usr/local/include/hiredis /usr/local/lib
cp -a hiredis.h async.h adapters /usr/local/include/hiredis
cp -a libhiredis.dylib /usr/local/lib/libhiredis.0.10.dylib
cd /usr/local/lib && ln -sf libhiredis.0.10.dylib libhiredis.0.dylib
cd /usr/local/lib && ln -sf libhiredis.0.dylib libhiredis.dylib
cp -a libhiredis.a /usr/local/lib

では本番のredis_fdwをinstall


まずはgitから落とす。
$  git clone https://github.com/pg-redis-fdw/redis_fdw.git
Cloning into 'redis_fdw'...
remote: Counting objects: 174, done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 174 (delta 89), reused 174 (delta 89)
Receiving objects: 100% (174/174), 49.01 KiB | 0 bytes/s, done.
Resolving deltas: 100% (89/89), done.
Checking connectivity... done

$  cd redis_fdw/

ここで、PostgreSQL9.3をinstallし直し、どこにインストールされているのか分からなくなり調べる事に...

whichコマンドでpsqlの場所を調べる。
$ which psql
/usr/local/bin/psql

シンボリックリンクが張ってあるので場所を確認
$ cd /usr/local/bin

$ ls -la psql
********************  35  2 18 13:53 psql -> ../Cellar/postgresql/9.3.2/bin/psql


見つかったのでインストール

$ cd ~/redis_fdw/

$ PATH=/usr/local/Cellar/postgresql/9.3.2/bin/:$PATH make USE_PGXS=1 install
clang -I/usr/local/Cellar/ossp-uuid/1.6.2/include -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv  -I. -I. -I/usr/local/Cellar/postgresql/9.3.2/include/server -I/usr/local/Cellar/postgresql/9.3.2/include/internal -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2   -c -o redis_fdw.o redis_fdw.c
clang -I/usr/local/Cellar/ossp-uuid/1.6.2/include -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv  -bundle -multiply_defined suppress -o redis_fdw.so redis_fdw.o -L/usr/local/Cellar/postgresql/9.3.2/lib -L/usr/local/Cellar/ossp-uuid/1.6.2/lib  -Wl,-dead_strip_dylibs   -lhiredis -bundle_loader /usr/local/Cellar/postgresql/9.3.2/bin/postgres
/bin/sh /usr/local/Cellar/postgresql/9.3.2/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/Cellar/postgresql/9.3.2/lib'
/bin/sh /usr/local/Cellar/postgresql/9.3.2/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/Cellar/postgresql/9.3.2/share/postgresql/extension'
/bin/sh /usr/local/Cellar/postgresql/9.3.2/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/Cellar/postgresql/9.3.2/share/postgresql/extension'
/usr/bin/install -c -m 755  redis_fdw.so '/usr/local/Cellar/postgresql/9.3.2/lib/redis_fdw.so'
/usr/bin/install -c -m 644 ./redis_fdw.control '/usr/local/Cellar/postgresql/9.3.2/share/postgresql/extension/'
/usr/bin/install -c -m 644 ./redis_fdw--1.0.sql  '/usr/local/Cellar/postgresql/9.3.2/share/postgresql/extension/'

以前はここでERRORとなっており、断念しましたが今回はすんなり入ったみたいです。

psqlでDBに入り create extension を行う。


postgres=# create extension redis_fdw;
CREATE EXTENSION
postgres=# \dx
                            List of installed extensions
   Name    | Version |   Schema   |                   Description
-----------+---------+------------+--------------------------------------------------
 hstore    | 1.2     | public     | data type for storing sets of (key, value) pairs
 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
 redis_fdw | 1.0     | public     | Foreign data wrapper for querying a Redis server
(3 rows)

成功!!!

以前もの凄くハマったのですが、すんなりいってしまいました。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1