设为首页 收藏本站
查看: 888|回复: 0

[经验分享] postgresql数据的安装简记录

[复制链接]

尚未签到

发表于 2016-11-20 08:11:01 | 显示全部楼层 |阅读模式
1 postgresql 数据库的官方地址
http://www.postgresql.org
2 从官方下载源码包
wget http://ftp.postgresql.org/pub/source/v8.4.10/postgresql-8.4.10.tar.gz
3 解压源码包
tar zxvf postgresql-8.4.10.tar.gz
4 进入目录
cd postgresql-8.4.10
5 配置
./configure --prefix=/usr/hehaibo/pgsql
--prefix 选项指定安装目录
6 编译
make
7 安装
make install

进入目录
cd /usr/hehaibo/pgsql/
[iyunv@oplinux postgresql-8.4.10]# cd /usr/hehaibo/pgsql/
[iyunv@oplinux pgsql]# ls
bin  include  lib  share

创建数据库目录
mkdir data
增加一个用户组
[iyunv@oplinux ~]# groupadd postgres
增加一个组
[iyunv@oplinux ~]# useradd -g postgres postgres
[iyunv@oplinux ~]# cd /usr/hehaibo/pgsql/
改变目录的所属的用户为postgres
[iyunv@oplinux pgsql]# chown postgres:postgres data/
用postgres用户登录
[iyunv@oplinux pgsql]# su postgres
#配置postgres用户的环境变量
注意这是用户的宿主目录 pwd查看当前目录
[postgres@oplinux ~]$ pwd
/home/postgres
#查看所有文件 -a 显示隐藏
[postgres@oplinux ~]$ ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .psql_history  .viminfo
[postgres@oplinux pgsql]$ vi .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
PGLIB=/usr/hehaibo/pgsql/lib
PGDATA=/usr/hehaibo/pgsql/data/
PATH=$PATH:/usr/hehaibo/pgsql/bin/
export PATH

保存退出
是当前环境变量立即生效
[postgres@oplinux ~]$ source ./.bash_profile
打印环境变量PGDATA
[postgres@oplinux ~]$ echo $PGDATA
/usr/hehaibo/pgsql/data/

初始化数据库
[postgres@oplinux data]$ initdb -D /usr/hehaibo/pgsql/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale zh_CN.GBK.
initdb: locale zh_CN.GBK requires unsupported encoding GBK
Encoding GBK is not allowed as a server-side encoding.
Rerun initdb with a different locale selection.
#为什么要加 --loccale参数
[postgres@oplinux data]$ initdb --locale=zh_CN -D /usr/hehaibo/pgsql/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale zh_CN.
The default database encoding has accordingly been set to EUC_CN.
initdb: could not find suitable text search configuration for locale zh_CN
The default text search configuration will be set to "simple".


fixing permissions on existing directory /usr/hehaibo/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /usr/hehaibo/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    postgres -D /usr/hehaibo/pgsql/data
or
    pg_ctl -D /usr/hehaibo/pgsql/data -l logfile start
创建成功。

运行并创建数据库
[postgres@oplinux bin]$ ./postmaster -D /usr/hehaibo/pgsql/data
LOG:  database system was shut down at 2012-07-18 15:33:23 CST
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections
创建数据test
[postgres@oplinux bin]$ ./createdb test

进入数据库
[postgres@oplinux bin]$ psql test
psql (8.4.10)
Type "help" for help.

test=# select * from test;
id
----
  1
(1 row)

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-302665-1-1.html 上篇帖子: 关于设置Postgresql Increment的备份方式 下篇帖子: liunx环境下源码安装PostgreSQL+PostGIS
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表