Download presentation
Presentation is loading. Please wait.
Published byNelson Lambert Modified over 9 years ago
1
PostgreSQL Installation By: Keerthi Nelaturu knela006@uottawa.ca Previous version by Ahmed Jeddah & Miguel Garzon
2
Presentation Overview Prerequisite packages Connecting to SITE’s LINUX Server Some basic UNIX commands PostgreSQL Installation PgAdmin III Installation
3
Prerequisite packages SSH: http://www.ccs.uottawa.ca/download/ssh/ssh329.exe http://www.ccs.uottawa.ca/download/ssh/ssh329.exe click on the exe file and follow the instructions PostgreSQL: http://www.postgresql.org/ftp/source/v8.1.4 choose the file postgresql-8.1.4.tar.gz (The version we will be using is ver 8.1.4) pgAdmin III: http://www.postgresql.org/ftp/pgadmin3/release/v1.8.4/win 32/ http://www.postgresql.org/ftp/pgadmin3/release/v1.8.4/win 32/ choose the.zip file This is only needed if you want to work in your own pc!
4
Connecting to SITE’s LINUX Server On-Campus: (FTP Server) 1- go to Programs-> SSH Secure Shell -> Secure File Transfer Client --- then click on Quick Connect
5
Connecting to SITE’s LINUX Server Continue: 2- In the host name field : linux.site.uottawa.ca, in the user name field : your site email alias The password: site account password (remember the Autopass)
6
Connecting to SITE’s LINUX Server Go to Programs-> SSH Secure Shell -> Secure Shell Client --- then click on Quick Connect Host name : linux.site.uottawa.ca User name : site email alias Password : site account password
7
Connecting to SITE’s LINUX Server Connecting Off-Campus -- for connecting to the Secure File Transfer – follow the same steps but Host name: ugate.site.uottawa.ca --for connecting to the Secure Shell – follow the same steps but Host name: ugate.site.uottawa.ca – and then, type: ssh linux.site.uottawa.ca (the server will then ask for a password – it is the same as the site account password) See for more details http://www.site.uottawa.ca/local/labinfo/unix.shtml#2 http://www.site.uottawa.ca/local/labinfo/unix.shtml#2
8
Some basic UNIX commands pwd : show the full name of the current directory. – Note that in Unix; we use “/” in the file name description – while in windows we use “\” mkdir: create a new directory – e.g. mkdir new_folder Note 1: in Unix; Do NOT name directories with a space in them (i.e. A folder called My Documents will cause some problems). Note 2: Unix is case sensitive for commands and files– i.e. Mkdir new_folder is wrong statment
9
Some basic UNIX commands ls (list files in the current directory) cd ( current directory) – Examples: – cd new_folder (will go to the folder called new_folder) – cd ( return to your home directory) – cd.. (will go to the parent directory) – Hint: You can use “Tab” when writing the names of directories – it is as Auto Complete !
10
Some basic UNIX commands cp : copy a file (or folder) – cp source destination Figure out how it work for folders!! Try typing cp --help to get some help !! mv : move a file – mv file1 file2 (will move the contents of file1 to file2 – file1 no more exist)
11
Some basic UNIX commands Removing files and directories: – rmdir: (remove directory) Note: rmdir cannot remove directory that is not empty – rm: (remove file) – Examples: rm file1 rm Directory1 ----- Error message: Directory1 is a directory rm --help --- show the documentation of command rm rm –r Directory1 -- No error message (works for files and folders – (Q. What does –r do ?!) rm –rf File == rm –r –f File --- (Q. What does –f do ?!) Other Commands – clear : clear the screen – history: display the history of commands
12
Some basic UNIX commands Compiling a c source code in Linux; – There exist many c compilers: GCC – LCC – PCC – TenDRA. – We are going to use GCC – We don’t need to install it now, it is already there !
13
Some basic UNIX commands Compiling C code #include int main(void) { printf("First file \n"); printf("Hello World \n"); return 0; } Write the following code and save it in hello.c
14
Some basic UNIX commands cd c // c is the directory where hello.c resides gcc hello.c ls // you will find a file called a.out./a.out // run executable file./a.out -bash-3.2$./a.out First file Hello World -bash-3.2$
15
Some basic UNIX commands We are not restricted to the file a.out; The statement: gcc hello.c –o b.out will generate the executable file b.out instead, “type gcc -- help for some more useful options;”
16
Some basic UNIX commands Makefile and the make command We can write many commands in a script file and run it all at once; For example: all: gcc hello.c –o b.out mkdir –p x mv b.out x 1) Write the previous commands in a file called Makefile-1.txt; (in the same directory of hello.c); 2) Type the command: make -f Makefile-1.txt Q1. What do this script do ? Q2. What does the –p in mkdir do ?
17
all: createFolder first: gcc hello.c -o b.out./b.out # *** File hello.c Compiled and executed *** createFolder: rm -rf newfolder mkdir newfolder second: gcc second.c./a.out # *** File calculations.c Compiled and executed *** clean: rm -rf *.out rm -rf newfolder Try these examples and observe the output: make –f makefile-5.txt make –f makefile-5.txt first make –f makefile-5.txt clean make –f makefile-5.txt second make –f makefile-5.txt all More options in MakeFile
18
Rename Makefile-5.txt to Makefile and then run make ; i.e. make all ; make clean ; make first etc... The default file that make look for is Makefile IMPORTANT NOTE: Makefile has NO extension; it is a UNIX file
19
More options in MakeFile Makefile may be more intelligent and powerful. We may have variables; Or we may also use if-else statements (see link: – http://mrbook.org/tutorials/make/ (introduction) http://mrbook.org/tutorials/make/ – http://theory.uwinnipeg.ca/gnu/make/make_toc. html (more advanced) http://theory.uwinnipeg.ca/gnu/make/make_toc. html
20
Installing PostgreSQL 1.Have the file postgresql-8.1.4.tar.gz in your base file (i.e. home/infofa/h/users/you_user_name ) 2.Type gzip –d postgresql- 8.1.4.tar.gz 3.Type tar -xvf postgresql- 8.1.4.tar (Extraction) 3. cd postgresql- 8.1.4
21
Installing PostgreSQL 4)./configure --prefix=PREFIX --enable- debug –enable-depend Replace PREFIX with the name of the folder you want to install PostgreSQL in; (i.e. /home/infofa/h/users/mgarz042/ postgresql- 8.1.4 /pgs) --enable-debug and –enable-depend are optional will be useful for the project
22
Installing PostgreSQL 5) gmake // or you may use make “Note” gmake has the same function as make; however; the default file in this case is GNUmakefile make, in this case, points to gmake (Read the file Makefile – intersting) Wait for this message: All of PostgreSQL successfully made. Ready to install.
23
Installing PostgreSQL 6) gmake check This step performs some testing before the installation Expect something like that: ======================= All 114 tests passed. =======================
24
Installing PostgreSQL 7) gmake install We are done if we see; PostgreSQL installation complete.
25
Installing PostgreSQL 8) Go to directory where you installed PostgreSQL (i.e. PREFIX) cd pgs 9) cd bin 10)./initdb –D../data Success. You can now start the database server using:./postgres -D../data or./pg_ctl -D../data -l logfile start
26
Installing PostgreSQL 11) Start the server side of the database with./postgres –D../data if Error: LOG: could not bind IPv4 socket: Address already in use HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. WARNING: could not create listen socket for "localhost" FATAL: could not create any TCP/IP sockets then:./postgres –D../data –p xxxx // xxxx is any number
27
Installing PostgreSQL DONE !!! You may expect a message like this: LOG: database system was shut down at 2008-10-21 23:34:14 EDT LOG: autovacuum launcher started LOG: database system is ready to accept connections
28
Not Done Yet ! - Open a new terminal window in SSH Secure Shell -Type in the client side:./psql postgres –p xxxx where xxxx is the same port number of the server side
29
DONE !!! Welcome to psql 8.3.4, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit postgres=# Now, you can write your SQL quiries !
30
SQL Commands Example of SQL commands; create table products (pnum int, pname varchar(20), price real); insert into products (pnum, pname, price) values (12, ‘coke’, 1.25); insert into products (pnum, pname, price) values (13, ‘burger’, 5.99); Insert into products (pnum, pname, price) values (551, ‘coffee’, 1.18); Select * from products ; Etc..
31
Installing PgAdmin III Unzip the file pgadmin3-1.8.4.zip Follow instructions. This is the same port number the database server is listening to
32
More configurations on PostgreSQL To connect pgAdmin with PostgreSql: – Go to the directory where the files of the database are located (i.e. in our case: /home/infofa/h/users/ajedd07/postgresql-8.3.4 /data) -Look for #listen_addresses = 'localhost‘ in file postgresql.conf ; change it with listen_addresses = ‘*‘ -At the end of the file pg_hba.conf; add the line host all all 137.122.93.0/32 trust Unfortunatley, even with these changes, pgAdmin can not connect to the database serever from off-campus
33
References PostgreSQL Documentations http://www.postgresql.org/docs/manuals/ http://www.postgresql.org/docs/manuals/ pgAdmin III Documentations http://www.pgadmin.org/docs/1.8/index.html Unix commands http://mally.stanford.edu/~sr/computing/basic-unix.html A good reference for c and c++ http://www.cprogramming.com/http://www.cprogramming.com/ PostgreSQL for developpers (useful for the next lectures) http://www.postgresql.org/developer/coding
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.