Change data directory – PostgreSQL
来源:互联网 发布:centos安装oracle 256 编辑:程序博客网 时间:2024/06/03 20:50
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)
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
0 0
- Change data directory – PostgreSQL
- How to change mysql default data directory in Ubuntu
- How to Change default MySQL Data Directory in Linux111
- oracle asm剖析系列(7)–Active Change Directory
- vsftp: failed to change directory
- 500 OOPS: cannot change directory
- 500 OOPS: cannot change directory:
- 550 failed to change directory
- Change Data Capture(一)
- CHANGE ALV DATA
- Change Data Capture(二)
- Change Data Capture(三)
- Change Data Capture(四)
- Oracle CDC(Change Data Capture)
- 关于Change Data Capture--NinGoo
- Change mysql default data location
- MAF: Synchronized Data Change Envent
- data-duplex-event="change"
- 【bzoj3171】[Tjoi2013]循环格 (费用流)
- 多线程
- 三个统计结果之间的差异
- CSS选择器
- Kafka Zero-Copy 使用分析
- Change data directory – PostgreSQL
- spring自带的定时任务配置
- mysql 分表分区实践
- Android Studio项目结构和Gradle应用
- Android 5.0 Camera (3):open camera
- 安卓开发——问题:PNG图片的透明部分不显示Layout的背景色
- 【JS学习笔记】时间与日期
- CSS基础研究(四)-CSS高级样式研究
- proxool配置文件中用户名和密码使用加密后的密文(安全测评)