Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6545847
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Mysql/postgreSQL

2018-08-06 16:30:48


1.下载
下载地址:[root@localhost tmp]# wget



或是手工源码下载


2.解压部署到目录
tar zxvf postgresql-10.4-1-linux-x64-binaries.tar.gz -C /db

3.新建用户和用户组
groupadd postgres
useradd -g postgres postgres

4.创建数据及日志目录,并做相应授权
mkdir -p /db/pgsql/{data,log}
chown -R postgres:postgres /db/pgsql

5.进行数据库初始化
切换用户 postgres,并执行初始化操作
su - postgres
cd /db/pgsql/bin
./initdb -E utf8 -D /db/pgsql/data

[postgres@localhost bin]$ ./initdb -E utf8 -D /db/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 "en_US.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /db/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

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

Success. You can now start the database server using:

    ./pg_ctl -D /db/pgsql/data -l logfile start

6.配置 postgres 环境变量
[postgres@localhost ~]$ more .bash_profile
# .bash_profile

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

# User specific environment and startup programs
PG_HOME=/db/pgsql
PATH=$PG_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin

export PATH

7.启动数据库
pg_ctl -D /db/pgsql/data -l /db/pgsql/log/postgres.log start

postgres -D /db/pgsql/data/ > /db/pgsql/log/postgres.log &

8.登陆数据库
[postgres@localhost ~]$ psql
psql.bin (10.4)
Type "help" for help.

postgres=#


阅读(3923) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~