wap网站建设教程,北京工程建设信息网官网,wordpress无法改成中文字体,温州建站费用零、前置条件
系统CentOS 7#xff0c;并已联网#xff0c;已安装gcc或者g编译器#xff0c;GNU make版本3.80或以上#xff0c;系统有至少一个除root之外的普通用户user gcc安装-参考链接查看make命令的版本——make --version更新make版本-参考链接postgresql的使用一般…零、前置条件
系统CentOS 7并已联网已安装gcc或者g编译器GNU make版本3.80或以上系统有至少一个除root之外的普通用户user gcc安装-参考链接查看make命令的版本——make --version更新make版本-参考链接postgresql的使用一般不用root用户而是普通用户这里假设普通用户名为user。Linux创建新用户-参考链接 Xshell建立起与CentOS 7系统的会话Xftp同样建立了与CentOS 7的链接
一、下载、转移、解压
下载
首先在本地打开以链接下载postgresql-xx.xreadline-7.0zlib-1.2.xx
https://www.postgresql.org/ftp/source/PostgresSQL建议下载最新版本打开后的版本列表中选择最新的正式版本最好不要选带beta的
http://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz下载zlib前先开官网http://www.zlib.net/看一下最新版本号比如这里是1.2.13那么下面下载链接中的版本号就改成最新的版本号
http://www.zlib.net/zlib-1.x.xx.tar.gz转移
在root用户下的/root目录下操作
[rootlocalhost ~]# mkdir pgsoft打开xftp将刚刚下载好的三个压缩包拖到刚刚建立目录下面/root/pgsoft
解压
[rootlocalhost pgsoft]# tar -xf readline-7.0.tar.gz
[rootlocalhost pgsoft]# tar -xf zlib-1.x.xx.tar.gz
[rootlocalhost pgsoft]# tar -xf postgresql-xx.x.tar.gz版本号根据实际情况来
二、安装
readline安装
[rootlocalhost pgsoft]# cd readline-7.0
[rootlocalhost readline-7.0]# ./configure
[rootlocalhost readline-7.0]# make
[rootlocalhost readline-7.0]# make install安装readline开发包readline-devel不然后面安装postgresql时会提示错误configure: error: readline library not found
[rootlocalhost readline-7.0]# yum install readline-develzlib安装
[rootlocalhost readline-7.0]# cd /root/pgsoft/zlib-1.x.xx
[rootlocalhost zlib-1.x.xx]# ./configure
[rootlocalhost zlib-1.x.xx]# make
[rootlocalhost zlib-1.x.xx]# make installpostgresql安装
# 为pg安装新建一个目录/opt/pgsql-xx.x
[rootlocalhost ~]# mkdir -p /opt/pgsql-xx.x# 将opt目录的拥有权给予给普通用户user
[rootlocalhost ~]# chown user -R /opt # 进入下载转移解压后的postgresql目录
[rootlocalhost ~]# cd /root/pgsoft/postgresql-xx.x# 配置postgresql
[rootlocalhost postgresql-xx.x]# ./configure --prefix/opt/pgsql-xx.x# 编译postgresql这一步耗时稍微较长
[rootlocalhost postgresql-xx.x]# make world# 安装postgresql
[rootlocalhost postgresql-xx.x]# make install -world验证postgres是否安装成功
# 查看安装目录/opt/pgsql-xx.x安装成功的话会出现以下四个目录
[rootlocalhost postgresql-15.3]# ll /opt/pgsql-xx.x/
总用量 16
drwxr-xr-x. 2 root root 4096 6月 9 09:29 bin
drwxr-xr-x. 6 root root 4096 6月 9 09:29 include
drwxr-xr-x. 4 root root 4096 6月 9 09:29 lib
drwxr-xr-x. 6 root root 4096 6月 9 09:29 share# 查看安装的postgres版本是否对应这里以15.3版本为例
[rootlocalhost postgresql-15.3]# /opt/pgsql-15.3/bin/postgres --version
postgres (PostgreSQL) 15.3三、安装数据目录
数据目录即后续数据库使用中数据存放的目录
# 递归创建新目录版本号记得根据实际情况更换
[rootlocalhost ~]# mkdir -p /pgdata/15.3/poc/{data,archive,scripts,backup}# 将该目录的拥有权赋给普通用户user
[rootlocalhost ~]# chown -R user /pgdata/15.3/# 初始化数据目录
# 首先由root切换到普通用户
[rootlocalhost pgsoft]# su - user
上一次登录五 6月 9 09:32:48 CST 2023pts/0 上
# 进入数据目录用initdb命令初始化该目录初始化成功后最后出现Success字样
[userlocalhost ~]$ cd /pgdata/15.3/poc
[userlocalhost poc]$ /opt/pgsql-15.3/bin/initdb -D /pgdata/15.3/poc/data/ -E UTF-8
……
……
Success. You can now start the database server using:/opt/pgsql-15.3/bin/pg_ctl -D /pgdata/15.3/poc/data/ -l logfile start# 对数据目录开放读写执行权限
[userblocalhost poc]$ chmod 0700 data/# 启动PostgreSQL启动成功后最后一行会出现server started
[userblocalhost poc]$ /opt/pgsql-15.3/bin/pg_ctl -D /pgdata/15.3/poc/data/ start
waiting for server to start....2023-06-09 09:43:50.826 CST [18923] LOG: starting PostgreSQL 15.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2023-06-09 09:43:50.828 CST [18923] LOG: listening on IPv6 address ::1, port 5432
2023-06-09 09:43:50.828 CST [18923] LOG: listening on IPv4 address 127.0.0.1, port 5432
2023-06-09 09:43:50.832 CST [18923] LOG: listening on Unix socket /tmp/.s.PGSQL.5432
2023-06-09 09:43:50.836 CST [18926] LOG: database system was shut down at 2023-06-09 09:42:19 CST
2023-06-09 09:43:50.855 CST [18923] LOG: database system is ready to accept connectionsdone
server started四、创建PostgreSQL第一个数据库实例
# 使用createdb命令创建第一个数据库实例如果不产生任何响应则表示该步骤成功
[userblocalhost poc]$ /opt/pgsql-15.3/bin/createdb my_first_pgdb五、将PostgreSQL的安装路径添加到Shell的搜索路径
# 注意切换到root用户
[rootlocalhost ~]# su - root
password:# 当前环境变量中的路径
[rootlocalhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin# 将postgres安装目录/opt/pgsql-xx.x/bin添加到环境变量中
[rootlocalhost ~]# export PATH$PATH:/opt/pgsql-15.3/bin# 再次查看环境变量PATH值
[rootlocalhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/pgsql-15.3/bin# 验证是否有效不在安装目录下直接运行postgres --version如果能出现相关信息则表示已经添加成功
[rootlocalhost ~]# postgres --version
postgres (PostgreSQL) 15.3# 添加完成路径后可以直接使用/opt/pgsql-15.3/bin下的命令而不需要加绝对路径例如上面创建数据库实例可以直接写成
[userblocalhost poc]$ createdb my_first_pgdb