注意:docker的postgresql安装是官方镜像叫 postgres
docker安装ip4r
一、安装与测试
修改数据源
vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian-security buster/updates main
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security buster/updates main
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
确定数据库版本,以9.6为例
apt-get update
apt-get install vim
apt-get install wget
# 9.6为数据库版本号,数据库版本有12 11 9.6 9.5
apt-get install postgresql-server-dev-9.6
apt-get install postgresql-common
apt-get install make
apt-get install gcc
wget https://github.com/RhodiumToad/ip4r/archive/2.4.tar.gz
tar -zxvf 2.4.tar.gz
cd ip4r-2.4
env USE_PGXS=1 make
env USE_PGXS=1 make install
psql -U postgres
create extension ip4r ;
# 返回 > CREATE EXTENSION
create extension btree_gist;
# 返回 > CREATE EXTENSION
安装 ppsycopg2报错, Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application
apt-get install libpq-dev
二、使用
psql -U postgres
# strategy_parser为目标数据库
\l strategy_parser
create extension ip4r ;
create extension btree_gist;
apt-get安装ip4r
apt-get install postgresql-9.X-ip4r
apt-get install postgresql-9.6-ip4r
物理环境安装IP4R插件
在root用户下添加postgresql的环境变量信息
export PGHOME=/var/lib/postgresql
export PGDATA=/var/lib/postgresql/data
export PATH=$PGHOME/bin:$PATH
export MANPATH=$PGHOME/share/man:$MANPATH
export LANG=en_US.utf8
export DATE=`date +"%Y-%m-%d %H:%M:%S"`
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
下载ip4r插件
wget https://github.com/RhodiumToad/ip4r/archive/2.4.tar.gz
tar -zxvf 2.4.tar.gz
cd ip4r-2.4
env USE_PGXS=1 make
env USE_PGXS=1 make install
进入数据库,并创建extension
Psql -U postgres
create extension ip4r;
dx ip4r