加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql安装参考

发布时间:2020-12-13 16:10:35 所属栏目:百科 来源:网络整理
导读:操作系统环境: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.创建目录
操作系统环境: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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读