博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Change data directory – PostgreSQL
阅读量:4055 次
发布时间:2019-05-25

本文共 2867 字,大约阅读时间需要 9 分钟。

Useful and common task, should be well documented. Let´s try it! Debian 7.4 x64, PostgreSQL 9.3.2
I just checked via psql where is current data directory stored. Default path = /var/lib/postgresql/9.3/main . As a root i will create new directory, /PGDATA and assign ownership into postgres user:
root@deb74:/var/lib/postgresql/9.3/main# mkdir -p /PGDATA
root@deb74:/var/lib/postgresql/9.3/main# chown -R postgres:postgres /PGDATA
root@deb74:/var/lib/postgresql/9.3/main# service postgresql stop
[ ok ] Stopping PostgreSQL 9.3 database server: main.
Last step = pure paranoia level and untrustful „restart“ service parameter :-)
As postgres user I will re-initialize database:
postgres@deb74:/usr/lib/postgresql/9.3/bin$ /usr/lib/postgresql/9.3/bin/initdb -D /PGDATA
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 database encoding has accordingly been set to „UTF8“.
The default text search configuration will be set to „english“.
Data page checksums are disabled.
fixing permissions on existing directory /PGDATA … ok
creating subdirectories … ok
selecting default max_connections … 100
selecting default shared_buffers … 128MB
creating configuration files … ok
creating template1 database in /PGDATA/base/1 … ok
initializing pg_authid … ok
initializing dependencies … ok
creating system views … ok
loading system objects‘ descriptions … ok
creating collations … ok
creating conversions … ok
creating dictionaries … ok
setting privileges on built-in objects … ok
creating information schema … ok
loading PL/pgSQL server-side language … ok
vacuuming database template1 … ok
copying template1 to template0 … ok
copying template1 to postgres … 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:
/usr/lib/postgresql/9.3/bin/postgres -D /PGDATA
or
/usr/lib/postgresql/9.3/bin/pg_ctl -D /PGDATA -l logfile start
Change in configuration must be written into main postgresql conf file:
postgres@deb74:~$ cd /etc/postgresql/9.3/main/
postgres@deb74:/etc/postgresql/9.3/main$ nano postgresql.conf
There you have to change data_directory into '/PGDATA', save file.
Now I need just to start postgresql service and double-check if everything is changed well:
root@deb74:~# service postgresql start
[ ok ] Starting PostgreSQL 9.3 database server: main.
root@deb74:~# su postgres
postgres@deb74:/root$ psql
could not change directory to „/root“: Permission denied
psql (9.3.2)
Type „help“ for help.
postgres=# show data_directory;
data_directory 
—————-
/PGDATA
(1 row)

-a-

from:http://it.tuxie.eu/?p=515

转载地址:http://tcoci.baihongyu.com/

你可能感兴趣的文章
消息队列设计精要
查看>>
分布式缓存负载均衡负载均衡的缓存处理:虚拟节点对一致性hash的改进
查看>>
分布式存储系统设计(1)—— 系统架构
查看>>
MySQL数据库的高可用方案总结
查看>>
常用排序算法总结(一) 比较算法总结
查看>>
SSH原理与运用
查看>>
SIGN UP BEC2
查看>>
S3C2440中对LED驱动电路的理解
查看>>
《天亮了》韩红
查看>>
Windows CE下USB摄像头驱动开发(以OV511为例,附带全部源代码以及讲解) [转]
查看>>
出现( linker command failed with exit code 1)错误总结
查看>>
iOS开发中一些常见的并行处理
查看>>
iOS获取手机的Mac地址
查看>>
ios7.1发布企业证书测试包的问题
查看>>
如何自定义iOS中的控件
查看>>
iOS 开发百问
查看>>
Mac环境下svn的使用
查看>>
github简单使用教程
查看>>
如何高效利用GitHub
查看>>
环境分支-git版本管理
查看>>