Saturday, February 9, 2013

MANAGING USERS AND PERMISSIONS IN POSTGRESQL AND POSTGIS

MANAGING USERS AND PERMISSIONS IN POSTGRESQL AND POSTGIS

Table of Contents

Create Users. 2

Create Schema (Optional). 2

Grant USAGE and CREATE on the schema to the user. 2

Grant USAGE permissions on the schema (s). 3

Group Roles. 3

Assign Users to the Roles. 3

Enable Inherit Group Priviledges. 3

Work with Spatial Types. 3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Create Users

 

#Grant USAGE and CREATE on the schema to the user.

#Log into PL/SQL as a user with permissions to create other roles in the DBMS. This is usually the #postgres super user.

 

#Execute the CREATE ROLE command in PL/SQL.

#      For example:

 

CREATE ROLE user1 LOGIN ENCRYPTED PASSWORD 'user1' NOSUPERUSER NOINHERIT CREATEDB NOCREATEROLE;

CREATE ROLE user2LOGIN ENCRYPTED PASSWORD 'dmuthami' NOSUPERUSER NOINHERIT CREATEDB NOCREATEROLE;

Create Schema (Optional)

 

#Execute the CREATE SCHEMA command to create a schema for the user in the database where the #geodatabase is stored.

#      For example:

#database of interest now is cso

 

CREATE SCHEMA user1 AUTHORIZATION user1;

CREATE SCHEMA user2AUTHORIZATION user1;

 

Grant USAGE and CREATE on the schema to the user.

#This is required to allow the user to create log file tables. See ArcSDE log file table #configuration options for PostgreSQL for more information on log file tables.

GRANT USAGE ON SCHEMA user1 TO user1;

GRANT CREATE ON SCHEMA user1 TO user1;

GRANT USAGE ON SCHEMA user2TO dmuthami;

GRANT CREATE ON SCHEMA user2TO dmuthami;

Grant USAGE permissions on the schema (s)

#Grant USAGE permissions on the schema to any other role or group that needs to access the data in #the user's schema.

#In this example, USAGE is granted to the Public group.

 

GRANT USAGE ON SCHEMA user1 TO public;

GRANT USAGE ON SCHEMA user2TO public;

Group Roles

#If you want to place the user in a group to control permissions, create another role to be used #as a group.

#For example, you might create a group for all users creating data in the geodatabase.

 

CREATE ROLE dataownersgroup NOSUPERUSER NOINHERIT CREATEDB NOCREATEROLE;

Assign Users to the Roles

#Grant the group (user1) privileges to the role (role4u).

GRANT dataownersgroup TO user1;

GRANT dataownersgroup TO dmuthami;

Enable Inherit Group Priviledges

#Enable the role (user1) to inherit group privileges from the groups to which it is assigned.

ALTER ROLE user1 INHERIT;

ALTER ROLE user2INHERIT;

Work with Spatial Types

#If you are using groups, you can grant permissions on other datasets to the group. If not, grant permissions to individual login #roles.

#In this example, the dataowner group is granted permission on the geometry_columns and spatial_ref_sys tables in the public schema. #These permissions are required for any users who create data that uses PostGIS geometry storage.

GRANT SELECT, INSERT, UPDATE, DELETE ON public.geometry_columns TO dataownersgroup;

GRANT SELECT ON public.spatial_ref_sys TO dataownersgroup;

GRANT SELECT ON public.geography_columns TO dataownersgroup;

GRANT SELECT ON public.raster_columns TO dataownersgroup;

GRANT SELECT ON public.raster_overviews TO dataownersgroup;

Friday, August 31, 2012

GIS Republic: Installing & Configuring PostgreSQL + PostGIS in U...

GIS Republic: Installing & Configuring PostgreSQL + PostGIS in U...: Installing & Configuring PostgreSQL + PostGIS in Ubuntu 12.XX Installation Launch Terminal Open Terminal. Use Ctrl+Alt+T key c...

Installing & Configuring PostgreSQL + PostGIS in Ubuntu 12.XX



Installing & Configuring PostgreSQL + PostGIS in Ubuntu 12.XX

Installation

Launch Terminal

Open Terminal. Use Ctrl+Alt+T key combination                         
















install python-software-properties. Type the command below in the terminal

sudo apt-get install python-software-properties








Add PPA repository to my Ubuntu.

Type the command below in the terminal
sudo add-apt-repository ppa:pitti/postgresql



 








Update the System

After adding PPA, update your system apt:
Type the command below in the terminal
                sudo apt-get update

















Finally install postgresql-9.X:

Type the command below;
sudo apt-get install postgresql












A successful installation

Configuring postgresql.conf to use port 5432...

update-alternatives: using /usr/share/postgresql/9.1/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.

 * Starting PostgreSQL 9.1 database server                      [ OK ]

Setting up postgresql (9.1+134~precise) ...


if you having any error, make sure you already install libpq-dev. The libpq-dev package is for compiling wrappers/clients against libpq.

Install libpq-dev package


$sudo apt-get install postgresql-9.1 libpq-dev


 

 

 

 

 











Wednesday, August 22, 2012

APACHE 2 + TOMCAT 7 + GEOSERVER



Installing Tomcat 7 and Apache2 with mod_jk on Ubuntu 12.04 or linode a cloud platform powered on linux distros


This is a tutorial on how to install Tomcat and Apache2, and then configure to connect the Apache Web Server to Tomcat using mod_jk and then drop a war file for geoserver.
Login as root in the LINODE instance by issuing the following commands

su root

A password prompt appears prompting you to supply the password. Issue the following command to install Apache:

apt-get install apache2













Test the installation from the browser using http://localhost/

apt-get install tomcat7
apt-get install tomcat7-admin


Issue the following command

apt-get install libapache2-mod-jk

First lets enable the redirect port 8443 on Tomcat by issuing the following command

vim /etc/tomcat7/server.xml

and uncomment the following line

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />











Now we will create our workers.properties file for Apache. 

vim /etc/apache2/workers.properties

Copy and paste the text below;

# Define 1 real worker using ajp13
worker.list=worker1, worker2
# Set properties for worker (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

# Define second  real worker using ajp13
# Set properties for worker (ajp13)
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8010
















Issue the command to save and quit

:wq

Ask Apache to use this worker 

vim /etc/apache2/mods-available/jk.conf

Change the JkWorkersFile property to;

/etc/apache2/workers.properties















Finally configure the URL so that Apache web server should pass through to Tomcat servlet requests

vim /etc/apache2/sites-enabled/000-default

and add the following line in your opened file in the terminal

<VirtualHost *:80>
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
JkMount /apps* worker1
JkMount /geoserver* worker2
</VirtualHost *:80>


















Now, restart the servers

/etc/init.d/tomcat7 restart
/etc/init.d/apache2 restart



Download a web archive file (*.war) from GeoServer downloads

Copy file to Tomcat7 Directory root folder

cp /home/administrator/Downloads/geserver-2.1.4.zip  /var/lib/tomcat7/webapps

Unzip the file by issuing the below command in the terminal.

unzip geoserver-2.1.4.zip

Immediately, your geoserver-2.1.4.war file is exploded by tomcat7 into a folder.The folder is called GeoServer. Test GeoServer by typing on your browser http://localhost/geoserver. An example can be shown from this link.