ラベル centos の投稿を表示しています。 すべての投稿を表示
ラベル centos の投稿を表示しています。 すべての投稿を表示

2018年4月28日土曜日

ansible で yum update を実行

ansible を使って CentOSのアップデートを実行します。
一台だけだと、ansibleでやる必要性は感じないけど、対象が沢山ある時には便利かも。

[root@centos7 ansible]# ansible -i production cent7-1 -m yum -a "name='*' update_cache=yes state=latest"
[root@centos7 ansible]# ansible -i production cent7-1 -m shell -a "shutdown -r now"
cent7-1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Shared connection to 192.168.1.80 closed.\r\n",
    "unreachable": true
}
[root@centos7 ansible]# ansible -i production cent7-1 -m ping
cent7-1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
[root@centos7 ansible]#

  • アップデートを実行
  • システム再起動
  • ansible pingで稼働を確認


システム起動後の動作確認をansibleで

沢山のサーバを起動したあと、すべてのサーバにログインして確認コマンドを打つのは大変なので、ansibleで一括で実行してみます。

コマンドはこんな感じ
[root@centos7 ansible]# ansible -i production common-servers -m shell -a "ntpq -p"
cent7-1 | SUCCESS | rc=0 >>
     remote           refid      st t when poll reach   delay   offset  jitter 
==============================================================================
+cbr-jp-1.dn42.e 133.243.238.163  2 u   22   64  377    8.398   11.943   7.764
*date.no-such-ag 103.1.106.69     2 u   25   64  377    7.369   11.609   5.619
-b.hnd.pobot.net 71.80.83.115     2 u   35   64  377    9.420    6.175   4.915
+extendwings.com 133.243.238.164  2 u  101   64  376   11.825   12.024  40.148

cent7-2 | SUCCESS | rc=0 >>
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp1.jst.mfeed. 133.243.236.17   2 u  125  128  377    7.749    0.235   0.327
*ntp2.jst.mfeed. 133.243.236.17   2 u   32  128  377    7.388   -0.415   0.900

[root@centos7 ansible]#
 やっぱり、ansible便利だな~


ちなみに、インベントリ"-i"で指定している production ファイルはこんな感じに対象サーバを登録しています。
[common-servers]
cent7-2 ansible_host=192.168.1.82
cent7-1 ansible_host=192.168.1.80
[all:vars]
ansible_ssh_port=22
ansible_ssh_user=user02
ansible_ssh_pass=************

ansible_become=yes
ansible_become_pass=************

2017年12月9日土曜日

Ansibleで OS再起動後も task(playbook)を続ける

CentOSで  
yum: name='*' update_cache=yes state=latest
の後に再起動をしたくて、方法を探してました。
ググると、すぐにいくつかの方法が見つかるんだけど、こんなエラーが出てうまく動かせなかった。

TASK [common : restart system] *************************************************
fatal: [cent7-2]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Shared connection to 192.168.1.82 closed.\r\n", "unreachable": true}

その時の task の書き方がこんな感じ

- name: restart system
  command: shutdown -r now "Ansible triggered"
  async: 0
  poll: 0
  ignore_errors: true 
- name: wait for server to comeback
  local_action: wait_for host={{ inventory_hostname }} state=started delay=30 timeout=300 
で、問題を解決するため、さらに探して見つかった方法がこれ

https://stackoverflow.com/questions/29955605/how-to-reboot-centos-7-with-ansible
- name: restart system
  shell: |
    set timeout 10
    nohup bash -c "sleep 2s && reboot" &
- name: wait for server to comeback
  local_action: wait_for host={{ inventory_hostname }} state=started delay=30 timeout=60
- name: wait for comeback
  wait_for_connection:
    delay: 30
    timeout: 600

とりあえず、いい感じに動いてくれてます。

環境は
ansibleサーバ、ターゲットサーバ共に CentOS7.4
ansibleは ansible-2.4.1.0-1.el7.noarch

2017年10月30日月曜日

CentOS7 ローカルリポジトリ を作る

なんとなく CentOS7のローカルリポジトリを作ってみました。
で、作り方はいろんなところで紹介されているので 省略して リポジトリを同期したあとの ディスク使用量を書いておきます。

[root@centos7 ~]# du -sh /var/tmp/repo/*
7.7G     /var/tmp/repo/base
116M     /var/tmp/repo/centosplus
13G      /var/tmp/repo/epel
287M     /var/tmp/repo/extras
1.6G     /var/tmp/repo/updates
[root@centos7 ~]#


EPEL まで ローカルに持って来ても 23GB程度 これから増えるにしても 100GB程度の領域を確保してれば余裕かな~

2013年3月13日水曜日

centos 6.4 が起動しない

VirtualBox 上で動いてる、centos6.3 を centos6.4 へアップグレードしてみました。

yum でアップデートして、最初の再起動から、システムが起動しなくなってしまった (^_^;


試してみた事


  • single user mode での起動
    OK single user modeで、なにか出来ないか試してみます。

  • とりあえず、Virtual box addition の アンインストール
[root@cent6 /]# mount /dev/cdrom /mnt
[root@cent6 /]# cd /mnt
[root@cent6 mnt]# VBoxLinuxAdditions.run uninstall

[root@cent6 mnt]# shutdown -r now

 効果なし……

  • xorg.conf の削除
[root@cent6 /]# rm /etc/X11/xorg.conf

[root@cent6 mnt]# shutdown -r now

   OK システムが起動する様になりました (^_^)


追記
唐突に、xorg.conf を削除している事を不思議に感じてる方がいらっしゃる様なので、そこに至った経緯?を、書いておきます。
って、runlevel 5で起動するサービスの、どれがおかしくなってるのかを調べようとしたら、全部正常に起動してたので、じゃ、Xが起動出来てないだけかも。。。って思った次第です(^^;)


2013年1月5日土曜日

Lsyncd 監視対象ファイルの上限

Lsyncdが利用している inotifyが監視できるファイル数には上限があります。
この上限を超えると、Lsyncdは動作を停止 or 起動してくれません。

起動しようとすると、こんなエラーが発生します。(しました)

lsyncd: Error, Terminating since out of inotify watches.#012Consider increasing /proc/sys/fs/inotify/max_user_watches


ちなみに、上限値は以下で確認できます。
[root@cent6 ~]# cat /proc/sys/fs/inotify/max_user_watches
8192
[root@cent6 ~]#


これじゃ、ちょっと心もとないので、大きな値に変更します。
[root@centos6 ~]# cp -ip /etc/sysctl.conf{,.org}
[root@centos6 ~]# vi /etc/sysctl.conf

fs.inotify.max_user_watches = 819200

[root@centos6 ~]# /sbin/sysctl -p

かなり大きな値に設定していますが、システムへの負荷はあまり掛かっていないようです。

Lsyncd が 同期を開始するまでの遅延時間(待ち時間)

Lsyncd が、ファイルの変更を検知して、実際に同期を開始するまでに、ちょっと時間がかかります。

これは、lsyncdが意図的に遅延させているだけなので、設定で変更することができます。

ちなみに、標準では 15秒の遅延時間が設定されているようです。


で、上書きの方法は

コマンドラインで実行する場合は、以下のように -delay オプションを指定して、lsyncd を起動します。

# lsyncd -delay 3 -rsyncssh  ……


設定ファイルに書く場合は

settings の項目に、 delay オプションを設定すればOKです。


settings {
        logfile = "/var/log/lsyncd.log",
        statsfile = "/var/run/lsyncd.status",
        delay = "3",
}

2012年8月19日日曜日

ownCloud4.0.7

やはり日本語対応はいまいちの様子……

フォルダ名に日本語を使うと、アップロードが完了しない。
ま、実際にはアップロードされているんだけど、ブラウザ上で完了になりません。

また、ファイルはアップ出来ても、日本語のフォルダやファイル名があると、ギャラリーに写真が表示されないとか、一番使いたい機能で問題が出ちゃってます。

3系の安定版の方がよかったかもしれない (^_^;

英語だけにすれば良いんだけど、苦手なんだよな〜


2012年7月16日月曜日

CentOS 6.2 postfix + Dovecot + DRAC + drac plugin で pop beroe smtp

最近、pop before smtp をやりたいって話は聞かなくなってたんですが、頑なに pop before smtp にこだわる方が居たので調べてみました。

最近は、perlベースの Pop-before-smtp を使うのがはやりっぽいですね。

試してみると、maillogを監視してて、popの認証ログをベースに動くから、pop認証後にメールが送れるようになるまで、時間が掛りすぎました。


それで、昔ながらのDRACを使ってみようと思った次第です。

popしてから、メールの送信が許可されるまでの遅延が気にならなければ、 perl ベースの pop-before-smtp が簡単で良いかもしれません。



DRAC と dovecot、postfixの関係はこんな感じです

  1. dovecotでpop/imapの認証が成功
  2. dovecotからdrac_pluginが呼び出される
  3. drac_pluginはdracdにデータベースの更新を依頼
  • postfixはdracdが作成したデータベースを、中継可否を判断するデータベースとして利用する
動きは単純ですね。


導入の流れはこんな感じ

  1. BerkeleyDBの導入
  2. Dovecot-develの導入
  3. DRACの導入
  4. dovecot drac_pluginの導入
  5. dovecot がdrac_pluginを使うように設定
  6. postfix が、DRACが管理しているデータベースを参照するように設定

手順はこんな感じです

BerkeleyDB/Dovecot-develの導入
[root@cent6 ~]# yum install db4-devel dovecot-devel

DRACの導入
[root@cent6 ~]# mkdir drac
[root@cent6 ~]# mv drac.tar.Z drac
[root@cent6 ~]# cd drac
[root@cent6 drac]# tar zxf drac.tar.Z
[root@cent6 drac]# vi Makefile

#### Makefile for drac

## Tuneables

# Paths

##INSTALL = /usr/ucb/install
INSTALL = install
EBIN = /usr/local/sbin
MAN = /usr/local/man/man

# OS-Dependant settings

# Choose one of this pair...
# -DTI_RPC # Transport-independant RPC
# -DSOCK_RPC # Socket RPC

# Choose one of this pair...
# -DFCNTL_LOCK # fcntl() locking
# -DFLOCK_LOCK # flock() locking

# Choose one of this pair...
# -DSYSINFO # hostname from sysinfo()
# -DGETHOST # hostname from gethostname()

# If rpcgen -C is specified below...
# -DDASH_C # ANSI-C mode

# Settings for postfix and exim

# Do not set these for sendmail
# -DREQ_HASH # requires hash format
# -DCIDR_KEY # keys in CIDR format
# -DTERM_KD # keys and data nul-terminated

##DEFS = -DTI_RPC -DFCNTL_LOCK -DSYSINFO
DEFS = -DSOCK_RPC -DFCNTL_LOCK -DGETHOST -DDASH_C -DTERM_KD

# Compiler flags
CC = gcc
RANLIB = :
##CFLAGS = $(DEFS) -g -I/usr/local/src/db/db-4.1.25/build_unix
CFLAGS = $(DEFS) -g -fPIC
#CFLAGS = $(DEFS) -g -I/usr/local/src/db/db-3.1.17/build_unix
#CFLAGS = $(DEFS) -g -I/usr/local/src/db/db-2.4.14/Unix
#CFLAGS = $(DEFS) -g -I/usr/local/src/db/db.1.85/PORT/sunos.5.2/include
##LDLIBS = -L/usr/local/src/db/db-4.1.25/build_unix -lnsl -ldb-4.1
LDLIBS = -ldb
#LDLIBS = -L/usr/local/src/db/db-3.1.17/build_unix -lnsl -ldb
#LDLIBS = -L/usr/local/src/db/db-2.4.14/Unix -lnsl -ldb
#LDLIBS = -L/usr/local/src/db/db.1.85/PORT/sunos.5.2 -lnsl -ldb
##TSTLIBS = -L. -ldrac -lnsl
TSTLIBS = -L. -ldrac
##RPCGENFLAGS =
RPCGENFLAGS = -C -I
#RPCGENFLAGS = -C

# Man sections
MANLIB = 3
##MANADM = 1m
MANADM = 8

~~~~~~~~~~~~~~~~~

[root@cent6 drac]# make
[root@cent6 drac]# make install
install -c -o bin -g bin -m 0755 rpc.dracd /usr/local/sbin
[root@cent6 drac]# cp drac.h /usr/local/include/
[root@cent6 drac]# cp libdrac.a /usr/local/lib

dovecot drac_pluginの導入
[root@cent6 drac]# cd ../dovecot2-drac
[root@cent6 dovecot2-drac]# vi Makefile

##DOVDIR:=../dovecot-2.0.13
DOVDIR:= /usr/include/dovecot
LIBS:=-ldrac
LDFLAGS:=-L/usr/local/lib

CFLAGS=-Wall -W -shared -fPIC -DHAVE_CONFIG_H -I$(DOVDIR) \
        -I$(DOVDIR)/src/lib \
        -I$(DOVDIR)/src/lib-index \
        -I$(DOVDIR)/src/lib-mail \
        -I$(DOVDIR)/src/lib-storage \
        -I$(DOVDIR)/src/lib-storage/index \
        -I$(DOVDIR)/src/lib-storage/index/maildir

all: drac_plugin.so

drac_plugin.so: drac-plugin.c
        $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS)

clean:
        @rm -f *.so *.o

[root@cent6 dovecot2-drac]# make

cc -Wall -W -shared -fPIC -DHAVE_CONFIG_H -I/usr/include/dovecot -I/usr/include/dovecot/src/lib -I/usr/include/dovecot/src/lib-index -I/usr/include/dovecot/src/lib-mail -I/usr/include/dovecot/src/lib-storage -I/usr/include/dovecot/src/lib-storage/index -I/usr/include/dovecot/src/lib-storage/index/maildir -L/usr/local/lib drac-plugin.c -o drac_plugin.so -ldrac

32bitの場合
[root@cent6 dovecot2-drac]# cp -pi drac_plugin.so /usr/lib/dovecot/

64bitの場合
[root@cent6 dovecot2-drac]# cp -pi drac_plugin.so /usr/lib64/dovecot/


dovecotの設定変更
[root@cent6 dovecot2-drac]# vi /etc/dovecot/conf.d/10-mail.conf

# Space separated list of plugins to load for all services. Plugins specific to
# IMAP, LDA, etc. are added to this list in their own .conf files.
#mail_plugins =
mail_plugins = drac


[root@cent6 dovecot2-drac]# vi /etc/dovecot/conf.d/90-plugin.conf

plugin {
  #setting_name = value
dracdserver = localhost
dracdtimeout = 60
}

[root@cent6 dovecot2-drac]#

dracの起動
[root@cent6 dovecot2-drac]# /usr/local/sbin/rpc.dracd -e 5 /etc/postfix/drac.db

-e 5 : DRACのデータベースでの存在期間(min)
/etc/postfix/drac.db : データベースファイルの場所
※rpc.dracdが起動できない場合、rpcbindが導入・起動されていることを確認してください。

dracd起動ファイルの例
#!/bin/bash
# chkconfig: - 90 25
### BEGIN INIT INFO
# Provides: rpcdrac
# Short-Description: Dynamic Relay Authorization Control
# Description: Dynamic Relay Authorization Control
### END INIT INFO

. /etc/rc.d/init.d/functions
prog="/usr/local/sbin/rpc.dracd"
timeout="5"
conf="/etc/postfix/drac.db"
pidfile="/var/run/rpc.dracd.pid"

RETVAL=0

start() {
echo -n "Starting $prog:"
daemon $prog -e $timeout $conf
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $pidfile
return $RETVAL
}
stop() {
echo -n "Stopping $prog:"
killproc $prog
RETVAL=$?
echo
rm -f $pidfile
return $RETVAL
}
case $1 in
start ) start ;;
stop ) stop ;;
restart) stop && start ;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac


postfixの設定変更
※下の方法だけじゃなくて、いろんな参照のさせ方があると思います。
[root@cent6 dovecot2-drac]#  vi /etc/postfix/main.cf


mynetworks = check_client_access btree:/etc/postfix/drac


[root@cent6 dovecot2-drac]#

と、こんな感じでした。


2015/7/12 追記
・以下のエラーに対応

[root@cent6-64 dovecot2-drac]# make
cc -Wall -W -shared -fPIC -DHAVE_CONFIG_H -I/usr/include/dovecot -I/usr/include/dovecot/src/lib -I/usr/include/dovecot/src/lib-index -I/usr/include/dovecot/src/lib-mail -I/usr/include/dovecot/src/lib-storage -I/usr/include/dovecot/src/lib-storage/index -I/usr/include/dovecot/src/lib-storage/index/maildir -L/usr/local/lib drac-plugin.c -o drac_plugin.so -ldrac
/usr/bin/ld: /usr/local/lib/libdrac.a(dracauth.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libdrac.a: could not read symbols: Bad value
collect2: ld はステータス 1 で終了しました
make: *** [drac_plugin.so] エラー 1
[root@cent6-64 dovecot2-drac]#

・起動ファイルサンプル追加

2012年6月30日土曜日

ownCloud 4.0.4 に アップグレード

CentOS 6.2 の上に作ってた、ownCloudのアップグレードを実施してみました。

手順はこんな感じ

ownClownのダウンロード

[root@centos6 ~]# wget http://download.owncloud.org/releases/owncloud-4.0.4.tar.bz2
--2012-06-30 10:58:38--  http://download.owncloud.org/releases/owncloud-4.0.4.tar.bz2
Resolving download.owncloud.org... 50.30.42.17
Connecting to download.owncloud.org|50.30.42.17|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://owncloud.org/releases/owncloud-4.0.4.tar.bz2 [following]
--2012-06-30 10:58:39--  http://owncloud.org/releases/owncloud-4.0.4.tar.bz2
Resolving owncloud.org... 50.30.42.17
Reusing existing connection to download.owncloud.org:80.
HTTP request sent, awaiting response... 200 OK
Length: 4616904 (4.4M) [application/x-bzip]
Saving to: “owncloud-4.0.4.tar.bz2”

100%[======================================>] 4,616,904    373K/s   in 15s

2012-06-30 10:58:54 (309 KB/s) - “owncloud-4.0.4.tar.bz2” saved [4616904/4616904]

[root@centos6 ~]#

ファイルの展開
[root@centos6 ~]# tar jxf owncloud-4.0.4.tar.bz2

設定・データの移行
[root@centos6 ~]# cp -Rpf owncloud /var/www/owncloud-4.0.4
[root@centos6 ~]# cd /var/www/
[root@centos6 www]# cp -Rp owncloud/config/* owncloud-4.0.4/config/
cp: overwrite `owncloud-4.0.4/config/config.sample.php'? y
[root@centos6 www]# cp -Rp owncloud/data/ owncloud-4.0.4/

ファイルの入れ替え
[root@centos6 www]# mv owncloud owncloud-old
[root@centos6 www]# mv owncloud-4.0.4/ owncloud

オーナー変更
[root@centos6 www]# chown -R apache:apache owncloud


アップグレードして思った事。。。

ファイルやフォルダの名前に日本語を使わなければ、結構ちゃんと動いてくれる。
日本語への対応は、もっと先になるのかな~


2012年5月28日月曜日

apacheでホスト名が確認できない時のエラー

ちゃんと設定してないApacheは、よくこんなエラーが出ます。

Starting httpd: httpd: apr_sockaddr_info_get() failed for centos6.example.co.jp
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName


このエラーを、てっとり早く解消したい場合は、httpd.conf 内の ServerName ディレクティブに、自ホストのFQDNを設定してください。

こんな感じ

ServerName centos6.example.co.jp

2012年5月27日日曜日

zlib-devel がない時のエラー(メモ)

こんな感じのエラーが出た場合

checking pcre install prefix... no
checking for the location of zlib... configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
ERROR: `/var/tmp/zip/configure' failed

zlibの開発環境(lib,includeとか、、)をインストールすれば良い

[root@centos6 ~]# yum -y install zlib-devel

2012年5月23日水曜日

ownCloud 4.0.0 on CentOS6.2

とりあえず、ブラウザで利用する時に、ファイル名の先頭が2byte文字の場合に、文字化けが発生する問題が解決されているみたいです。

これで、やっと使ってみれそうな予感



http://owncloud.org/install/

CentOS 6.2 に、インストールした時のログはこんな感じです。
http://www.kichise.com/owncloud4-0-0-on-centos6-2

2012年5月2日水曜日

CentOS6.2 に ownCloud をインストールしてみた

作ってみたけど、日本語のファイル名を使う場合は、今のところ使い物にならないみたいです。

WindowsにownCloudのクライアントを入れて、WindowsとownCloudを同期させてみたんだけど、
クライアントの指定したディレクトリに放り込んだ、日本語で名前を付けたファイルが、ことごとく文字化けさせられてしまいます。

そう、WebUI で見た時だけ化けるんならまだしも、元ファイルのファイル名まで化けてしまうのです……
こまったモノだ ^^;


で、
インストール自体は結構簡単でした。
こんな感じで、インストール出来ると思われます。

準備


  • iptables と selinux を停止(無効化)
  • 作業用ディレクトリの作成
  • パッケージのダウンロード

[root@owncloud ~]# mkdir owncloud
[root@owncloud ~]# cd owncloud/
[root@owncloud owncloud]# wget http://owncloud.org/releases/owncloud-3.0.2.tar.bz2

ownCloudのインストール

[root@owncloud owncloud]# yum -y install php php-xml php-mbstring php-gd php-mysql php-pear php-devel
[root@owncloud owncloud]# yum -y install libzip libzip-devel
[root@owncloud owncloud]# yum -y install pcre pcre-devel
[root@owncloud owncloud]# pecl install zip

[root@owncloud owncloud]# vi /etc/php.ini
extension=zip.so            <- この設定を追加

[root@owncloud owncloud]# tar jxf owncloud-3.0.2.tar.bz2
[root@owncloud owncloud]# cp -r owncloud /var/www/
[root@owncloud owncloud]# chown -R apache:apache /var/www/owncloud/

MySQLの準備

[root@owncloud etc]# cp my.cnf my.cnf.org
[root@owncloud etc]# cp /usr/share/mysql/my-medium.cnf my.cnf
cp: `my.cnf' を上書きしてもよろしいですか(yes/no)? y
[root@owncloud etc]# vi my.cnf


# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password       = your_password
port            = 3306
socket          = /var/lib/mysql/mysql.sock

default-character-set = utf8

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

default-character-set = utf8

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# binary logging format - mixed recommended
binlog_format=mixed

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id       = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

default-character-set = utf8

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

default-character-set = utf8

[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
[root@owncloud etc]


[root@owncloud etc]# service mysqld start
~~~~~省略~~~~~

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
mysqld を起動中:                                           [  OK  ]
[root@owncloud etc]#


データベースの作成

とりあえず、こんなふざけた設定で作ってみます^^;
管理者パスワードpassword
DB名owncloud
DBユーザ名owncloud
DBユーザのパスワードmy_password


[root@owncloud etc]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.61-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.01 sec)

mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> select host,user,password from mysql.user;
+------------------------+------+----------+
| host                   | user | password |
+------------------------+------+----------+
| localhost              | root |          |
| owncloud.example.co.jp | root |          |
| 127.0.0.1              | root |          |
| localhost              |      |          |
| owncloud.example.co.jp |      |          |
+------------------------+------+----------+
5 rows in set (0.00 sec)

mysql> drop database test;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)

mysql> select host,user,password from mysql.user;
+------------------------+------+----------+
| host                   | user | password |
+------------------------+------+----------+
| localhost              | root |          |
| owncloud.example.co.jp | root |          |
| 127.0.0.1              | root |          |
+------------------------+------+----------+
3 rows in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> set password = password('password');
Query OK, 0 rows affected (0.00 sec)

mysql> create database owncloud character set utf8;
Query OK, 1 row affected (0.00 sec)

mysql> create user 'owncloud'@'localhost' identified by 'my_password';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on owncloud.* to 'owncloud'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@owncloud etc]#


ownCloudの設定

  • Webにアクセス
  • Advanced を選択
  • MySQLを選択
  • DBのパラメタを設定
  • Finish setup をクリック

設定変更
大きなファイルのアップロードを許可する
標準では、phpで2MBに制限されている
php.ini に以下の設定を行う事でアップロードサイズを変更できる。

php.iniをこんな感じに編集して、httpdを再起動する。

    727 ; Maximum size of POST data that PHP will accept.
    728 ; http://www.php.net/manual/en/ini.core.php#ini.post-max-size
    729 ;;post_max_size = 8M
    730 post_max_size = 100M

    877 ; Maximum allowed size for uploaded files.
    878 ; http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
    879 ;;upload_max_filesize = 2M
    880 upload_max_filesize = 80M


追記

2012/05/12 : ownCloud3.0.2 から 3.0.3へアップデートしたけど、日本語の文字化けは治らず orz

2012年1月14日土曜日

CentOS6.2 の SSSD で LDAP filter を設定する

SSSDを使って、LDAP連携をやってるんだけど、特定の属性値を持ったIDだけを連携対象に
したいと思って、ちょっと調べてみました。

結果は、微妙……

manにもあるとおり、こんな設定を入れる事で、認証の制限は出来ました。
access_provider = ldap
ldap_access_filter = memberOf=cn=allowedusers

でも、ユーザーとしては、存在している事になってしまいます。
例えば、id user01 とか、getent passwd でユーザー情報が確認出来てしまいます。

ログイン出来なければ良いシステムであれば、これでも良いんだけど、例えばメールサーバ
だと、pop/imap等でメールを取り出す事は出来ないけど、送られてきたメールはサーバが
受信してしまいます。

これでは、メールを送ってくれた人も、メールが届いていない事に気づけないし困ってしまいます。

という事で、現時点で、LDAP上のアカウントのうち、システムを利用できるユーザーを、適当な
ldap filterを使って制限を行いたい場合は、sssdは使わずに、旧来の nslcd を使う方法を取り、
nslcd.conf と pam_ldap.conf でfilterを掛ける必要がありそうです。



ちなみに、SSSDの最新版(1.7系)では、LDAP filterを柔軟に適用出来るようです。
SSSDは、まだまだ発展途上といったところでしょうか。。。