CentOS6にPostgresインストール

■yumで使用するリポジトリのrpmパッケージの設定ファイルダウンロード
cd /tmp/
wget http://yum.pgrpms.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm

■インストール
rpm -ivh ./pgdg-centos93-9.3-1.noarch.rpm

■確認
ls -l /etc/yum.repos.d/ [/etc/yum.repos.d]
-rw-r--r-- 1 root root 2001 10月 20 15:30 2013 CentOS-Base.repo



-rw-r--r-- 1 root root 442 5月 9 03:58 2013 pgdg-93-centos.repo

CentOS-Base.repoからpostgresのパッケージをインストールしないように設定
vim /etc/yum.repos.d/vim CentOS-Base.repo
[base]
末尾に
exclude=postgresql*
[update]
末尾に
exclude=postgresql*

■インストール

yum install postgresql-server [~]

Loaded plugins: fastestmirror, priorities, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* remi: mirror.smartmedia.net.id
* updates: ftp.iij.ad.jp
565 packages excluded due to repository priority protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql93-server.x86_64 0:9.3.1-1PGDG.rhel6 will be installed
--> Processing Dependency: postgresql93 = 9.3.1-1PGDG.rhel6 for package: postgresql93-server-9.3.1-1PGDG.rhel6.x86_64
--> Running transaction check
---> Package postgresql93.x86_64 0:9.3.1-1PGDG.rhel6 will be installed
--> Processing Dependency: postgresql93-libs = 9.3.1-1PGDG.rhel6 for package: postgresql93-9.3.1-1PGDG.rhel6.x86_64
--> Running transaction check
---> Package postgresql93-libs.x86_64 0:9.3.1-1PGDG.rhel6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql93-server x86_64 9.3.1-1PGDG.rhel6 pgdg93 4.0 M
Installing for dependencies:
postgresql93 x86_64 9.3.1-1PGDG.rhel6 pgdg93 1.0 M
postgresql93-libs x86_64 9.3.1-1PGDG.rhel6 pgdg93 189 k

Transaction Summary
================================================================================
Install 3 Package(s)

Total download size: 5.2 M
Installed size: 21 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): postgresql93-9.3.1-1PGDG.rhel6.x86_64.rpm | 1.0 MB 00:01 
(2/3): postgresql93-libs-9.3.1-1PGDG.rhel6.x86_64.rpm | 189 kB 00:00 
(3/3): postgresql93-server-9.3.1-1PGDG.rhel6.x86_64.rpm | 4.0 MB 00:00 
--------------------------------------------------------------------------------
Total 1.6 MB/s | 5.2 MB 00:03

■postgresのアカウント確認(自動で作られる)
id postgres
uid=26(postgres) gid=26(postgres) 所属グループ=26(postgres)

■コマンドの確認
which psql

■/etc/init.d/にpostgres起動コマンドがあることを確認
ls -la /etc/init.d/
postgresql-9.3があればOK

■OS起動したら自動で起動するように設定
chkconfig postgresql on

■DB起動
service postgresql-9.3 initdb

vargrantを使って仮想環境構築

正直あんまりわからない。
けど手順だけ。

MAC OSX 10.7.5

VirtualBoxインストール
※インストールしたPC上に仮想的なPCを作成し、別のOSを実行できるソフト。
https://www.virtualbox.org/wiki/Downloads

■Vagrantインストール
http://downloads.vagrantup.com/

■boxイメージダウンロード
boxのサンプルリスト
http://www.vagrantbox.es/

vagrant box add ubuntu13.04 https://dl.dropboxusercontent.com/u/547671/thinkstack-raring64.box

初期化
vagrant init ubuntu13.04

起動
vagrant up

その他コマンド
# 状態確認
vagrant status
# スリープ
vagrant suspend
# 復帰
vagrant resume
# 終了
vagrant halt
# 起動・再起動
vagrant up
# 削除
vagrant destory

vagrant解読(1)

vagrantインストールすると

/usr/bin/vagrant

っていうコマンドができている。

/usr/bin/vagrant
はvagrantをインストールしたらできる

/Vagrant/bin/vagrant

シンボリックリンク


/Vagrant/bin/vagrant
こいつ何やってんだ?

なんかGEM_PATHとか
ゴニョゴニョ設定している。

で最後にこれ実行
${RUBY_EXECUTABLE}" "${VAGRANT_EXECUTABLE}" "$@"
※"$@"はシェルスクリプトで引数格納してる変数
 vagrant -v だと -v が格納されている。
→/Vagrant/embeded/bin/ruby /Vagrant/embeded/gems/bin/vagrant "$@"

/Vagrant/embeded/gems/bin/vagrant
rubyでなんか書いてる

 #!/vagrant-installer/staging/embedded/bin/ruby
 #
 # This file was generated by RubyGems.
 #
 # The application 'vagrant' is installed as part of a gem, and
 # this file is here to facilitate running it.
 #

require 'rubygems'
#→gemのライブラリー使う為に宣言

version = ">= 0"

if ARGV.first
  str = ARGV.first
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  if str =~ /\A_(.*)_\z/
    version = $1
    ARGV.shift
  end
end
#→引数をバイナリにencodeing

gem 'vagrant', version
#→gemにvagrantがあるかどうか?true返す

load Gem.bin_path('vagrant', 'vagrant', version)
#→load /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/bin/vagrant

<||

あー、ruby読むの時間かかるー。
早く慣れたい。