本篇内容介绍了“怎么在CentOS 7.4环境下源码编译安装postgreSQL 11.4”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
1. 安装依赖包
yum install -y readline readline-devel openssl openssl-devel zlib zlib-devel
2. 下载软件
wget https://ftp.postgresql.org/pub/source/v11.4/postgresql-11.4.tar.gz
3. 解压并安装
tar -zvvf postgresql-11.4.tar.gz #进入解压后的文件夹cd postgresql-11.4 ./configure --prefix=/usr/local/pgsql #指定默认安装路径 make #编译 make install #安装
4. 添加用户并更改权限
useradd postgres #添加用户 passwd postgres #设置密码 mkdir -p /data/pgsql/data mkdir -p /data/pgsql/log cd /data/pgsql/log touch pgsql.log chown -R postgres:postgres /data/pgsql
5. 添加环境变量
vim /etc/profile
内容如下:
#postgresql export PGHOME=/data/pgsql export PGBASE=/usr/local/pgsql export PATH=$PATH:$PGBASE/bin
使之生效
source /etc/profile
6. 初始化数据
切换到postgres用户下 su - postgres
[postgres@localhost ~]$ cd /usr/local/pgsql/bin/ [postgres@localhost bin]$ ls clusterdb ecpg pg_config pg_isready pg_rewind pg_waldump vacuumdb createdb initdb pg_controldata pg_receivewal pg_test_fsync postgres createuser pg_archivecleanup pg_ctl pg_recvlogical pg_test_timing postmaster dropdb pg_basebackup pg_dump pg_resetwal pg_upgrade psql dropuser pgbench pg_dumpall pg_restore pg_verify_checksums reindexdb
[postgres@localhost bin]$ ./initdb -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 database encoding has accordingly been set to "UTF8". 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 default timezone ... PRC 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
7. 检查数据目录:
[root@localhost data]# ls base pg_hba.conf pg_notify pg_stat pg_twophase postgresql.auto.conf global pg_ident.conf pg_replslot pg_stat_tmp PG_VERSION postgresql.conf pg_commit_ts pg_logical pg_serial pg_subtrans pg_wal pg_dynshmem pg_multixact pg_snapshots pg_tblspc pg_xact
其中
base
目录是表空间目录;
global
目录是相关全局变量目录;
pg_hba.conf
是访问控制配置文件;
postgresql.conf
是postgresql的主配置文件。
将该文件中的IPV4的连接修改为0.0.0.0/0
,表示信任来自所有id连接的客户端,加密方式改为md5
,如下图所示:
将localhost
改为*
,表示监听所有的网络连接。其他的参数保持默认即可。
10. 关闭防火墙
systemctl stop firewalld
11. 启动数据库
[postgres@localhost bin]$ ./pg_ctl -D /data/pgsql/data -l /data/pgsql/log/pgsql.log start waiting for server to start.... done server started
12. 登录数据库并设置密码
[postgres@localhost bin]$ ./psql psql (11.4) Type "help" for help. postgres=# \password Enter new password: Enter it again: postgres=# \l List of databases 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)
13. navicat 登录
“怎么在CentOS 7.4环境下源码编译安装postgreSQL 11.4”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。