This document describes how to build and install PGroonga from source.
Build and install instruction is different between on Windows and on non Windows. This document describes it separately.
Install PostgreSQL.
Install Groonga. We recommend that you use package. If you use package to install Groonga, install the following package:
groonga-devel
: on CentOSlibgroonga-dev
: on Debian/GNU Linux and UbuntuExtract PGroonga source:
% wget https://packages.groonga.org/source/pgroonga/pgroonga-3.2.4.tar.gz
% tar xvf pgroonga-3.2.4.tar.gz
% cd pgroonga-3.2.4
FYI: If you want to use the unreleased latest version, use the followings:
% git clone --recursive https://github.com/pgroonga/pgroonga.git
% cd pgroonga
Build PGroonga. There are some options:
HAVE_MSGPACK=1
: It's required for WAL support. You need msgpack-c 1.4.1 or later. You can use libmsgpack-dev
package on Debian based platform and msgpack-devel
package in EPEL on CentOS 7.Use the following command line when you want to build with WAL support:
% make HAVE_MSGPACK=1
Use the following command line when you don't need WAL support:
% make
If you get any error, confirm the followings:
pg_config
command exists at any path in PATH
environment variable.pkg-config --list-all
includes groonga
.If pg_config
command doesn't exist, you may forget to install the development package of PostgreSQL.
If pkg-config --list-all
doesn't include groonga
, you may forget to install the development package of Groonga. Or groonga.pc
is installed into non-standard directory. You can use PKG_CONFIG_PATH
environment variable for the case.
Here is an example when you install Groonga with --prefix=/usr/local
:
% PKG_CONFIG_PATH=/usr/local/lib/pkgconfig make
Install PGroonga:
% sudo make install
If you use SELinux, you must create a policy package(.pp) and install it. PGroonga makes PostgreSQL map <data dir>/pgrn*
files into memory, which is not allowed by default. First, install policycoreutils
and checkpolicy
.
% sudo dnf install policycoreutils checkpolicy
Let's assume that PostgreSQL binaries are of type postgresql_t
and PostgreSQL data files are of type postgresql_db_t
. Allow postgresql_t
type to memory map files of type postgresql_db_t
. Then compile it (.mod), package it (.pp) and install the resulting policy package.
% cat > my-pgroonga.te << EOF
module my-pgroonga 1.0;
require {
type postgresql_t;
type postgresql_db_t;
class file map;
}
allow postgresql_t postgresql_db_t:file map;
EOF
% checkmodule -M -m -o my-pgroonga.mod my-pgroonga.te
% semodule_package -o my-pgroonga.pp -m my-pgroonga.mod
% sudo semodule -i my-pgroonga.pp
Create a database:
% psql --command 'CREATE DATABASE pgroonga_test'
(Normally, you should create a user for pgroonga_test
database and use the user. See GRANT USAGE ON SCHEMA pgroonga
for details.)
Connect to the created database and execute CREATE EXTENSION pgroonga
:
% psql -d pgroonga_test --command 'CREATE EXTENSION pgroonga;'
That's all!
Try tutorial. You can understand more about PGroonga.
Here is a list of required software to build and install PGroonga from source. Install them:
PostgreSQL (You can choose installer version or zip version.)
Download PGroonga source archive for Windows from packages.groonga.org. Source archive for Windows is zip file. Source archive for Windows bundles Groonga.
Extract the downloaded source archive and move to source folder:
> cd c:\Users\%USERNAME%\Downloads\pgroonga-3.2.4
Specify build option by cmake
. The following command line is for building PGroonga for 64bit version PostgreSQL. If you want to build for 32bit version PostgreSQL, use -G "Visual Studio 12 2013"
parameter instead:
pgroonga-3.2.4> cmake . -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=%POSTGRESQL_INSTALL_FOLDER% -DGRN_WITH_BUNDLED_LZ4=yes -DGRN_WITH_BUNDLED_MECAB=yes -DGRN_WITH_BUNDLED_MESSAGE_PACK=yes -DGRN_WITH_MRUBY=yes
If you installed PostgreSQL by installer, %POSTGRESQL_INSTALL_FOLDER%
is C:\Program Files\PostgreSQL\%POSTGRESQL_VERSION%
.
If you installed PostgreSQL by zip, %POSTGRESQL_INSTALL_FOLDER%
is %POSTGRESQL_ZIP_EXTRACTED_FOLDER%\pgsql
.
Build PGroonga:
pgroonga-3.2.4> cmake --build . --config Release
Install PGroonga. You may be required administrator privilege. For example, you installed PostgreSQL by installer, you will be required administrator privilege.
pgroonga-3.2.4> cmake --build . --config Release --target Install
Create a database:
postgres=# CREATE DATABASE pgroonga_test;
(Normally, you should create a user for pgroonga_test
database and use the user. See GRANT USAGE ON SCHEMA pgroonga
for details.)
Connect to the created database and execute CREATE EXTENSION pgroonga
:
postgres=# \c pgroonga_test
pgroonga_test=# CREATE EXTENSION pgroonga;
That's all!
Try tutorial. You can understand more about PGroonga.