about summary refs log tree commit diff stats
path: root/tools/postgresql.html
diff options
context:
space:
mode:
authorSilvino Silva <silvino@bk.ru>2016-09-29 05:21:34 +0100
committerSilvino Silva <silvino@bk.ru>2016-09-29 05:21:34 +0100
commit81d7c7820c25cdca723bbe7c13a3657174904b70 (patch)
tree984cd63c11d252b82a55901be38cb66a53cfc4f7 /tools/postgresql.html
parent17bc450495c9ab6933590fb825dbd80b0af64a66 (diff)
downloaddoc-81d7c7820c25cdca723bbe7c13a3657174904b70.tar.gz
postgresql revision
Diffstat (limited to 'tools/postgresql.html')
-rw-r--r--tools/postgresql.html165
1 files changed, 75 insertions, 90 deletions
diff --git a/tools/postgresql.html b/tools/postgresql.html
index e160ae2..b8790e2 100644
--- a/tools/postgresql.html
+++ b/tools/postgresql.html
@@ -11,53 +11,22 @@
         <h1>Postgresql</h1>
 
 
-        <h2 id="install">1.1. Install Postgresql</h2>
+        <h2 id="install">1. Install Postgresql</h2>
 
-        <pre>
-        $ prt-get depinst postgresql
-        </pre>
-
-        <p>Mount Point;</p>
-
-        <pre>
-        # mkdir -p /srv/pgsql
-        # mount /srv/pgsql
-        </pre>
-
-        <p>Create user;</p>
-
-        <pre>
-        # useradd -U -m -d /srv/pgsql -s /bin/false postgres
-        useradd: warning: the home directory already exists.
-        Not copying any file from skel directory into it.
-        </pre>
+        <p>Install postgresql;</p>
 
         <pre>
-        # passwd -l postgres
-        passwd: password expiry information changed.
-        # touch /var/log/pgsql
-        # chown -R postgres:postgres /srv/pgsql /var/log/pgsql
-        # ldconfig /user/lib/postgresql
-		</pre>
-
-        $ sudo -u postgres mkdir -p /srv/pgsql/data
-        # sudo -u postgres touch /srv/pgsql/.psql_history
+        $ prt-get depinst postgresql
         </pre>
 
-        <p>Create /etc/logrotate.d/postgres;</p>
-
         <pre>
-        /var/log/pgsql {
-            weekly
-            compress
-            delaycompress
-            rotate 10
-            notifempty
-            create 660 postgres postgres
-        }
+        # mkdir /srv/pgsql/
+        # touch /var/log/postgresql
+        # chown postgres:postgres /srv/pgsql /var/log/postgresql
+        # sudo -u postgres initdb -D /srv/pgsql/data
         </pre>
 
-        <p>Edit /etc/rc.d/postgresql;</p>
+        <p>Change <a href="conf/etc/rc.d/postgresql">/etc/rc.d/postgresql</a>;</p>
 
         <pre>
         #
@@ -65,25 +34,20 @@
         #
 
         PG_DATA=/srv/pgsql/data
-        PG_HOME=/srv/pgsql
 
         case "$1" in
-        start|stop|status|restart|reload)
-                (cd $PG_HOME && sudo -u postgres pg_ctl -D "$PG_DATA" -l /var/log/pgsql "$1")
-        ;;
-        *)
-        echo "usage: $0 start|stop|restart|reload|status"
-        ;;
+            start|stop|status|restart|reload)
+                sudo -u postgres pg_ctl -D "$PG_DATA" -l /var/log/postgresql "$1"
+                ;;
+            *)
+                echo "usage: $0 start|stop|restart|reload|status"
+                ;;
         esac
 
         # End of file
         </pre>
 
-        <h2 id="config">1.2. Configure Server</h2>
-
-        <pre>
-        # sudo -u postgres initdb -D /srv/pgsql/data
-        </pre>
+        <h2 id="config">2. Configure Server</h2>
 
         <p>Create password for super user;</p>
 
@@ -92,17 +56,9 @@
         $ psql -U postgres
         </pre>
 
-        <p>Edit /pgsql/data/<a href="../conf/srv/pgsql/data/postgresql.conf">postgresql.conf</a>;</p>
-
-        <pre>
-        log_destination = 'syslog' # Can specify multiple destinations
-        syslog_facility='LOCAL0'
-        syslog_ident='postgres'
-        log_connections = on
-        password_encryption=on
-        </pre>
-
-        <p>Edit /srv/pgsql/data/<a href="../conf/srv/pgsql/data/pg_hba.conf">pg_hba.conf</a>;</p>
+        <p>Edit
+        <a href="conf/srv/pgsql/data/pg_hba.conf">/srv/pgsql/data/pg_hba.conf</a>;
+        </p>
 
         <pre>
         # TYPE  DATABASE        USER            ADDRESS                 METHOD
@@ -121,62 +77,89 @@
         #host    replication     postgres        ::1/128                 trust
         </pre>
 
+        <p>Start server and alter postgres password</p>
+
+        <pre>
+        # /etc/rc.d/postgresql start
+        </pre>
+
+        <pre>
+        postgres=# alter user postgres with password 'new_password';
+        </pre>
+
+        <h3 id="syslog">2.1. Configure syslog-ng</h3>
+
         <p><a href="syslog-ng.html">Configure Syslog-ng</a>, check <a href="http://michael.otacoo.com/postgresql-2/postgres-settings-simple-syslog-configuration-with-syslog-ng/">Michael at otacoo</a> article. Example;</p>
 
+        <p>Edit /pgsql/data/<a href="../conf/srv/pgsql/data/postgresql.conf">postgresql.conf</a>;</p>
+
         <pre>
-        destination postgres { file("/var/log/pgsql"); };
-        filter f_postgres { facility(local0); };
-        log { source(s_log); filter(f_postgres); destination(postgres); };
+        log_destination = 'syslog' # Can specify multiple destinations
+        syslog_facility='LOCAL0'
+        syslog_ident='postgres'
+        log_connections = on
+        password_encryption=on
         </pre>
 
-        <p>Start server and alter postgres password</p>
+
+        <p>Create /etc/logrotate.d/postgres;</p>
 
         <pre>
-        # /etc/rc.d/postgresql start
+        /var/log/pgsql {
+            weekly
+            compress
+            delaycompress
+            rotate 10
+            notifempty
+            create 660 postgres postgres
+        }
         </pre>
 
+
         <pre>
-        postgres=# alter user postgres with password 'new_password';
+        destination postgres { file("/var/log/pgsql"); };
+        filter f_postgres { facility(local0); };
+        log { source(s_log); filter(f_postgres); destination(postgres); };
         </pre>
 
-        <h2 id="createuser">1.3. Create User</h2>
+
+        <h2 id="createuser">3. Create User</h2>
 
         <p>Create a new user with createuser command;</p>
 
         <pre>
         $ sudo -u postgres createuser --pwprompt --encrypted \
-        --no-createrole --no-createdb laravel_user
+        --no-createrole --no-createdb flyspray
         Enter password for new user:
         Enter it again:
         </pre>
 
-        <h2 id="createdb">1.4. Create Database</h2>
+        <h2 id="createdb">4. Create Database</h2>
 
         <p>Create a new database for new user with createdb command;</p>
 
         <pre>
         $ sudo -u postgres createdb --template=template0 --encoding=UTF8 \
-        --owner=laravel_user laravel_db
+        --owner=flyspray db_flyspray
         </pre>
 
-        <h2 id="dropdb">1.5. Drop Database</h2>
+        <h2 id="dropdb">5. Drop Database</h2>
 
         <p>Deleting database with dropdb command;</p>
 
         <pre>
-        sudo -u postgres dropdb laravel_db
+        sudo -u postgres dropdb db_flyspray
         </pre>
 
-        <h2 id="dropuser">1.6. Drop User</h2>
+        <h2 id="dropuser">6. Drop User</h2>
 
         <p>Deleting user with dropuser command;</p>
 
         <pre>
-        sudo -u postgres dropuser laravel_user
+        sudo -u postgres dropuser flyspray
         </pre>
 
-
-        <h2 id="psql">1.7. Psql</h2>
+        <h2 id="psql">7. Psql</h2>
 
         <p>Lets check with psql, login with user postgres;</p>
 
@@ -190,7 +173,7 @@
         postgres=# \?
         </pre>
 
-        <h3 id="listdb">Psql - List Databases and Roles</h3>
+        <h3 id="listdb">7.1. List Databases and Roles</h3>
 
         <p>List roles then list databases;</p>
 
@@ -199,39 +182,43 @@
         postgres=# \l
         </pre>
 
-        <h3 id="psqldb">Psql - Create Database</h3>
+        <h3 id="psqldb">7.2. Create Database</h3>
 
         <pre>
-        postgres=# create database laravel_db_ext owner laravel_user encoding 'UTF-8' template template0;
+        postgres=# create database db_flyspray_ext owner flyspray encoding 'UTF-8' template template0;
         </pre>
 
-        <h3 id="droptables">Psql - Drop Tables</h3>
+        <h3 id="droptables">7.3. Drop Tables</h3>
 
         <p>This example assumes that all tables,
         are in public schema. First connect to database and
         list tables;</p>
 
         <pre>
-        postgres=# \c laravel_db
+        postgres=# revoke SELECT on db_flyspray from flyspray;
+        </pre>
+
+        <pre>
+        postgres=# \c db_flyspray
         postgres=# \dt
         </pre>
 
         <p>Drop all tables on public schema and recreate public schema;</p>
 
         <pre>
-        laravel_db=# drop schema public cascade;
-        laravel_db=# create schema public;
+        db_flyspray=# drop schema public cascade;
+        db_flyspray=# create schema public;
         </pre>
 
-        <h3 id="backup">Backup</h3>
+        <h3 id="backup">7.4. Backup</h3>
 
 
         <p>Backup Database</p>
 
-        <h3 id="backup">Restore</h3>
+        <h3 id="backup">7.5. Restore</h3>
 
         <pre>
-        $ psql laravel_db &lt; database_dump
+        $ psql db_flyspray &lt; database_dump
         </pre>
 
         <a href="index.html">Tools Index</a>
@@ -242,7 +229,5 @@
         See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
         for copying conditions.</p>
 
-
-
     </body>
 </html>