レプリケーション運用検証 事前準備 RSA公開鍵の持ち合い
検証環境のサーバは3台
プライマリー 192.168.14.101
ホットスタンバイ 192.168.14.102
ホットスタンバイ 192.168.14.103
各サーバで下記のようにpostgresユーザのRSA鍵を作ります。
# vi /etc/passwd # mkdir /home/postgres # chown -R postgres:postgres /home/postgres # cd /var/lib/pgsql # mv ./.bash_history /home/postgres/ # mv ./.bash_profile /home/postgres/ # mv ./.psql_history /home/postgres/ # su - postgres $ cd $HOME $ pwd /home/postgres $ ssh-keygen -t rsa $ cd ./.ssh $ ls id_rsa id_rsa.pub
次に各サーバから他の2台のサーバへ公開鍵を渡します。
プライマリサーバ
# su - postgres $ scp /home/postgres/.ssh/id_rsa.pub root@192.168.14.102:/home/postgres/id_rsa.pub.901 $ scp /home/postgres/.ssh/id_rsa.pub root@192.168.14.103:/home/postgres/id_rsa.pub.901
ホットスタンバイ1台目
# su - postgres $ scp /home/postgres/.ssh/id_rsa.pub root@192.168.14.101:/home/postgres/id_rsa.pub.902 $ scp /home/postgres/.ssh/id_rsa.pub root@192.168.14.103:/home/postgres/id_rsa.pub.902
ホットスタンバイ2台目
# su - postgres $ scp /home/postgres/.ssh/id_rsa.pub root@192.168.14.101:/home/postgres/id_rsa.pub.903 $ scp /home/postgres/.ssh/id_rsa.pub root@192.168.14.102:/home/postgres/id_rsa.pub.903
受け取った公開鍵をauthorized_keysに追加します。
プライマリサーバ
# su - postgres $ cat /home/postgres/id_rsa.pub.902 >> /home/postgres/.ssh/authorized_keys $ cat /home/postgres/id_rsa.pub.903 >> /home/postgres/.ssh/authorized_keys
ホットスタンバイ1台目
# su - postgres $ cat /home/postgres/id_rsa.pub.901 >> /home/postgres/.ssh/authorized_keys $ cat /home/postgres/id_rsa.pub.903 >> /home/postgres/.ssh/authorized_keys
ホットスタンバイ2台目
# su - postgres $ cat /home/postgres/id_rsa.pub.901 >> /home/postgres/.ssh/authorized_keys $ cat /home/postgres/id_rsa.pub.902 >> /home/postgres/.ssh/authorized_keys
パスワードを使わずに鍵ファイルでログインできるか試します。
プライマリサーバ
# su - postgres $ ssh 192.168.14.102 $ exit logout Connection to 192.168.14.102 closed. $ ssh 192.168.14.103 $ exit logout Connection to 192.168.14.103 closed.
ホットスタンバイ1台目
# su - postgres $ ssh 192.168.14.101 Last login: Fri Sep 24 09:06:01 2010 from 192.168.14.103 $ exit logout Connection to 192.168.14.101 closed. $ ssh 192.168.14.103 Last login: Fri Sep 24 09:07:34 2010 from 192.168.14.101 $ exit logout Connection to 192.168.14.103 closed.
ホットスタンバイ2台目
# su - postgres $ ssh 192.168.14.101 Last login: Fri Sep 24 09:08:56 2010 from 192.168.14.102 $ exit logout Connection to 192.168.14.101 closed. $ ssh 192.168.14.102 Last login: Fri Sep 24 09:07:28 2010 from 192.168.14.101 $ exit logout Connection to 192.168.14.102 closed.
これで各サーバからパスワードを確認されないで
ログイン出来るようになりましたので
コマンドラインでrsync等が実行出来るようになります。