源码编译安装pg13
源码下载地址:https://www.postgresql.org/ftp/source/
[root@muze1 data]# wget https://ftp.postgresql.org/pub/source/v13.2/postgresql-13.2.tar.gz
-- 创建用户
groupadd -g 60000 dba
useradd -u 60000 -g dba postgres
echo "lhr" | passwd --stdin postgres
-- 创建目录
[root@muze1 data]# mkdir -p /data/postgresql/{pgdata,archive,scripts,backup,pg13,soft}
chown -R postgres:dba /data/postgresql
chmod -R 775 /data/postgresql
-- 编译
su - postgres
cd /data/postgresql/soft
tar zxvf postgresql-13.2.tar.gz
cd postgresql-13.2
./configure --prefix=/data/postgresql/pg13 --without-readline
make -j 8 && make install
-- 配置环境变量
cat >> ~/.bash_profile <<"EOF"
export LANG=en_US.UTF-8
export PS1="[\u@\h \W]\$ "
export PGPORT=5432
export PGDATA=/data/postgresql/pgdata
export PGHOME=/data/postgresql/pg13
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export PATH=$PGHOME/bin:$PATH:.
export DATE=`date +"%Y%m%d%H%M"`
export MANPATH=$PGHOME/share/man:$MANPATH
export PGHOST=$PGDATA
export PGUSER=postgres
export PGDATABASE=postgres
alias psql='rlwrap psql'
EOF
source ~/.bash_profile
-- 初始化
[postgres@muze1 postgresql]$ /data/postgresql/pg13/bin/initdb -D /data/postgresql/pgdata -E UTF8 --locale=en_US.utf8 -U postgres
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.utf8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /data/postgresql/pgdata ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Shanghai
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: 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:
/data/postgresql/pg13/bin/pg_ctl -D /data/postgresql/pgdata -l logfile start
[postgres@muze1 postgresql]$
-- 修改参数
cat >> /data/postgresql/pgdata/postgresql.conf <<"EOF"
listen_addresses = '*'
port=5432
unix_socket_directories='/data/postgresql/pgdata'
logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql-%a.log'
log_truncate_on_rotation = on
EOF
cat > /data/postgresql/pgdata/pg_hba.conf << EOF
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 md5
host replication all 0.0.0.0/0 md5
EOF
[postgres@muze1 ~]$ pg_ctl start
waiting for server to start....2021-06-08 17:10:13.281 CST [87275] LOG: redirecting log output to logging collector process
2021-06-08 17:10:13.281 CST [87275] HINT: Future log output will appear in directory "pg_log".
done
server started
[postgres@muze1 ~]$ ps -ef|grep pg
postgres 87275 1 0 17:10 ? 00:00:00 /data/postgresql/pg13/bin/postgres
postgres 87292 87178 0 17:10 pts/0 00:00:00 grep --color=auto pg
[postgres@muze1 bin]$ ./psql
psql (13.2)
Type "help" for help.
postgres=# select version() ;
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 13.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端