linux安装Postgres12及Hasura GraphQL引擎

1、postgres官网选择对应的版本,按照步骤安装。

linux安装Postgres12及Hasura GraphQL引擎_第1张图片

安装插件

yum -y install postgresql12-contrib

 

2、修改配置文件,开放外部网络访问

修改postgresql.conf

修改:#listen_addresses = 'localhost'为listen_addresses = '*'

 

linux安装Postgres12及Hasura GraphQL引擎_第2张图片

修改pg_hba.conf

修改前

linux安装Postgres12及Hasura GraphQL引擎_第3张图片

修改后

linux安装Postgres12及Hasura GraphQL引擎_第4张图片

重新启动

systemctl restart postgresql-12

设置密码

su postgres              #不能使用root用户登录,切换到普通用户

\password                #设置用户密码

select version();        #查看版本

linux安装Postgres12及Hasura GraphQL引擎_第5张图片
 

测试登录

linux安装Postgres12及Hasura GraphQL引擎_第6张图片

 

3、设置Hasura专属用户及权限,执行sql

-- schemas and information_schema and pg_catalog
-- These permissions/grants are required for Hasura to work properly.

-- create a separate user for hasura
CREATE USER hasurauser WITH PASSWORD 'hasurauser';

-- create pgcrypto extension, required for UUID
CREATE EXTENSION IF NOT EXISTS  pgcrypto;

-- create the schemas required by the hasura system
-- NOTE: If you are starting from scratch: drop the below schemas first, if they exist.
CREATE SCHEMA IF NOT EXISTS hdb_catalog;
CREATE SCHEMA IF NOT EXISTS hdb_views;

-- make the user an owner of system schemas
ALTER SCHEMA hdb_catalog OWNER TO hasurauser;
ALTER SCHEMA hdb_views OWNER TO hasurauser;

-- grant select permissions on information_schema and pg_catalog. This is
-- required for hasura to query list of available tables
GRANT SELECT ON ALL TABLES IN SCHEMA information_schema TO hasurauser;
GRANT SELECT ON ALL TABLES IN SCHEMA pg_catalog TO hasurauser;

-- Below permissions are optional. This is dependent on what access to your
-- tables/schemas - you want give to hasura. If you want expose the public
-- schema for GraphQL query then give permissions on public schema to the
-- hasura user.
-- Be careful to use these in your production db. Consult the postgres manual or
-- your DBA and give appropriate permissions.

-- grant all privileges on all tables in the public schema. This can be customised:
-- For example, if you only want to use GraphQL regular queries and not mutations,
-- then you can set: GRANT SELECT ON ALL TABLES...
GRANT USAGE ON SCHEMA public TO hasurauser;
GRANT ALL ON ALL TABLES IN SCHEMA public TO hasurauser;
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO hasurauser;

-- Similarly add this for other schemas, if you have any.
-- GRANT USAGE ON SCHEMA TO hasurauser;
-- GRANT ALL ON ALL TABLES IN SCHEMA TO hasurauser;
-- GRANT ALL ON ALL SEQUENCES IN SCHEMA TO hasurauser;

 

4、从镜像启动hasura

docker run -d -p 8181:8080 \
  -e HASURA_GRAPHQL_DATABASE_URL=postgres://username:password@host:5432/postgres \
  -e HASURA_GRAPHQL_ENABLE_CONSOLE=true \

 -e HASURA_GRAPHQL_CONSOLE_ASSETS_DIR=/srv/console-assets \
  hasura/graphql-engine:latest

5、测试连接

localhost:8181/console

 

linux安装Postgres12及Hasura GraphQL引擎_第7张图片

6、安装postgis

安装存储库RPM:

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

安装PostGis

yum install postgis30_12

加载postgis

-- Enable PostGIS (as of 3.0 contains just geometry/geography)
CREATE EXTENSION postgis;
-- enable raster support (for 3+)
CREATE EXTENSION postgis_raster;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- Enable PostGIS Advanced 3D
-- and other geoprocessing algorithms
-- sfcgal not available with all distributions
CREATE EXTENSION postgis_sfcgal;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- rule based standardizer
CREATE EXTENSION address_standardizer;
-- example rule data set
CREATE EXTENSION address_standardizer_data_us;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;

 

你可能感兴趣的:(linux安装Postgres12及Hasura GraphQL引擎)