linux

ポートを使用しているプロセスを調べる

lsofを使う $ lsof -i:22 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 503 apache 4u IPv6 147871264 0t0 TCP *:http (LISTEN) httpd 2552 apache 4u IPv6 147871264 0t0 TCP *:http (LISTEN) ...プロセスIDを指定するとプロセスが使用してい…

さくらvpsでs3のストレージをマウント

s3fsというソフトウェアを使用する 前準備 libxml2をインストール # yum -y install libxml2 libxml2-devel 前準備 fuseをインストール # wget http://sourceforge.net/projects/fuse/files/fuse-2.X/2.9.3/fuse-2.9.3.tar.gz # tar xvfz fuse-2.9.3.tar.gz …

さくらvpsでfluentd + mongodbを試す

apacheのアクセスログをfluentdを経由してmongodbへ よくあるパターンを1台のサーバで試してみた mongodbのインストール $ vi /etc/yum.repos.d/mongodb.repo [mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/o…

ファイルディスクリプタの変更

[root@vps1 ~]# diff /etc/security/limits.conf /etc/security/limits.conf.org 51,54d50 < root soft nofile 65536 < root hard nofile 65536 < * soft nofile 65536 < * hard nofile 65536

静的ルーティングでハマる

ルータ機器、IP変更後、別ネットワークの機器につながらない現象が発生。 サーバへのファイアウォール、NATの設定もいくら確認しても問題なさそう。でやっとこさ判明した原因は # route Kernel IP routing table Destination Gateway Genmask Flags Metric R…

centos5 xen仮想サーバの時間がずれる

必要があって調査したのでメモ。/etc/sysctl.conf で xen.independent_wallclock = 1としてもずれる場合、 /boot/grub/grub.confに kernel /boot/vmlinuz-2.6.18-238.9.1.el5xen ro root=LABEL=/ rhgb quiet divider=10 clocksource=acpi_pmとして、ブートロ…

CHECK_NRPE: Error - Could not complete SSL handshakeでハマる

ここ最近、nagiosから飛んでくるエラー CHECK_NRPE: Error - Could not complete SSL handshake.の原因を調査してた。ただ「繋がる時もあるし繋がらない時もある」というちょっと意味不明な状況。エラーで検索するも、エージェント(監視される)側のファイア…

sshログインの秘密鍵を複数管理

$HOME/.ssh/config に記載 Host xxxx IdentityFile ~/.ssh/id_rsa-xxxx Host yyyy IdentityFile ~/.ssh/id_rsa-yyyyのようにして管理できる。

grepで該当した行の前後行も表示

ログ洗う時に大変便利前後3行を表示 $ cat logfile | grep -3 'string'

localhostからremotehostのコマンドを実行

$ ssh user@remotehost ls - l的な何か。

自前認証局の作成

先ずは、設定ファイルのtemplateを拝借 # cd /etc/pki/ # mkdir myCA # cp tls/misc/CA myCA/ # cp tls/openssl.cnf myCA/ # echo 01 > myCA/crlnumber# vi myCA/CA #以下の項目を追加、編集 SSLEAY_CONFIG="-config /etc/pki/myCA/openssl.cnf" CATOP=/etc/…

haldが起動しない

haldaemonのメモリ使用量が異常だったので、再起動しようとすると起動しない。 どうやら、messagebusに依存しているようなので、 # /etc/init.d/messagebus start # /etc/init.d/haldaemon startとして起動する。

splitが便利

13,000行くらいのCSVファイルを1000行ずつ処理したかったので。 $ split -l 1000 src_fileとすると1000行ずつに分割されたファイル群が生成される。大変、便利。

redisインストール後のトラブル

会社の事務所が計画停電になったので、事務所サーバを再起動。で、OS起動時に以下のメッセージが。 # Server started. Redis version 2.6.9 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this is…

CentOSにmailコマンドインストール

何故か入っていなかったので。http://www.linuxquestions.org/questions/linux-networking-3/postfix-mail-command-not-found-258242/ 上記で入れ方が見つかるがつっと # yum install mailxでインストールおまけ 今日教えてもらったこと shellの入力コマンド…

CentOSにgitインストール

git cloneを使いたかったので。yumでepelのリポジトリを利用。 yum install --enablerepo=epel git*

couchdbのインストール

webコンパネがどんなものか見てみたかったので。 yumから。 # yum install couchdb # /etc/init.d/couchdb startport5984を使用するそうなので、FWを開放。 # vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5984 -j ACCE…

sambaインストール

yumでインストール # yum install samba # /etc/init.d/smb start # chkconfig smb on接続にはsmbaの管理するユーザが必要 # smbpasswd -a username New SMB password: Retype new SMB password: Added user username.

PHP5.4 pdo_pgsqlインストール

# yum install php54-devel # yum install php54-pgsql # pecl install pdo_pgsqlと実施。 checking for pg_config... not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation pathと怒られたので、 # yum in…

init.dスクリプトを作成

/etc/init.d/ 以下に配置するプロセス起動ファイルを作成 # vi /etc/init.d/myruner# chkconfig: 345 99 01 # description: my init.d file# chkconfig: runlevel 起動順番 終了順番 chkconfig --add serviceでrc.dにリンク貼る定義がこれ。実行ユーザ、コマ…

logwatchを標準出力

# logwatch --printで吐ける。 設定ファイルは /usr/share/logwatch/ 以下にある

nologinユーザーにsuする

例えばこんなapacheユーザ root # vipw apache:x:48:48:Apache:/var/www:/sbin/nologin普通にswitch userすると root # su - apache This account is currently not available.となるので、ログインシェルを渡すとswitch userできる root # su - apache --sh…

find mtimeオプション

よく忘れるので。 $ find ./ -mtime +7 -exec rm {} \; +7 で8日以上前 -7 で6日以内 7 で7日前 に修正されたファイルを削除

redmineのインストール

基本はRedmine 2.1をCentOS 6.3にインストールする手順で。 で、若干ハマったところ。yumでrubyをインストールしていたのだが、rubygemsのsetup時に # ruby setup.rb define_method name do |*args, &block| # TODO: really works on 1.8.7?versionが古いと…

普段使わないyumコマンド

Error: database disk image is malformed. と出たので、キャッシュを削除 # yum clean all実行中のままのyumトランザクションを終了 # yum install yum-utils # yum-complete-transaction指定ファイルが含まれるpkgを検索 # yum whatprovides */pg_stat_sta…

centos postgresql9.1 pg_stat_statementsを導入

SQLログの出力 log_statement = 'none' # none, ddl, mod, all none : 出力しない(デフォルト) ddl : DDLを出力 mod : DDLとDML all : 全てのSQL を設定する。設定後、log_directory, log_filenameの設定のファイルに実行SQLが吐かれる。スロークエリの出力 …

memcachedのインストール

リポジトリはremiで # rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi # cd /etc/yum.repos.d/ # wget http://rpms.famillecollet.com/remi-enterprise.repo # yum install --enablerepo=remi memcached # chkconfig memcached onでインスト…

SSL 2048bit鍵長の秘密鍵の作成

1024bit時と変わらず。 # openssl md5 * > rand.dat # openssl genrsa -rand rand.dat -des3 2048 > server.key 212 semi-random bytes loaded Generating RSA private key, 2048 bit long modulus .+++ ..................................................…

CentOS5にpostgresql9.2をインストール

リリースされたそうなので。リポジトリを追加 wget http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/pgdg-centos92-9.2-5.noarch.rpm rpm -ivh pgdg-centos92-9.2-5.noarch.rpmインストール yum install --enablerepo=pgdg92 postgresql92* postgresql9…

CentOSの言語設定

メモ EnglishからJapaneseに変更# vi /etc/sysconfig/i18n LANG="ja_JP.UTF-8" SYSFONT="lat0-sun16"# source /etc/sysconfig/i18n