码迷,mamicode.com
首页 > 数据库 > 详细

postgresql安装参考

时间:2018-12-08 16:16:31      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:pre   mem   launch   auth   系统   4.4   ble   .gz   user   

操作系统环境: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.初始化数据库:
[postgres@my1 ~]$ /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.启动关闭数据库:
启动数据库:
[postgres@my1 ~]$ /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

查看数据库状态:
[postgres@my1 ~]$ /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"

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

postgresql安装参考

标签:pre   mem   launch   auth   系统   4.4   ble   .gz   user   

原文地址:http://blog.51cto.com/1937519/2327886

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!