Unix シグナルについて

実行中のプロセスに対して、さまざまなイベントを通知するために送出されるものである。

【シグナルの確認】

kill- l 
HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2

【シグナル種類】

1	HUP	プロセスに再起動を通知する。
2	INT	プロセスに割り込みを通知する。(Ctrl+c)
3	QUIT	プロセスに終了を通知する(coreを作成する)。
9	KILL	プロセスに強制終了を通知する。
15	TERM	プロセスに終了を通知する。(デフォルト)
18	CONT	プロセスに再開を通知する。
19	STOP	プロセスに中断を通知する。
20	TSTP	プロセスにサスペンドを通知する。(Ctrl+Z)


kill 9 starman
これstarmanのプロセス殺す時によく使ってたけど、
starmanのプロセスに強制終了のシグナル送ってたのね。

INT プロセスに割り込みを通知する。(Ctrl+c)
めっちゃ使ってるし。

trap 'echo test' 2
ってすると
プロセスに割り込んだ時(Ctrl+c)に
testって出力された!

root# trap 'echo test' 2 
root# test 
test
test
test

指定したシグナルをトリガーにイベント発生させられるみたい。

解除したい時は
trap 2


参考ページ
http://shellscript.sunone.me/signal_and_trap.html

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読むの時間かかるー。
早く慣れたい。