Postgresql安装
Postgresql默认不能用root启动,所以需要添加用户
linux141#useradd postgres
linux141:~ # passwd postgres
Changing password for postgres.
New Password:
Reenter New Password:
Password changed.
2、rpm包转deb包
如果已经有deb安装包,可以省略
切换到root用户:编译安装
root @puppet-master :dpkg-i bigpostgres94_9.4.1-2_amd64.deb
默认安装到/opt/big/postgres/9.4
3、创建数据目录和设置环境变量
切换到postgres用户
postgres@linux141:~> mkdir data
4、创建数据存储目录并赋予权限
mkdir -p /opt/big/data
chown postgres. /opt/big/data
5、设置环境变量
root#vi/etc/profile
export PGHOME=/opt/big/postgres/9.4
export PGDATA=/opt/big/data
LD_LIBRARY_PATH=/opt/big/postgres/9.4/lib
export LD_LIBRARY_PATH
PATH=/opt/big/postgres/9.4/bin:$PATH
export PATH
postgres$initdb -E UTF8 -D /opt/big/data/
启动数据库
postgres@linux141:~> pg_ctl start
server starting
postgres@linux141:~> LOG: database system was shut down at 2015-07-2411:11:29 CST
LOG: databasesystem is ready to accept connections
LOG: autovacuumlauncher started
7、进入数据库
postgres@linux141:~> psql
psql (9.4.1)
Type "help" for help.
postgres=# \l
List ofdatabases
Name |Owner | Encoding | Collate| Ctype |Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 |postgres | UTF8 | en_US.UTF-8 |en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 |postgres | UTF8 | en_US.UTF-8 |en_US.UTF-8 | =c/postgres +
| || | | postgres=CTc/postgres
(3 rows)
postgres=#
8、快速停止命令:
pg_ctl -m fast stop
9、启动命令:
pg_ctl start
10、常见问题:
解决办法:编辑pg_hba.conf文件,添加host all all192.168.3.0/24 trust配置,将该网段标记为可信。
b、重新指定日志文件存放路径,重启后不生效
原文链接:https://www.f2er.com/postgresql/194422.html