首页 » 爱链网 » PostgreSql系列一:PG数据库的安装配置启动(数据库列出显示安装信息)

PostgreSql系列一:PG数据库的安装配置启动(数据库列出显示安装信息)

萌界大人物 2024-07-23 18:08:55 爱链网 0

扫一扫用手机浏览

文章目录 [+]

数据库排名

2 PG数据库的安装

PG官网有具体的安装方法,可以根据自己具体的操作系统去选择对应的版本.我的是centos7 选择安装了PG12PG官网:https://www.postgresql.org/download/安装过程:yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpmyum install -y postgresql12-server

至此,数据库PG12就算下载下来了

3 配置启动

程序目录在:[root@slowquery ~]# ll /usr/pgsql-12/总用量 12drwxr-xr-x. 2 root root 4096 6月 30 20:14 bindrwxr-xr-x. 3 root root 4096 6月 30 20:02 libdrwxr-xr-x. 7 root root 4096 6月 30 20:02 share默认情况下PG的数据目录是在/var/log下边的,我们可以自定义一下,方便管理mkdir -p /pgsql/datauseradd postgreschown -R postgres.postgres /pgsql3.1 初始化命令理解

官网解释:https://www.postgresql.org/docs/12/app-initdb.html?spm=a2c6h.12873639.0.0.5dcc7145YmBIcC[root@slowquery ~]# ll /usr/pgsql-12/bin/initdb --help用法:ls [选项]... [文件]...List information about the FILEs (the current directory by default).Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.Mandatory arguments to long options are mandatory for short options too. -a, --all不隐藏任何以. 开始的项目 -A, --almost-all列出除. 及.. 以外的任何项目 --author与-l 同时使用时列出每个文件的作者 -b, --escape以八进制溢出序列表示不可打印的字符 --block-size=SIZE scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units of 1,048,576 bytes; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ -c with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first -C list entries by columns --color[=WHEN] colorize the output; WHEN can be 'never', 'auto', or 'always' (the default); more info below -d, --directory list directories themselves, not their contents -D, --dired generate output designed for Emacs' dired mode -f do not sort, enable -aU, disable -ls --color -F, --classify append indicator (one of /=>@|) to entries --file-type likewise, except do not append '' --format=WORD across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C --full-time like -l --time-style=full-iso -g类似-l,但不列出所有者 --group-directories-first group directories before files; can be augmented with a --sort option, but any use of --sort=none (-U) disables grouping -G, --no-group以一个长列表的形式,不输出组名 -h, --human-readable与-l 一起,以易于阅读的格式输出文件大小(例如 1K 234M 2G) --si同上面类似,但是使用1000 为基底而非1024 -H, --dereference-command-line follow symbolic links listed on the command line --dereference-command-line-symlink-to-dir follow each command line symbolic link that points to a directory --hide=PATTERN do not list implied entries matching shell PATTERN (overridden by -a or -A) --indicator-style=WORD append indicator with style WORD to entry names: none (default), slash (-p), file-type (--file-type), classify (-F) -i, --inode print the index number of each file -I, --ignore=PATTERN do not list implied entries matching shell PATTERN -k, --kibibytes default to 1024-byte blocks for disk usage -l使用较长格式列出信息 -L, --dereference当显示符号链接的文件信息时,显示符号链接所指示的对象而并非符号链接本身的信息 -m所有项目以逗号分隔,并填满整行行宽 -n, --numeric-uid-gid类似 -l,但列出UID 及GID 号 -N, --literal输出未经处理的项目名称 (如不特别处理控制字符) -o类似 -l,但不列出有关组的信息 -p, --indicator-style=slash对目录加上表示符号"/" -q, --hide-control-chars print ? instead of nongraphic characters --show-control-chars show nongraphic characters as-is (the default, unless program is 'ls' and output is a terminal) -Q, --quote-name enclose entry names in double quotes --quoting-style=WORD use quoting style WORD for entry names: literal, locale, shell, shell-always, c, escape -r, --reverse逆序排列 -R, --recursive递归显示子目录 -s, --size以块数形式显示每个文件分配的尺寸 -S sort by file size --sort=WORD sort by WORD instead of name: none (-U), size (-S), time (-t), version (-v), extension (-X) --time=WORD with -l, show time as WORD instead of default modification time: atime or access or use (-u) ctime or status (-c); also use specified time as sort key if --sort=time --time-style=STYLE with -l, show times using style STYLE: full-iso, long-iso, iso, locale, or +FORMAT; FORMAT is interpreted like in 'date'; if FORMAT is FORMAT1<newline>FORMAT2, then FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with 'posix-', STYLE takes effect only outside the POSIX locale -t sort by modification time, newest first -T, --tabsize=COLS assume tab stops at each COLS instead of 8 -u with -lt: sort by, and show, access time; with -l: show access time and sort by name; otherwise: sort by access time -U do not sort; list entries in directory order -v natural sort of (version) numbers within text -w, --width=COLS assume screen width instead of current value -x list entries by lines instead of by columns -X sort alphabetically by entry extension -1 list one file per lineSELinux options: --lcontext Display security context. Enable -l. Lines will probably be too wide for most displays. -Z, --context Display security context so it fits on most displays. Displays only mode, user, group, security context and file name. --scontext Display only security context and file name. --help显示此帮助信息并退出 --version显示版本信息并退出SIZE is an integer and optional unit (example: 10M is 1010241024). Unitsare K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。
退出状态: 0 正常 1 一般问题 (例如:无法访问子文件夹) 2 严重问题 (例如:无法使用命令行参数)GNU coreutils online help: <http://www.gnu.org/software/coreutils/>请向<http://translationproject.org/team/zh_CN.html> 报告ls 的翻译错误要获取完整文档,请运行:info coreutils 'ls invocation'
3.2 自定义初始化

/usr/pgsql-12/bin/initdb -D /pgsql/data-D 指定初始化数据目录其他参数默认就好了.PG12默认的校对规则及字符集都支持中文了.不需要去更改修改启动文件:vim /usr/lib/systemd/system/postgresql-12.service修改参数:Environment=PGDATA=/pgsql/data/ --指定自己刚刚初始化数据的数据目录保存退出然后执行systemctl daemon-reload3.3 启动数据库

systemctl start postgresql-12.service

数据库已经启动了.可以愉快的进行玩耍了

PostgreSql系列一:PG数据库的安装配置启动(数据库列出显示安装信息) PostgreSql系列一:PG数据库的安装配置启动(数据库列出显示安装信息) 爱链网
(图片来自网络侵删)

[root@slowquery ~]# su - postgres上一次登录:四 7月 1 10:12:51 CST 2021pts/0 上-bash-4.2$ [root@slowquery ~]# su - postgres上一次登录:四 7月 1 10:12:51 CST 2021pts/0 上-bash-4.2$ psqlpsql (12.7)输入 "help" 来获取帮助信息.postgres=# \db 表空间列表 名称 | 拥有者 | 所在地 ------------+----------+-------- pg_default | postgres | pg_global | postgres | (2 行记录)postgres=#

下期预告:PG的架构体系及权限体系 https://www.toutiao.com/i6979921697470235143/

源码安装请看:PG基于源码安装链接

PostgreSql系列一:PG数据库的安装配置启动(数据库列出显示安装信息) PostgreSql系列一:PG数据库的安装配置启动(数据库列出显示安装信息) 爱链网
(图片来自网络侵删)
标签:

相关文章