Postgresql9.4.4 Install&Configure

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:510

[color=#4f81bd][font=Cambria][size=18px]1.Download software
[root@test1 local]# wget http://ftp.postgresql.org/pub/source/v9.4.4/postgresql-9.4.4.tar.bz2
[color=#4f81bd][font=Cambria][size=18px]2.Check isnot install
[root@test1 ~]# ps -ef|grep pgsql
root 2879728412 0 16:40 pts/1 00:00:00 grep pgsql
[color=#4f81bd][font=Cambria][size=18px]3.tar software
[root@test1 local]# tar xjf postgresql-9.4.4.tar.bz2
[color=#4f81bd][font=Cambria][size=18px]4.Compile
[root@test1 local] # cd postgresql-9.4.4
[root@test1 postgresql-9.4.4] # ./configure
[root@test1 postgresql-9.4.4] #gmake
[root@test1 postgresql-9.4.4] # gmake install
[color=#4f81bd][font=Cambria][size=18px]5.Create group and user
[root@test1 local]# groupadd -g 101 dba
[root@test1 local]# useradd -u 515 -g dba -G root -d /usr/local/pgsql postgres
[root@test1 local]# id postgres
uid=515(postgres) gid=101(dba) groups=101(dba),0(root)
[root@test1 local]# passwd postgres
Changing password for user mysqladmin.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@test1 local]#
## if user mysqladmin is existing,please execute thefollowing command of usermod.
##[root@test1 local]# usermod -u 514 -g dba -G root -d/usr/local/mysql mysqladmin #

[root@test1 local]# cp /etc/skel/.* /usr/local/pgsql ###important
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
[color=#4f81bd][font=Cambria][size=18px]6.Create data and .psql_history
[root@test1 ~]#mkdir /usr/local/pgsql/data
[root@test1 ~]#mkdir /usr/local/pgsql/.psql_history
[color=#4f81bd][font=Cambria][size=18px]7.Configure .bash_profile
[root@test1 ~]# vi /usr/local/pgsql/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

exportPGHOME=/usr/local/pgsql

exportPGDATA=/usr/local/pgsql/data

exportPATH=$PATH:/usr/local/pgsql/bin

#sttyerase ^H
setumask to 022
umask022
PS1=`uname-n`":"'$USER'":"'$PWD'":>"; export PS1
[color=#4f81bd][font=Cambria][size=18px]8.Chmod and chown
[root@test1 ~]#chmod –R 755 /usr/local/pgsql
[root@test1 ~]#chown –R postgres:dba /usr/local/pgsql
[color=#4f81bd][font=Cambria][size=18px]9.Configure postgresql service and boot auto start
[root@test1 ~] # cd /usr/local/ postgresql-9.4.4
[root@test1 postgresql-9.4.4] # cp contrib/start-scripts/linux /etc/init.d/postgresql
[root@ test1 postgresql-9.4.4]# chmod +x /etc/init.d/postgresql
[root@ test1 postgresql-9.4.4]# chkconfig --del postgresql
[root@ test1 postgresql-9.4.4]# chkconfig --add postgresql
[root@ test1 postgresql-9.4.4]# chkconfig postgresql on
[color=#4f81bd][font=Cambria][size=18px]10.init db
[root@test1 ~]#
[root@test1 ~]# sudo su postgres
bash-3.2$ cd
bash-3.2$ pwd
/usr/local/pgsql
bash-3.2$ ..bash_profile
test1.localdomain:postgres:/usr/local/pgsql:> /usr/local/pgsql/bin/initdb -D/usr/local/pgsql/data/
[color=#4f81bd][font=Cambria][size=18px]10.login and create db test and create table test
test1.localdomain:postgres:/usr/local/pgsql:>created test
test1.localdomain:postgres:/usr/local/pgsql:>psql test
psql (9.4.4)
Type "help" for help.
test=# createtable test(id int);
CREATE TABLE
test=# \dt
List ofrelations
Schema | Name |Type | Owner
--------+------+-------+----------
public | test | table| postgres
(1 row)

test=# insertinto test values(1);
INSERT 0 1
test=# select* from test;
id
----
1
(1 row)

test=# \q
test1.localdomain:postgres:/usr/local/pgsql:>

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】