: | : |
‹ | › | |||||
Пн | Вт | Ср | Чт | Пт | Сб | Вс |
2017-11-13 17:24:41 3641 0
Установка Postgresql на Gentoo linux
PostgreSQL — это свободная система управления реляционными базами данных (RDBMS, или СУРБД) с открытым исходным кодом. Она поддерживает такие вещи как транзакции, схемы и внешние ключи, и часто позиционируется как более строго соответствующая стандартам SQL и более безопасная по умолчанию, чем любая другая база данных, коммерческая или нет.
Выполняем синхронизацию репозиориев Gentoo
emerge --sync
setlocale: unsupported locale setting setlocale: unsupported locale setting >>> Syncing repository "gentoo" into "/usr/portage"... >>> Starting rsync with rsync://91.186.30.235/gentoo-portage... >>> Checking server timestamp ... Welcome to boobie.gentoo.org / rsync.gentoo.org Server Address : 91.186.30.235 Contact Name : mirror-admin@gentoo.org Hardware : 2 x Intel(R) Xeon(R) CPU 3050 @ 2.13GHz, 3947MB RAM Sponsor : EUKhost, Maidenhead, England .................................
Ставим postgresql из репозиториев
emerge -av dev-db/postgresql
setlocale: unsupported locale setting setlocale: unsupported locale setting * IMPORTANT: 10 news items need reading for repository "gentoo". * Use eselect news read to view new items. These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] app-eselect/eselect-postgresql-2.2::gentoo 5 KiB [ebuild N ] dev-db/postgresql-9.6.4:9.6::gentoo USE="nls pam readline server ssl zlib -doc -kerberos -ldap (-libressl) -perl -pg_legacytimestamp -python (-selinux) -static-libs -systemd -tcl -threads -uuid -xml" LINGUAS="-af -cs -de -en -es -fa -fr -hr -hu -it -ko -nb -pl -pt_BR -ro -ru -sk -sl -sv -tr -zh_CN -zh_TW" PYTHON_SINGLE_TARGET="python3_4 -python2_7 (-python3_5) (-python3_6)" PYTHON_TARGETS="python2_7 python3_4 (-python3_5) (-python3_6)" 19109 KiB Total: 2 packages (2 new), Size of downloads: 19113 KiB Would you like to merge these packages? [Yes/No]
Программа показывает с какими модулями будет собран пакет postgresql
При необходимости можно добавить или убрать модули с помощью "USE"
Для примера добавим kerberos и уберем из сборки ssl
USE="kerberos -ssl" emerge -av dev-db/postgresql
Calculating dependencies... done! [ebuild N ] app-eselect/eselect-postgresql-2.2::gentoo 5 KiB [ebuild N ] sys-apps/keyutils-1.5.9-r1::gentoo USE="{-test}" ABI_X86="(64) -32 (-x32)" 73 KiB [ebuild N ] dev-libs/libev-4.23::gentoo USE="-static-libs" ABI_X86="(64) -32 (-x32)" 512 KiB [ebuild N ] dev-libs/libverto-0.2.5-r1::gentoo USE="libev threads -glib -libevent -static-libs -tevent" ABI_X86="(64) -32 (-x32)" 342 KiB [ebuild N ] app-crypt/mit-krb5-1.14.2::gentoo USE="keyutils pkinit threads -doc (-libressl) -openldap (-selinux) {-test} -xinetd" ABI_X86="(64) -32 (-x32)" 11978 KiB [ebuild N ] virtual/krb5-0-r1::gentoo ABI_X86="(64) -32 (-x32)" 0 KiB [ebuild N ] dev-db/postgresql-9.6.4:9.6::gentoo USE="kerberos nls pam readline server zlib -doc -ldap (-libressl) -perl -pg_legacytimestamp -python (-selinux) -ssl -static-libs -systemd -tcl -threads -uuid -xml" LINGUAS="-af -cs -de -en -es -fa -fr -hr -hu -it -ko -nb -pl -pt_BR -ro -ru -sk -sl -sv -tr -zh_CN -zh_TW" PYTHON_SINGLE_TARGET="python3_4 -python2_7 (-python3_5) (-python3_6)" PYTHON_TARGETS="python2_7 python3_4 (-python3_5) (-python3_6)" 19109 KiB Total: 7 packages (7 new), Size of downloads: 32017 KiB Would you like to merge these packages? [Yes/No]
Вводим "Yes"
* Fetching files in the background. * To view fetch progress, run in another terminal: * tail -f /var/log/emerge-fetch.log * eselect-postgresql-2.2.tbz2 SHA256 SHA512 WHIRLPOOL size ;-) ... [ ok ] >>> Unpacking source... >>> Unpacking eselect-postgresql-2.2.tbz2 to /var/tmp/portage/app-eselect/eselect-postgresql-2.2/work >>> Source unpacked in /var/tmp/portage/app-eselect/eselect-postgresql-2.2/work >>> Preparing source in /var/tmp/portage/app-eselect/eselect-postgresql-2.2/work/ eselect-postgresql-2.2 ... >>> Source prepared. >>> Configuring source in /var/tmp/portage/app-eselect/eselect-postgresql-2.2/work/ eselect-postgresql-2.2 ... >>> Source configured. >>> Compiling source in /var/tmp/portage/app-eselect/eselect-postgresql-2.2/work/ eselect-postgresql-2.2 ... >>> Source compiled. .................................................
После установки postgresql выполним инициализацию кластера баз данных
Перед инициализацией произведем настройку postgresql в фвйле /etc/conf.d/postgresql-9.6
cat /etc/conf.d/postgresql-9.6
########################################################################## # Location of configuration files PGDATA="/etc/postgresql-9.6/" # Where the data directory is located/to be created DATA_DIR="/var/lib/postgresql/9.6/data" # Additional options to pass to initdb. # See `man initdb" for available options. PG_INITDB_OPTS=""
- PGDATA - определяеи где должны находится файлы настроек
- DATA_DIR - куда будет установлен кластер базы данных
- PG_INITDB_OPTS - другие опции (man initdb - полное описание)
Изменение локали и набора кодировок может быть выполнена и после установки, при создании базы данных
Обязательно перед инициализацией устанавливаем системную локаль
eselect locale list
[1] C [2] en_US.utf8 [3] POSIX [ ] (free form)
Выбираем en_US.utf8 (если необходима русская локаль то следуем инструкции в статье про локализацию gentoo)
eselect locale set 3
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory /usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory /usr/bin/locale: Cannot set LC_COLLATE to default locale: No such file or directory Setting LANG to en_US.utf8 ... Run ". /etc/profile" to update the variable in your shell.
Создаем кластер базы даныых и сохраняем все принадлежащие серверу файлы в PGDATA и DATA_DIR
emerge --config postgresql:9.6
Configuring pkg... * You can modify the paths and options passed to initdb by editing: * /etc/conf.d/postgresql-9.6 * * Information on options that can be passed to initdb are found at: * http://www.postgresql.org/docs/9.6/static/creating-cluster.html * http://www.postgresql.org/docs/9.6/static/app-initdb.html * * PG_INITDB_OPTS is currently set to: * (none) * * Configuration files will be installed to: * /etc/postgresql-9.6/ * * The database cluster will be created in: * /var/lib/postgresql/9.6/data * * Continuing initialization in 5 seconds (Control-C to cancel) ... [ ok ] * Creating the data directory ... * Initializing the database ... The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.utf8". 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 /var/lib/postgresql/9.6/data ... 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: /usr/lib64/postgresql-9.6/bin/pg_ctl -D /var/lib/postgresql/9.6/data -l logfile start * The autovacuum function, which was in contrib, has been moved to the main * PostgreSQL functions starting with 8.1, and starting with 8.4 is now enabled * by default. You can disable it in the cluster"s: * /etc/postgresql-9.6/postgresql.conf * * The PostgreSQL server, by default, will log events to: * /var/lib/postgresql/9.6/data/postmaster.log * * You should use the "/etc/init.d/postgresql-9.6" script to run PostgreSQL * instead of "pg_ctl".
Запускаем postgresql
/etc/init.d/postgresql-9.6 start
* Caching service dependencies ... [ ok ] * No permission to apply cgroup settings * /run/postgresql: creating directory * /run/postgresql: correcting owner * Starting PostgreSQL 9.6 ... [ ok ]
Файлы настройки и файлы базы данных хранятся в директории /var/lib/postgresql/9.6/data/
ls /var/lib/postgresql/9.6/data/
base pg_hba.conf pg_replslot pg_subtrans postgresql.auto.conf global pg_ident.conf pg_serial pg_tblspc postgresql.conf pg_clog pg_logical pg_snapshots pg_twophase postmaster.log pg_commit_ts pg_multixact pg_stat PG_VERSION postmaster.opts pg_dynshmem pg_notify pg_stat_tmp pg_xlog postmaster.pid
Пробуем подключиться к postgresql
su postgres -c "psql"
psql (9.6.4) Type "help" for help. postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+------------+------------+----------------------- postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 | template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows)
Введите ответ:
+
=