デーモンごとにulimitで設定した値を確認する

忘れないようにメモ。

あるデーモンにulimitを設定したい場合、起動スクリプトにulimitを記載する。

これでデーモン起動時にどうしたら値が設定されたことを確認できるかなーって話。

ユーザだったらulimit -nとか叩けば値が返ってくるのだろうけど。

 

答えは/proc/pid/limitsをcatすればわかった。

 

/etc/init.d/mysqlにulimit -n xxxとか追記。

どの場所に追記すれば良いか試してないけど、startとかする前でよいと思われ。

 

ちなみにulimitの参考は以下から。

Linuxコマンド集 - 【 ulimit 】 コマンドに割り当てる資源を制限する:ITpro

 

★あげる前

[root@mysql001 user]# cat /proc/1088/limits | grep "open files"
Max open files 5000 5000 files

 

★結構先頭のほうに追記してみた

 

[root@mysql001 user]# grep -n -C 3 ulimit /etc/init.d/mysql
42-
43-# If you change base dir, you must also change datadir. These may get
44-# overwritten by settings in the MySQL configuration files.
45:ulimit -n 10240
46-
47-basedir=
48-datadir=

 

 

★あげた後

 [root@mysql001 user]# /etc/init.d/mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@mysql001 user]#
[root@mysql001 user]# ps axuf | grep mysql
root 1431 0.0 0.0 107456 912 pts/0 S+ 23:57 0:00 \_ grep mysql
root 1294 0.0 0.1 106192 1504 pts/0 S 23:57 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/mysql001.pid
mysql 1407 2.0 44.4 1077948 453928 pts/0 Sl 23:57 0:00 \_ /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/mysql001.err --pid-file=/var/lib/mysql/mysql001.pid
[root@mysql001 user]#
[root@mysql001 user]# cat /proc/1407/limits | grep "open file"
Max open files 10240 10240 files

 

反映されたことが確認できたよー!

Macでansible sshできない解決編

ansible.cfgの書き方がわかった。

以下のサイトを参考。

https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg

 

[default] を頭につければよいみたい。

よし、実行。

 

ansible -i inventory vm001.example.local -m ping

vm001.example.local | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue

 

あれ?やっぱり鍵認証をしているみたい。。。

よくよく調べると以下のオプションをつければ、パスワード認証になるみたい。

 

--ask-pass

 

よし!再実行!

 

ansible -i inventory vm001.example.local -m ping --ask-pass --ask-sudo-pass
SSH password:
vm001.example.local | FAILED => to use the 'ssh' connection type with passwords, you must install the sshpass program

 

むーおかしい。

さらに調べると以下のような記事が。

 

Ansible OS X Mavericks You Must Install the sshpass Program

 

OS X だと、sshpassがないんだね。

ブログにそって、sshpassをインストールし、実行するとようやくできた〜。

疲れた。。。

 

ansible -i inventory vm001.example.local -m ping --ask-pass
SSH password:
vm001.example.local | success >> {
"changed": false,
"ping": "pong"
}

Macでansibleをやってみたけど

ansibleの簡単な講習をうけたので、ぜひ使おうということで、Macに入れてみた。

 

インベントリファイルに記載して、いざ実行。

 

ansible -i inventory dev001.example.local -m ping


The authenticity of host 'dev001.example.local (192.168.1.100)' can't be established.
RSA key fingerprint is 22:85:51:e4:1f:64:1d:05:75:04:2e:ed:d3:62:1f:4e.
Are you sure you want to continue connecting (yes/no)? yes
dev001.example.local | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue

 

あれ?おかしい。

どうもデフォルトではクライアントのいまのユーザ名で接続して、ダメだったら.sshを見に行ってカギを使ってる?

 

ansible.cfgをつくってないからかなー。デフォルトは/etc/配下だって書いてあるサイトがあったけど、うちのMac上はない。

仕方ないから、よくわからないけど、手で作ってみた。

 

cat ./ansible.cfg
remote_user=testuser

 

これだけのファイル。

 

実行してみたら、以下のエラーがでた。。。。。

ConfigParser.MissingSectionHeaderError: File contains no section headers.

 

やっぱりansible.cfgの書き方が悪いみたい。。

うちのMacにはデフォルトのansible.cfgは入ってないみたいだし。

だれか、デフォルトのansible.cfgの全文をください。。

 

KVMサーバで起動時にゲストOSを自動起動する。

ldapサーバとか他のサーバの縁の下の力持ち的な役割をするサーバは、母艦の起動と同時に起動しておきたい。

そんなときは以下のコマンドで大丈夫だった。

 

virsh autostart xxxxx

xxxxはドメイン

 

忘れないようメモ。

CentOS 6.5 で ldapサーバを構築する

以下のサイトを参考にして途中までうまくいっていたんだけど、TLS対応するところで、はまってしまった。。

 

CentOS6 OpenLDAPのインストールと基本設定

 

以下のようなメッセージが出て肝心のkeyなどが設定できない。

 


modifying entry "cn=config"
ldap_modify: Inappropriate matching (18)
additional info: modify/add: olcTLSCertificateFile: no equality matching rule

 

 

うーん。どうしよ。。

KVMサーバを構築する

KVMサーバを構築したくて、以下のページを参考に作ってみた。

 

KVMで仮想マシンを作成 | OSSでLinuxサーバ構築 | OSS Fan

 

qemu-kvmコマンドを使用して、OSをインストールしたらなぜか

リブートするたびに再インストールされる。。

 

libvirtへの登録がうまくいってないのかなーというところ。

仕方ないので、libvirt仮想マシンを作成。

うまくいったみたいなんだけど、vnc仮想マシンにつながらない。。。
netstatで確認したら待ち受けが127.0.0.1みたいなんだよね。

これはブリッジの設定がないからいけないんだと思い、以下のページを参考に
ブリッジの設定をした。

 

KVMのホストOS(CentOS)のネットワークをブリッジ化する設定 – FlatLabs

 

それで気を取り直して再度libvirtコマンドで仮想マシンを作成。

 

virt-install --name server001 --vcpus 1 --ram 1024 \

--disk path=/mnt/hdd0/images/server001.img,size=40,sparse=true \

--network bridge=br0 --graphics vnc --os-variant rhel6 \

--cdrom /mnt/hdd0/iso/CentOS-6.5-x86_64-bin-DVD1.iso

 

それでも相変わらず待ち受けIPは127.0.0.1

 

googleセンセイで調べたら、以下のページに書いてあった。

 

KVMゲストをVNCでGUIインストール - mikedaの日記

 

libvirtのqume.confを編集しないとだめだったんだね。

 

再度インストールコマンドを実行すると、VNCでつながった。

めでたしめでたし。