initdb: невозможно запустить от имени пользователя root

Поскольку у вас есть компьютер C в Интернете, создайте там специальную учетную запись с именем sesame , а на A вы создаете учетную запись с открытым / закрытым ключом, из которого вы скопировали открытый ключ на sesame аккаунт на C.

Теперь вы можете войти в систему с A на C, но вместо этого вы выполните:

ssh -N -R 19930:localhost:22 sesame@yourserverC

(вы можете объединить это с оператором сна или, например, 10 секунд и заверните это в бесконечный цикл, чтобы соединение было восстановлено, если отключение Wi-Fi привело к его разрыву)

С машины B обычно входите в любую учетную запись, которая у вас есть на C (может быть, но не обязательно, sesame , я использую разные аккаунты). И как только вы перейдете на C, войдите в систему A, используя:

ssh localhost -p 19930

Конечно, вы можете использовать номер, отличный от 19930.

Можно запустить ssh -N -R ... из /etc/rc.local , если ваш закрытый ключ на A не защищен паролем. В этом случае не забудьте сделать sesame отдельной учетной записью с ограниченной функциональностью, чтобы в случае взлома / кражи вашей машины A риск для вашего сервера C был ограничен. Вот почему я также рекомендую использовать отдельную учетную запись для перехода от B к C.

Фактически вы можете установить оболочку входа для sesame в / etc / passwd на / bin / false , поэтому вы больше не можете использовать учетную запись для входа в систему.

3
25.02.2018, 14:40
2 ответа
[root@cll ~]# sudo chown jessica:jessica /usr/local/agdata/
[root@cll ~]# cd /usr/local/
[root@cll local]# ll

total 8
drwxr-xr-x.  2 jessica jessica    6 Feb 26 18:06 agdata
drwxr-xr-x.  6 root    root      56 Feb 26 03:31 agensgraph
drwxr-xr-x.  2 root    root    4096 Feb 24 21:01 bin
drwxr-xr-x.  2 root    root       6 Nov  5  2016 etc
drwxr-xr-x.  2 root    root       6 Nov  5  2016 games
drwxr-xr-x.  4 root    root     160 Feb 24 21:01 include
drwxr-xr-x.  6 root    root    4096 Feb 24 21:01 lib
drwxr-xr-x.  2 root    root       6 Nov  5  2016 lib64
drwxr-xr-x.  2 root    root       6 Nov  5  2016 libexec
drwxr-xr-x.  2 root    root       6 Nov  5  2016 sbin
drwxr-xr-x. 13 root    root     169 Feb 24 21:01 share
drwxr-xr-x.  2 root    root       6 Nov  5  2016 src

[root@cll local]# cd agdata/
[root@cll agdata]# initdb
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

[root@cll agdata]# su -l jessica
Last login: Mon Feb 26 23:31:29 CST 2018 from 192.168.109.1 on pts/2
[jessica@cll ~]$ cd /usr/local/agensgraph/
[jessica@cll agensgraph]$ initdb
The files belonging to this database system will be owned by user "jessica".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
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 /usr/local/agdata... ok
creating subdirectories... ok
selecting default max_connections... 100
selecting default shared_buffers... 128MB
selecting dynamic shared memory implementation... posix
creating configuration files... ok
running bootstrap script... ok
performing post-bootstrap initialization... ok
syncing data to disk... ok

WARNING: enabling "trust" authentication for local connections
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:

    ag_ctl -D /usr/local/agdata -l logfile start

[jessica@cll agensgraph]$ 

Explicación

ingrese la descripción del enlace aquí

0
27.01.2020, 21:25

La base de datos PostgreSQL requiere que la inicialización se lleve a cabo como el usuario que realmente ejecutará el proceso de la base de datos. Este usuario no es usted sino una cuenta de usuario del sistema como postgreso postgresqlo similar.

En CentOS, siguiendo las instrucciones que se encuentran en el Wiki de PostgreSQL , como root, haría cualquiera de las dos cosas

service postgresql-9.6 initdb

o

/usr/pgsql-9.6/bin/postgresql96-setup initdb

(asumiendo que es PostgreSQL 9.6 que está configurando ).

Otro sitio sugiere

sudo postgresql-setup initdb

Si el paquete de PostgreSQL en su máquina vino con la documentación (seguramente lo hizo ), entonces esta documentación explicaría exactamente cómo se debe inicializar la versión de la base de datos.

3
27.01.2020, 21:25

Теги

Похожие вопросы