rhel 6.7简单安装postgresql 9.2.10

来源:互联网 发布:q币拦截软件 编辑:程序博客网 时间:2024/05/01 16:14


安装介质下载:

http://www.postgresql.org/ftp/source/



安装操作系统包

[root@pgsql1 ~]# mkdir /media/rhel[root@pgsql1 ~]# mount /dev/cdrom /media/rhelmount: block device /dev/sr0 is write-protected, mounting read-only[root@pgsql1 ~]# vi /etc/yum.repos.d/rhel6.repo[Server]name=Red Hat Enterprise Linux $releasever Beta - $basearch - Sourcebaseurl=file:///media/rhelenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[root@pgsql1 ~]# yum clean all   [root@pgsql1 ~]# yum list[root@pgsql1 ~]# yum install *readline* *zlib* gcc -y

其中readline包的作用是在psql中使用上下键翻查历史记录;zlib包的作用是支持安装时数据库的压缩功能;gcc包的作用是后面gmake会用到。


解压

[root@pgsql1 opt]# tar -zxvf postgresql-9.2.10.tar.gz


创建安装目录

[root@pgsql1 opt]# mkdir pgsql9210


编译安装第一步

[root@pgsql1 postgresql-9.2.10]# ./configure --prefix=/opt/pgsql9210/


编译安装第二步

[root@pgsql1 postgresql-9.2.10]# gmake world


PostgreSQL, contrib, and documentation successfully made. Ready to install.


编译安装第三步

[root@pgsql1 postgresql-9.2.10]# gmake install-world


PostgreSQL, contrib, and documentation installation complete.


创建用户postgres

[root@pgsql1 postgresql-9.2.10]# useradd postgres


配置用户的环境变量

[root@pgsql1 postgresql-9.2.10]# vi /home/postgres/.bash_profileexport PGBASE=/opt/pgsql9210export PGUSER=postgresexport PGPORT=5432export PGDATA=/opt/pgsql9210/dataexport PATH=$PGBASE/bin:$PATH:$HOME/binexport LD_LIBRARY_PATH=$PGBASE/lib:$LD_LIBRARY_PATH


创建数据库的数据目录

[root@pgsql1 pgsql9210]# mkdir data
[root@pgsql1 pgsql9210]# chown postgres:postgres data/


创建数据库簇:

[root@pgsql1 pgsql9210]# su - postgres

[postgres@pgsql1 ~]$ initdb --locale=C --encoding=UTF8


启动数据库

[postgres@pgsql1 data]$ pg_ctl start


查看数据库

[postgres@pgsql1 data]$ psqlpsql (9.2.10)Type "help" for help.postgres=# \l                             List of databases   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   -----------+----------+----------+---------+-------+----------------------- postgres  | postgres | UTF8     | C       | C     |  template0 | postgres | UTF8     | C       | C     | =c/postgres          +           |          |          |         |       | postgres=CTc/postgres template1 | postgres | UTF8     | C       | C     | =c/postgres          +           |          |          |         |       | postgres=CTc/postgres(3 rows)

0 0