您的位置:首页 > 健康 > 养生 > 线上托管_杭州设计院排行榜_新闻稿_东莞关键词排名快速优化

线上托管_杭州设计院排行榜_新闻稿_东莞关键词排名快速优化

2025/2/24 0:55:04 来源:https://blog.csdn.net/qq_40914472/article/details/144400994  浏览:    关键词:线上托管_杭州设计院排行榜_新闻稿_东莞关键词排名快速优化
线上托管_杭州设计院排行榜_新闻稿_东莞关键词排名快速优化

1.安装 PostgreSQL

sudo yum install -y postgresql postgresql-server
root@localhost ~]# systemctl status postgresql.service 
● postgresql.service - PostgreSQL database serverLoaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)Active: failed (Result: exit-code) since Wed 2024-12-11 14:09:49 CST; 6s agoProcess: 64216 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (code=exited, status=1/FAILURE)1211 14:09:49 localhost.localdomain systemd[1]: Starting PostgreSQL database server...
1211 14:09:49 localhost.localdomain postgresql-check-db-dir[64216]: Directory "/var/lib/pgsql/data" is missing or empty.
1211 14:09:49 localhost.localdomain postgresql-check-db-dir[64216]: Use "/usr/bin/postgresql-setup --initdb"
1211 14:09:49 localhost.localdomain postgresql-check-db-dir[64216]: to initialize the database cluster.
1211 14:09:49 localhost.localdomain postgresql-check-db-dir[64216]: See /usr/share/doc/postgresql/README.rpm-dist for more information.
1211 14:09:49 localhost.localdomain systemd[1]: postgresql.service: Control process exited, code=exited status=1
1211 14:09:49 localhost.localdomain systemd[1]: postgresql.service: Failed with result 'exit-code'.
1211 14:09:49 localhost.localdomain systemd[1]: Failed to start PostgreSQL database server.

出现这个错误是因为 PostgreSQL 的数据目录 /var/lib/pgsql/data 不存在或为空。要解决这个问题,需要初始化数据库集群。
按照以下步骤修复问题:

步骤 1:初始化 PostgreSQL 数据目录

执行初始化命令:

[root@localhost ~]# sudo /usr/bin/postgresql-setup --initdb* Initializing database in '/var/lib/pgsql/data'* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log

这将初始化 PostgreSQL 的数据目录。

步骤 2:启动 PostgreSQL 服务

启动服务:

sudo systemctl start postgresql.service

检查服务状态:

sudo systemctl status postgresql.service

设置服务开机自启动:

sudo systemctl enable postgresql.service

步骤 3 :创建数据库和用户

sudo -i -u postgres
psql

在 PostgreSQL shell 中运行以下命令:

CREATE DATABASE confluence;
CREATE USER confluence_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE confluence TO confluence_user;
ALTER ROLE confluence_user WITH LOGIN;
\q
exit

步骤 4:配置允许远程连接

编辑/var/lib/pgsql/data/pg_hba.conf,添加:

host    all             all             0.0.0.0/0            md5

编辑 /var/lib/pgsql/data/postgresql.conf,修改:

listen_addresses = '*'

重启服务:

sudo systemctl restart postgresql

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com