当前位置: 首页 > wzjs >正文

类似稿定设计的网站清远网站建设

类似稿定设计的网站,清远网站建设,网站关键词优化有用吗,中山移动网站建设公司PostgreSQL 数据库源码编译安装全流程详解 Linux 8 1. 基础环境配置1.1 修改主机名1.2 配置操作系统yum源1.3 安装操作系统依赖包1.4 禁用SELINUX配置1.5 关闭操作系统防火墙1.6 创建用户和组1.7 建立安装目录1.8 编辑环境变量 2. 源码方式安装(PG 16)2.…

PostgreSQL 数据库源码编译安装全流程详解 Linux 8

  • 1. 基础环境配置
    • 1.1 修改主机名
    • 1.2 配置操作系统yum源
    • 1.3 安装操作系统依赖包
    • 1.4 禁用SELINUX配置
    • 1.5 关闭操作系统防火墙
    • 1.6 创建用户和组
    • 1.7 建立安装目录
    • 1.8 编辑环境变量
  • 2. 源码方式安装(PG 16)
    • 2.1 下载源码安装包
    • 2.2 编译安装源码包
    • 2.3 初始化数据库
    • 2.4 启动数据库
    • 2.5 开机自启动
    • 2.6 编辑环境变量
  • 3. 安装后配置
    • 3.1 修改默认用户postgres密码
    • 3.2 连接配置文件
    • 3.3 数据库启动关闭

1. 基础环境配置

1.1 修改主机名

hostnamectl set-hostname pgdb
# 配置hosts文件
cat >> /etc/hosts <<EOF
192.168.1.109   pgdb
EOF

1.2 配置操作系统yum源

创建挂载目录
mkdir /mnt/iso
编辑yum源配置文件
cat > /etc/yum.repos.d/yum.repo<<EOF
[sourceOS]
name=yumserverOS
baseurl=file:///mnt/iso/BaseOS
gpgcheck=0
enabled=1[sourceAPP]
name=yumserverApp
baseurl=file:///mnt/iso/AppStream
gpgcheck=0
enabled=1
EOF
检查yum源
yum clean all
yum makecache
yum repolist

1.3 安装操作系统依赖包

yum install -y mke automake zlib zlib-devel bzip2 bzip2-devel bzip2-libs readline readline-devel gcc gcc-c++ bison ncurses ncurses-devel libaio-devel gmp gmp-devel mpfr mpfr-devel libmpc 

1.4 禁用SELINUX配置

getenforce 
setenforce 0 
iptables -F
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
cat /etc/selinux/config
getenforcePermissive   –输出(表示临时关闭)
Disabled     –重启服务器后输出

1.5 关闭操作系统防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service

1.6 创建用户和组

# 创建pg用户和组
groupadd -g 2000 postgres
useradd -g postgres -u 2000 postgres
echo "postgres123" | passwd --stdin postgres# 验证创建成功
id postgres

1.7 建立安装目录

# 创建安装目录
mkdir -p /pgsql/app/pg16
mkdir -p /pgsql/soft
mkdir -p /pgdata/data/pg16
mkdir -p /pgdata/arch
chown -R postgres.postgres /pgsql
chown -R postgres.postgres /pgdata
chmod -R 775 /pgsql
chmod -R 775 /pgdata

1.8 编辑环境变量

# 编辑环境变量
vi /home/postgres/.bash_profile
export PGPORT=5432
export PGDATA=/pgdata/data/pg16
export PGHOME=/pgsql/app/pg16
export LANG=en_US.utf8
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres
export PGDATABASE=postgres

2. 源码方式安装(PG 16)

2.1 下载源码安装包

官方下载地址:
https://www.postgresql.org/ftp/source/

[root@pgdb soft]# ll
total 31676
-rwxr-xr-x 1 root root 32433767 Mar 19 14:23 postgresql-16.1.tar.gz

2.2 编译安装源码包

# 解压源码包
[root@pgdb soft]# tar -xvf postgresql-16.1.tar.gz
[root@pgdb soft]# cd postgresql-16.1
# 配置编译选项 可以自定义端口号 默认5432
[root@pgdb postgresql-16.1]# ./configure --prefix=/pgsql/app/pg16 --with-pgport=5436
# 编译源代码
[root@pgdb postgresql-16.1]# make
# 编译安装
[root@pgdb postgresql-16.1]# make install

2.3 初始化数据库

[postgres@pgdb ~]$  /pgsql/app/pg16/bin/initdb -D /pgdata/data/pg16 
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 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 /pgdata/data/pg16 ... 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 ... okinitdb: warning: enabling "trust" authentication for local connections
initdb: hint: 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 /pgdata/data/pg16 -l logfile start

2.4 启动数据库

[postgres@pgdb ~]$ pg_ctl -D /pgdata/data/pg16 -l logfile start
waiting for server to start.... done
server started

2.5 开机自启动

  • 添加配置文件 参考PG16 RPM安装时配置文件
  • Environment=PGDATA=/pgdata/data/pg16/
  • ExecStart=/pgsql/app/pg16/bin/postgres -D ${PGDATA}

vi /usr/lib/systemd/system/postgresql-16.service
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades.  It is recommended to use systemd
# "dropin" feature;  i.e. create file with suffix .conf under
# /etc/systemd/system/postgresql-16.service.d directory overriding the
# unit's defaults. You can also use "systemctl edit postgresql-16"
# Look at systemd.unit(5) manual page for more info.# Note: changing PGDATA will typically require adjusting SELinux
# configuration as well.# Note: do not use a PGDATA pathname containing spaces, or you will
# break postgresql-16-setup.
[Unit]
Description=PostgreSQL 16 database server
Documentation=https://www.postgresql.org/docs/16/static/
After=syslog.target
After=network-online.target[Service]
Type=notifyUser=postgres
Group=postgres# Note: avoid inserting whitespace in these Environment= lines, or you may
# break postgresql-setup.# Location of database directory
#Environment=PGDATA=/var/lib/pgsql/16/data/
Environment=PGDATA=/pgdata/data/pg16/# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog# Disable OOM kill on postgres main process
OOMScoreAdjust=-1000
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0#ExecStartPre=/usr/pgsql-16/bin/postgresql-16-check-db-dir ${PGDATA}
ExecStart=/pgsql/app/pg16/bin/postgres -D ${PGDATA}
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT# Do not set any timeout value, so that systemd will not kill postgres 
# main process during crash recovery.
TimeoutSec=0# 0 is the same as infinity, but "infinity" needs systemd 229
TimeoutStartSec=0TimeoutStopSec=1h[Install]
WantedBy=multi-user.target
  • 重新加载配置文件 systemctl start postgresql-16.service 不会结束命令,systemctl status postgresql-16.service Active: activating (start)显示状态非running
# reload配置文件
[root@pgdb ~]# systemctl daemon-reload
# 启动数据库
[root@pgdb ~]# systemctl start postgresql-16.service
# 开机自启动
[root@pgdb ~]# systemctl enable postgresql-16.service
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-16.service → /usr/lib/systemd/system/postgresql-16.service.
# pg14 资源状态
[root@pgdb ~]# systemctl status postgresql-16.service
● postgresql-16.service - PostgreSQL 16 database serverLoaded: loaded (/usr/lib/systemd/system/postgresql-16.service; enabled; vendor preset: disabled)Active: activating (start) since Wed 2025-03-19 16:21:17 CST; 3min 33s agoDocs: https://www.postgresql.org/docs/16/static/Main PID: 1062 (postgres)Tasks: 6 (limit: 37638)Memory: 11.9MCGroup: /system.slice/postgresql-16.service├─1062 /pgsql/app/pg16/bin/postgres -D /pgdata/data/pg16/├─1067 postgres: checkpointer ├─1068 postgres: background writer ├─1070 postgres: walwriter ├─1071 postgres: autovacuum launcher └─1072 postgres: logical replication launcher Mar 19 16:21:17 pgdb systemd[1]: Starting PostgreSQL 16 database server...
Mar 19 16:21:17 pgdb postgres[1062]: 2025-03-19 16:21:17.178 CST [1062] LOG:  starting PostgreSQL 16.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.4.1 20200928 (Re>
Mar 19 16:21:17 pgdb postgres[1062]: 2025-03-19 16:21:17.179 CST [1062] LOG:  listening on IPv6 address "::1", port 5436
Mar 19 16:21:17 pgdb postgres[1062]: 2025-03-19 16:21:17.179 CST [1062] LOG:  listening on IPv4 address "127.0.0.1", port 5436
Mar 19 16:21:17 pgdb postgres[1062]: 2025-03-19 16:21:17.180 CST [1062] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5436"
Mar 19 16:21:17 pgdb postgres[1062]: 2025-03-19 16:21:17.184 CST [1069] LOG:  database system was shut down at 2025-03-19 16:19:41 CST
Mar 19 16:21:17 pgdb postgres[1062]: 2025-03-19 16:21:17.187 CST [1062] LOG:  database system is ready to accept connections

2.6 编辑环境变量

#PG 16
######
export PGPORT=5436
export PGDATA=/pgdata/data/pg16
export PGHOME=/pgsql/app/pg16

3. 安装后配置

3.1 修改默认用户postgres密码

postgres=# alter user postgres with password 'postgres';
ALTER ROLE

3.2 连接配置文件

  • postgresql.conf参数 监听所有地址IP
[postgres@pgdb pg16]$ cd $PGDATA
[postgres@pgdb pg16]$ vi postgresql.conf
#listen_addresses = 'localhost'         # what IP address(es) to listen on;  #重启生效
listen_addresses = '*'
  • pg_hba.conf参数 实例访问控制
[postgres@pgdb pg16]$ cd $PGDATA
[postgres@pgdb pg16]$ vi pg_hba.conf
# IPv4 local connections:
#host    all             all             127.0.0.1/32            trust   #重加载配置生效 
# 允许192.168.1.0网段连接数据库
host    all             all             192.168.1.0/24          scram-sha-256
  • 重启数据库
[postgres@pgdb ~]$ pg_ctl restart
  • 远程连接数据库
[postgres@pgdb ~]$ psql -h 192.168.1.109 -p 5436 -U postgres -d postgres

3.3 数据库启动关闭

[postgres@pgdb ~]$ pg_ctl status
pg_ctl: server is running (PID: 1063)
/pgsql/app/pg16/bin/postgres "-D" "/pgdata/data/pg16/"
[postgres@pgdb ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@pgdb ~]$ pg_ctl start
waiting for server to start....2025-03-21 22:24:33.069 CST [1335] LOG:  redirecting log output to logging collector process
2025-03-21 22:24:33.069 CST [1335] HINT:  Future log output will appear in directory "log".done
server started
[postgres@pgdb ~]$ pg_ctl status
pg_ctl: server is running (PID: 1335)
/pgsql/app/pg16/bin/postgres

文章转载自:

http://yY0Glhjj.mwbqk.cn
http://Uz53Bl3l.mwbqk.cn
http://mXbItlxq.mwbqk.cn
http://MNhVAREN.mwbqk.cn
http://BT4Gc8et.mwbqk.cn
http://Sg6VwEvU.mwbqk.cn
http://MeleImIO.mwbqk.cn
http://bcQ3dnz6.mwbqk.cn
http://8tnBpSKq.mwbqk.cn
http://fYDX7W3i.mwbqk.cn
http://3hwclrjJ.mwbqk.cn
http://brt55gzm.mwbqk.cn
http://z1FMMqdx.mwbqk.cn
http://cWGIJ7zX.mwbqk.cn
http://t95KvAWu.mwbqk.cn
http://hiiAgsW1.mwbqk.cn
http://GYo2NXCc.mwbqk.cn
http://a58wAwKB.mwbqk.cn
http://dz5Ey0dK.mwbqk.cn
http://xOlJ8pPU.mwbqk.cn
http://optB10bj.mwbqk.cn
http://D2PRthRx.mwbqk.cn
http://JVfHZ9X6.mwbqk.cn
http://YvGXuo5H.mwbqk.cn
http://3wvbdHEE.mwbqk.cn
http://DlxzNhve.mwbqk.cn
http://CkQlkGuQ.mwbqk.cn
http://fMNYdJ4V.mwbqk.cn
http://WApO1yo6.mwbqk.cn
http://Fb8V3hB3.mwbqk.cn
http://www.dtcms.com/wzjs/724278.html

相关文章:

  • 邯郸做移动网站多少钱西安装修公司排名
  • 政法网站建设有哪些不足wordpress图片上传到
  • 那个公司搭建网站郑州网站建设公司哪家好
  • 有ip地址如何做网站做网站的软件是是什么
  • 做网站的企划书做羞羞的事网站
  • 在线做动漫图片视频在线观看网站网页制作大宝库
  • 只做PC版网站wordpress文章标题颜色
  • 外贸建站 wordpresswordpress 微信导航站
  • 做英文网站的流程赣州是哪个省属于哪个市
  • 档案信息网站开发利用上海网站建设的网
  • 顺德品牌网站建设优惠重庆市建设施工安全网
  • 网站做产品的审核工作怎么样本网站正在建设中
  • 门户网站管理流程什么是seo文章
  • 网站只能用ip访问网站建立一个网站的技术解决方案
  • 青岛知名网站建设网站建设报价比较
  • 做传奇网站云服务器地域改选哪里建站之星网站成品分离
  • 武夷山景区网站建设特点网站建设课程ppt模板
  • 网站代码素材建设黄岛区网站建设
  • 京美建站有代码吗电脑版和手机版网站怎么做
  • 外贸网站哪个比较好网站接入支付宝在线交易怎么做
  • 在网上招标做兼职的网站青柠影视免费高清电视剧
  • 个人网站备案网站名称深圳龙华区龙华街道高坳新村
  • 安徽网站建设制作建立新中国的构想及其实践
  • 东圃做网站的公司北京市建设工程交易服务平台
  • 商城网站建设42623d建模图片
  • 怎么发布个人网站学会了vue 能搭建一个网站平台
  • 湘西网站建设设计师做网站的流程
  • 湖南微信网站首都产业建设集团网站
  • 网站建设资料需要公司提交的吗南京机械加工网
  • 珠海网站建设成功案例室内设计联盟论坛