制作PostgreSQL-15.1绿色版,简化以后搭建测试环境。
内置数据库test
内置用户test,密码test,可远程登陆,管理员权限
./start.sh 启动
./stop.sh 停止
./cmd.sh test用户和库的命令行
./admin.sh 超级用户权限命令行
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql15-server
mkdir postgresql-green
cd postgresql-green
cp -rf /usr/pgsql-15/* .
mkdir data
./bin/initdb -D ./data -E UTF8
host all all 0.0.0.0/0 md5
listen_addresses = ‘*’
port = 6432
./bin/pg_ctl -D ./data -l logfile start
./bin/psql -p 6432 postgres
postgres=# create database test;
CREATE DATABASE
postgres=# create user test with password 'test';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE test to test;
GRANT
postgres=# alter user test superuser;
ALTER ROLE
postgres=# \q
居然发现postgresql-15中比旧版本少个字段,搞得Navicat-15报错,用16才正常。
[yinyx@localhost postgresql-green]$ cat start.sh
source ./env
./bin/pg_ctl -D ./data -l logfile start
[yinyx@localhost postgresql-green]$ cat stop.sh
source ./env
./bin/pg_ctl -D ./data -l logfile stop
[yinyx@localhost postgresql-green]$ cat cmd.sh
source ./env
PGPASSWORD=test
./bin/psql -h 127.0.0.1 -p 6432 -U test test
[yinyx@localhost postgresql-green]$ cat admin.sh
source ./env
./bin/psql -h 127.0.0.1 -p 6432 postgres
[yinyx@localhost postgresql-green]$ cat env
export PGHOME=`pwd`
export PGDATA=$PGHOME/data
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
[yinyx@localhost postgresql-green]$
将libzstd.so.1放入lib目录
修改data/postgresql.conf
unix_socket_directories = ‘/tmp’
./stop.sh停止数据库
打包压缩文件
tar cfz postgresql-green.tar.gz postgresql-green
安装一台的CentOS7,mini安装,1C1G,上传green,解压启动,so easy!