Subscribe:

2010/10/04

postgresql インストール(さくらVPSサーバー)


インストール

[root@centos]# yum -y install postgresql-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.nara.wide.ad.jp * base: ftp.nara.wide.ad.jp * extras: ftp.nara.wide.ad.jp * updates: ftp.nara.wide.ad.jp addons | 951 B 00:00 base | 2.1 kB 00:00 extras | 2.1 kB 00:00 updates | 1.9 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package postgresql-server.x86_64 0:8.1.21-1.el5_5.1 set to be updated --> Processing Dependency: postgresql = 8.1.21-1.el5_5.1 for package: postgresql-server --> Running transaction check ---> Package postgresql.x86_64 0:8.1.21-1.el5_5.1 set to be updated --> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size ========================================================================================== Installing: postgresql-server x86_64 8.1.21-1.el5_5.1 updates 3.9 M Installing for dependencies: postgresql x86_64 8.1.21-1.el5_5.1 updates 2.9 M Transaction Summary ========================================================================================== Install 2 Package(s) Upgrade 0 Package(s) Total download size: 6.8 M Downloading Packages: (1/2): postgresql-8.1.21-1.el5_5.1.x86_64.rpm | 2.9 MB 00:00 (2/2): postgresql-server-8.1.21-1.el5_5.1.x86_64.rpm | 3.9 MB 00:00 ------------------------------------------------------------------------------------------ Total 7.8 MB/s | 6.8 MB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : postgresql 1/2 Installing : postgresql-server 2/2 Installed: postgresql-server.x86_64 0:8.1.21-1.el5_5.1 Dependency Installed: postgresql.x86_64 0:8.1.21-1.el5_5.1 Complete! [root@centos]# yum -y install perl-DBD-Pg Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.nara.wide.ad.jp * base: ftp.nara.wide.ad.jp * extras: ftp.nara.wide.ad.jp * updates: ftp.nara.wide.ad.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package perl-DBD-Pg.x86_64 0:1.49-2.el5_3.1 set to be updated --> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size ========================================================================================== Installing: perl-DBD-Pg x86_64 1.49-2.el5_3.1 base 115 k Transaction Summary ========================================================================================== Install 1 Package(s) Upgrade 0 Package(s) Total download size: 115 k Downloading Packages: perl-DBD-Pg-1.49-2.el5_3.1.x86_64.rpm | 115 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : perl-DBD-Pg 1/1 Installed: perl-DBD-Pg.x86_64 0:1.49-2.el5_3.1 Complete! [root@centos]# su - postgres -bash-3.2$ initdb --encoding=UNICODE --no-locale -D /var/lib/pgsql/data データベースクラスタ初期化 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 C. fixing permissions on existing directory /var/lib/pgsql/data ... ok creating directory /var/lib/pgsql/data/global ... ok creating directory /var/lib/pgsql/data/pg_xlog ... ok creating directory /var/lib/pgsql/data/pg_xlog/archive_status ... ok creating directory /var/lib/pgsql/data/pg_clog ... ok creating directory /var/lib/pgsql/data/pg_subtrans ... ok creating directory /var/lib/pgsql/data/pg_twophase ... ok creating directory /var/lib/pgsql/data/pg_multixact/members ... ok creating directory /var/lib/pgsql/data/pg_multixact/offsets ... ok creating directory /var/lib/pgsql/data/base ... ok creating directory /var/lib/pgsql/data/base/1 ... ok creating directory /var/lib/pgsql/data/pg_tblspc ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 1000 creating configuration files ... ok creating template1 database in /var/lib/pgsql/data/base/1 ... ok initializing pg_authid ... ok enabling unlimited row size for system tables ... ok initializing dependencies ... ok creating system views ... ok loading pg_description ... ok creating conversions ... ok setting privileges on built-in objects ... ok creating information schema ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the -A option the next time you run initdb. Success. You can now start the database server using: postmaster -D /var/lib/pgsql/data or pg_ctl -D /var/lib/pgsql/data -l logfile start -bash-3.2$ exit logout [root@centos]# /etc/rc.d/init.d/postgresql start Starting postgresql service: [ OK ] [root@centos]# su - postgres -bash-3.2$ createuser centos -P -U postgres ロールを作成 Enter password for new role:パスワード Enter it again:もう一度 Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) y Shall the new role be allowed to create more new roles? (y/n) n CREATE ROLE -bash-3.2$ createdb -h 127.0.0.1 -E UTF-8 centosdb -U centos データベース作成 CREATE DATABASE -bash-3.2$ psql -h 127.0.0.1 -U centos centosdb 作成したロールでログイン Welcome to psql 8.1.21, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit centosdb=> \du ロール一覧表示 List of roles Role name | Superuser | Create role | Create DB | Connections | Member of -----------+-----------+-------------+-----------+-------------+----------- centos | no | no | yes | no limit | postgres | yes | yes | yes | no limit | (2 rows) centosdb=> \l データベース確認 List of databases Name | Owner | Encoding -----------+----------+---------- centosdb | centos | UTF8 postgres | postgres | UTF8 template0 | postgres | UTF8 template1 | postgres | UTF8 (4 rows) centosdb=> \q -bash-3.2$ exit logout [root@centos]#

0 件のコメント: