PostgreSQL 二进制安装

本文涉及的产品
云原生数据库 PolarDB PostgreSQL 版,标准版 2核4GB 50GB
云原生数据库 PolarDB MySQL 版,通用型 2核8GB 50GB
简介: 初学 PostgreSQL,二进制安装。与 MySQL 安装类似。

一、安装前准备工作

下载二进制包

wget https://get.enterprisedb.com/postgresql/postgresql-10.1-1-linux-x64-binaries.tar.gz
AI 代码解读


解压到部署目录

tar zxvf  postgresql-10.1-1-linux-x64-binaries.tar.gz  -C /usr/local/
AI 代码解读


新建用户

groupadd postgres
useradd -g postgres postgres
AI 代码解读


创建数据及日志目录,并做相应授权

mkdir -p /data/pgsql/{data,log}
chown -R postgres.postgres /data/pgsql
AI 代码解读

二、进行数据库初始化

切换用户 postgres,并执行初始化操作

su - postgres
cd /usr/local/pgsql/bin
./initdb -E utf8 -D /data/pgsql/data
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 text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data/pgsql/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:

    ./pg_ctl -D /data/pgsql/data -l logfile start
AI 代码解读

初始化完成


三、安装后

配置环境变量,~/.bash_profile 添加如下内容

PATH=/usr/local/pgsql/bin:$PATH
export PATH
AI 代码解读


四、启动 & 登陆

启动数据库

./pg_ctl -D /data/pgsql/data -l /data/pgsql/log/postgres.log start
或
./postgres -D /opt/pgsql/data/ > /opt/pgsql/log/postgres.log &
AI 代码解读


登陆数据库

psql
AI 代码解读









相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
打赏
0
0
0
0
32443
分享
相关文章
PostgreSQL 入门指南:安装、配置与基本命令
本文从零开始,详细介绍如何在 Windows、Linux 和 macOS 上安装和配置 PostgreSQL,涵盖30+个实操代码示例。内容包括安装步骤、配置远程访问和用户权限、基础数据库操作命令(如创建表、插入和查询数据),以及常见问题的解决方案。通过学习,你将掌握 PostgreSQL 的基本使用方法,并为后续深入学习打下坚实基础。
391 1
postgresql的安装和使用
postgresql的安装和使用
223 0
在CentOS 6上安装和使用PostgreSQL的方法
在CentOS 6上安装和使用PostgreSQL的方法
103 2
在Ubuntu 18.04上安装和使用PostgreSQL的方法
在Ubuntu 18.04上安装和使用PostgreSQL的方法
128 1
在Ubuntu 14.04上安装和使用PostgreSQL的方法
在Ubuntu 14.04上安装和使用PostgreSQL的方法
84 1
在CentOS 7上安装和使用PostgreSQL的方法
在CentOS 7上安装和使用PostgreSQL的方法
656 0
如何在 Debian 8 上安装和使用 PostgreSQL 9
如何在 Debian 8 上安装和使用 PostgreSQL 9
93 0

热门文章

最新文章