微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql安装参考

操作系统环境:CentOS 7.5
1.安装依赖包:
yum install -y zlib readline readline-devel zlib zlib-devel openssl openssl-devel make cmake gcc flex bison autoconf

2.解压:
tar xvzf postgresql-10.0.tar.gz

3.添加用户
useradd postgres

4.创建目录:
mkdir -p /opt/pg10/
mkdir -p /pgdata/10/{data,backup,script,archive_wal}
chown -R postgres:postgres /pgdata/10
chmod 0700 /pgdata/10/data

5.编译安装:
./configure --prefix=/opt/pg10/ --with-pgport=5432

gmake

gmake install

设置软连接:
ln -s /opt/pg10 /opt/pgsql

6.初始化数据库
[[email protected] ~]$ /opt/pgsql/bin/initdb -D /pgdata/10/data -W

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.

Enter new superuser password:
Enter it again:

fixing permissions on existing directory /pgdata/10/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:

/opt/pgsql/bin/pg_ctl -D /pgdata/10/data -l logfile start

7.启动关闭数据库
启动数据库
[[email protected] ~]$ /opt/pgsql/bin/pg_ctl -D /pgdata/10/data start
waiting for server to start....2018-12-08 02:44:44.495 EST [15059] LOG: listening on IPv6 address "::1",port 5432
2018-12-08 02:44:44.495 EST [15059] LOG: listening on IPv4 address "127.0.0.1",port 5432
2018-12-08 02:44:44.500 EST [15059] LOG: listening on Unix socket "/tmp/.s.PGsql.5432"
2018-12-08 02:44:44.515 EST [15060] LOG: database system was shut down at 2018-12-08 02:42:52 EST
2018-12-08 02:44:44.517 EST [15059] LOG: database system is ready to accept connections
done
server started

查看数据库状态:
[[email protected] ~]$ /opt/pgsql/bin/pg_ctl -D /pgdata/10/data status
pg_ctl: server is running (PID: 15059)
/opt/pg10/bin/postgres "-D" "/pgdata/10/data"

关闭数据库
[[email protected] ~]$ /opt/pgsql/bin/pg_ctl -D /pgdata/10/data -ms stopwaiting for server to shut down....2018-12-08 02:47:08.919 EST [15059] LOG: received smart shutdown request2018-12-08 02:47:08.922 EST [15059] LOG: worker process: logical replication launcher (PID 15066) exited with exit code 12018-12-08 02:47:08.923 EST [15061] LOG: shutting down2018-12-08 02:47:08.936 EST [15059] LOG: database system is shut downdoneserver stopped

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐