在docker和物理机里安装ip4r插件

注意: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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值