タグ: centos

ZFS ファイルシステム作成

ストレージプールの上にZFSファイルシステムを作ってみる。
オプションが色々あるらしい。詳細は ZFS のプロパティーの紹介 – Oracle Solaris ZFS 管理ガイド に。

とりあえず使ってみようと思ったのは
-o mountpoint=/mnt/media
-o compression=lz4
-o sharenfs=on
あたり。

# zfs create -o mountpoint=/mnt/media -o compression=lz4 -o sharenfs=on tank/media
cannot share 'tank/media': share(1M) failed
filesystem successfully created, but not shared

あうふ。
nfs はまだインストールしていなかったので、このザマよ。
でも、領域は出来たらしい。

# zfs list
NAME         USED  AVAIL  REFER  MOUNTPOINT
tank        1.18M  5.33T   208K  /tank
tank/media   181K  5.33T   181K  /mnt/media

うむ、出来た。

ZFSonLinux インストール

とりあえず、Minimumインストールしたら「yum update」はやっておく。

# yum install kernel-devel wget rpm-build gcc zlib-devel libuuid-devel bc lsscsi mdadm

で、必要な物をインストールしておく。
最新のファイルはZFS on Linuxにあります。

ココにEPEL7へのインストール方法が書いてあるけど、Beta だからかうまく行きませんでした。
というわけで、tar から入れていくことにします。

# wget http://archive.zfsonlinux.org/downloads/zfsonlinux/spl/spl-0.6.3.tar.gz
# wget http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-0.6.3.tar.gz

の2つをダウンロード。
SPLっていうのは「Solaris Porting Layer」の略らしい。

# tar zxvf spl-0.6.3.tar.gz
# cd spl-0.6.3
# ./configure
# make rpm
# rpm -Uvh *.x86_64.rpm

で、

kmod-spl-3.10.0-123.4.4.el7.x86_64-0.6.3-1.el7.centos.x86_64.rpm
kmod-spl-devel-0.6.3-1.el7.centos.x86_64.rpm
kmod-spl-devel-3.10.0-123.4.4.el7.x86_64-0.6.3-1.el7.centos.x86_64.rpm
spl-0.6.3-1.el7.centos.src.rpm
spl-0.6.3-1.el7.centos.x86_64.rpm
spl-debuginfo-0.6.3-1.el7.centos.x86_64.rpm
spl-dkms-0.6.3-1.el7.centos.noarch.rpm
spl-dkms-0.6.3-1.el7.centos.src.rpm
spl-kmod-0.6.3-1.el7.centos.src.rpm
spl-kmod-debuginfo-0.6.3-1.el7.centos.x86_64.rpm

が出来上がるので、

# rpm -Uvh *.x86_64.rpm

で、作成されたものをインストールする。
これで、SPLのインストールは完了。
続いてZFSのインストール。

# cd ..
# tar zxvf zfs-0.6.3.tar.gz
# cd zfs-0.6.3
# ./configure
# make rpm

で、

kmod-zfs-3.10.0-123.4.4.el7.x86_64-0.6.3-1.el7.centos.x86_64.rpm
kmod-zfs-devel-0.6.3-1.el7.centos.x86_64.rpm
kmod-zfs-devel-3.10.0-123.4.4.el7.x86_64-0.6.3-1.el7.centos.x86_64.rpm
libnvpair1-0.6.3-1.el7.centos.x86_64.rpm
libuutil1-0.6.3-1.el7.centos.x86_64.rpm
libzfs2-0.6.3-1.el7.centos.x86_64.rpm
libzfs2-devel-0.6.3-1.el7.centos.x86_64.rpm
libzpool2-0.6.3-1.el7.centos.x86_64.rpm
zfs-0.6.3-1.el7.centos.src.rpm
zfs-0.6.3-1.el7.centos.x86_64.rpm
zfs-debuginfo-0.6.3-1.el7.centos.x86_64.rpm
zfs-dkms-0.6.3-1.el7.centos.noarch.rpm
zfs-dkms-0.6.3-1.el7.centos.src.rpm
zfs-dracut-0.6.3-1.el7.centos.x86_64.rpm
zfs-kmod-0.6.3-1.el7.centos.src.rpm
zfs-kmod-debuginfo-0.6.3-1.el7.centos.x86_64.rpm
zfs-test-0.6.3-1.el7.centos.x86_64.rpm

この辺りが出来上がるので、

# rpm -Uvh *.x86_64.rpm

これでZFSのインストールも完了。

# shutdown -r now

で再起動しておく。

# cat /proc/filesystems
nodev sysfs
nodev rootfs
...
...
nodev mqueue
xfs
nodev zfs

こんなカンジで「nodev zfs」が出ていれば正常かと。
わぁい入ったぁ、ということで

# zpool status
no pools available

うむ。コマンドは認識している。

# parted -l
モデル: ATA WDC WD30EZRX-00D (scsi)
ディスク /dev/sda: 3001GB
...
モデル: ATA ST3000DM001-1ER1 (scsi)                                       
ディスク /dev/sdb: 3001GB
...
モデル: ATA ST3000DM001-1CH1 (scsi)
ディスク /dev/sdc: 3001GB

この3本をZFSに使用してみる。

# zpool create -f tank raidz sda sdb sdc
# zpool status
  pool: tank
 state: ONLINE
  scan: none requested
config:

	NAME        STATE     READ WRITE CKSUM
	tank        ONLINE       0     0     0
	  raidz1-0  ONLINE       0     0     0
	    sda     ONLINE       0     0     0
	    sdb     ONLINE       0     0     0
	    sdc     ONLINE       0     0     0

errors: No known data errors
# zpool list
NAME   SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
tank  8.12T  1.55M  8.12T     0%  1.00x  ONLINE  -

ストレージプールとやらは出来た、かな?

# df -h
ファイルシス            サイズ  使用  残り 使用% マウント位置
/dev/mapper/centos-root   225G  1.3G  224G    1% /
devtmpfs                  7.8G     0  7.8G    0% /dev
tmpfs                     7.8G     0  7.8G    0% /dev/shm
tmpfs                     7.8G  8.6M  7.8G    1% /run
tmpfs                     7.8G     0  7.8G    0% /sys/fs/cgroup
/dev/sdd1                 497M  128M  370M   26% /boot
tank                      5.4T  256K  5.4T    1% /tank

おお!RAID-Zだから5.4TBね。

では、このtankを色々と弄ってみることにする。

構成図 Ver.5

HDD が7つになったので構成をちょっと変更して、すべてをひとつに纏める。
250GB x 1 : BOOT
2TB x 3 + 3TB x 3 : ZFS-DATA

事前にバックアップを取っておかなくてはならないものは

  • /etc/sysconfig/iptables
  • /etc/exports
  • /etc/fstab
  • /etc/samba/smb.conf
  • /etc/httpd/conf/httpd.conf
  • /etc/httpd/conf.d/virtualhost.conf
  • /etc/php.ini
  • /etc/my.cnf
  • /var/spool/cron/root

ぐらいかな?

  1. SYSTEM INSTALL
    1. minimum install
  2. PREFERENCES
    1. vi /etc/profile
    2. date –set=’****/**/** **:**:**’
  3. NETWORK
    1. vi /etc/sysconfig/network-scripts/ifcfg-eth0
    2. vi /etc/sysconfig/iptables
    3. vi /etc/resolv.conf
  4. SELINUX
    1. vi /etc/selinux/config
  5. YUM
    1. vi /etc/yum.conf
  6. NTP
    1. yum install ntp
    2. vi /etc/ntp.conf
    3. /etc/init.d/ntpd start
    4. chkconfig ntpd on
    5. chkconfig ntpdate on
  7. KEYRING
    1. yum install openssh-clients
    2. ssh-keygen -t rsa
    3. mv /root/.ssh/id_rsa.pub /root/.ssh/id_rsa.pub.192.168.1.2
    4. scp /root/.ssh/id_rsa.pub.192.168.1.2 root@192.168.1.1:/root/.ssh/
    5. [ on 192.168.1.1 ]
      cat id_rsa.pub.192.168.1.2 >> authorized_keys
  8. WGET
    1. yum install wget
    2. vi /etc/wgetrc
  9. ZFS (Under Construction)
    1. zpool create tank sdb1
  10. FSTAB (Under Construction)
  11. NFS
    1. yum install rpcbind nfs-utils
    2. vi /etc/exports
    3. /etc/init.d/rpcbind start
    4. /etc/init.d/nfslock start
    5. /etc/init.d/nfs start
  12. SMB
    1. adduser samba-user
    2. passwd samba-user
    3. yum install samba
    4. pdbedit -a samba-user
    5. vi /etc/samba/smb.conf
    6. /etc/init.d/smb start
    7. chkconfig nmbd on
    8. chkconfig smbd on
  13. REPOSITORY
    1. MYSQL-COMMUNITY
      1. cd /tmp
      2. wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
      3. rpm -ivh mysql-community-release-el6-5.noarch.rpm
      4. vi /etc/yum.repos.d/mysql-community.repo
    2. RPMFORGE
      1. wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
      2. rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
      3. vi /etc/yum.repos.d/rpmforge.repo
    3. EPEL
      1. cd /etc/pki/rpm-gpg/
      2. wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
      3. vi /etc/yum.repos.d/epel.repo
    4. CENT-ALT
      1. cd /tmp
      2. wget http://mirror.sysadminguide.net/centalt/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
      3. rpm -ivh centalt-release-6-1.noarch.rpm
      4. vi /etc/yum.repos.d/centalt.repo
    5. NGINX
      1. cd /tmp
      2. wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
      3. rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
      4. vi /etc/yum.repos.d/nginx.repo
  14. LAMP
    1. HTTPD (Under Construction)
      1. yum install –enablerepo=CentALT httpd
      2. cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original
      3. vi /etc/httpd/conf/httpd.conf
      4. /etc/init.d/httpd start
      5. chkconfig httpd on
      6. htdigest -c /var/www/.htdigest ‘DigestAuthArea’ AuthUser
      7. vi /etc/httpd/conf.d/virtual.conf
      8. /etc/init.d/httpd restart
    2. PHP
      1. yum install php
      2. cp /etc/php.ini /etc/php.ini.original
      3. vi /etc/php.ini
      4. /etc/init.d/httpd restart
    3. MYSQL
      1. yum install –enablerepo=mysql56-community mysql
      2. cp /etc/my.cnf /etc/my.cnf.original
      3. vi /etc/my.cnf
      4. /etc/init.d/mysqld start
      5. chkconfig mysqld on
      6. mysql -u root -p
      7. > grant all privileges on *.* to username identified by ‘password’ with grant option;
      8. > quit
  15. READYMEDIA (formerly MINIDLNA)
    1. wget http://sourceforge.net/projects/minidlna/files/minidlna/1.1.3/minidlna-1.1.3_static.tar.gz/download
    2. tar -zxvf minidlna_1.1.3_static.tar.gz -C /
    3. vi /etc/minidlna.conf
    4. vi /etc/rc.d/init.d/minidlna
      ファイル自体は ココ にあります。拡張子は削除して使用。
    5. chmod 755 /etc/rc.d/init.d/minidlna
    6. chkconfig –add minidlna
    7. /etc/init.d/minidlna start
  16. MyDNS
    1. crontab -e
  17. BIND or PowerDNS (Under Construction)
  18. TRANSMISSION (Under Construction)
    1. yum install transmission
  19. GNOME DESKTOP
    1. yum groupinstall “X Window System” “デスクトップ”
    2. vi /etc/inittab
  20. PT3 (Under Construction)

自宅CentOS

なんとかして1台のサーバですべての用事を済まそう計画…

  1. minimum install
  2. date –set=’****/**/** **:**:**’
  3. vi /etc/sysconfig/network-scripts/ifcfg-eth0
  4. vi /etc/selinux/config
  5. vi /etc/sysconfig/iptables
  6. vi /etc/resolv.conf
    nameserver 192.168.1.1
  7. vi /etc/yum.conf (Proxy check only)
  8. yum install ntp openssh-clients wget rsync mlocate
  9. vi /etc/ntp.conf
    server 192.168.1.1 iburst
  10. /etc/init.d/ntpd start
  11. chkconfig ntpd on
  12. chkconfig ntpdate on
  13. ssh-keygen -t rsa
  14. cd /root/.ssh/
  15. mv id_rsa.pub id_rsa.pub.192.168.1.2
  16. scp id_rsa.pub.192.168.1.2 root@192.168.1.1:/root/.ssh/
  17. (on 192.168.1.1)
    cat id_rsa.pub.192.168.1.2 >> authorized_keys
  18. vi /etc/wgetrc (Proxy check only)
  19. vi /etc/profile
    HISTSIZE=5000
  20. cd /root
  21. wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
  22. rpm -ivh mysql-community-release-el6-5.noarch.rpm
  23. vi /etc/yum.repos.d/mysql-community.repo
  24. wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
  25. rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
  26. vi /etc/yum.repos.d/rpmforge.repo
  27. cd /etc/pki/rpm-gpg/
  28. wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
  29. cd /root/
  30. vi /etc/yum.repos.d/epel.repo
    [epel]
    name=Extra Packages for Enterprise Linux (EPEL)
    baseurl=http://ftp.riken.jp/Linux/fedora/epel/6/$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
  31. wget http://mirror.sysadminguide.net/centalt/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
  32. rpm -ivh centalt-release-6-1.noarch.rpm
  33. vi /etc/yum.repos.d/centalt.repo
    [CentALT]
    name=CentALT Packages for Enterprise Linux 6 - $basearch
    baseurl=http://mirror.sysadminguide.net/centalt/repository/centos/6/$basearch/
    enabled=0
    gpgcheck=0
  34. yum install –enablerepo=mysql-community,rpmforge,epel,CentALT httpd php mysql transmission kernel-devel unzip gcc ccid pcsc-lite pcsc-lite-devel pcsc-lite-libs perl-Gtk2
  35. yum update –enablerepo=mysql-community,rpmforge,epel,CentALT
  36. cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original
  37. vi /etc/httpd/conf/httpd.conf
    Timeout 20
    ServerName 192.168.0.2:80
    <Directory />
    AllowOverride All
    </Directory>
    AddDefaultCharset off
  38. /etc/init.d/httpd start
  39. chkconfig httpd on
  40. cp /etc/my.cnf /etc/my.cnf.original
  41. vi /etc/my.cnf
    sql_mode=NO_ENGINE_SUBSTITUTION
    # for Replication
    log-bin=mysql-bin
    server-id       = 168001002
    max_connections = 1000
    
    #log = /var/log/mysql/query.log
  42. /etc/init.d/mysqld start
  43. chkconfig mysqld on
  44. mysql -u root -p
  45. > grant all privileges on *.* to username identified by ‘password’ with grant option;
  46. > quit

[warn] module proxy_ajp_module is already loaded, skipping

# /etc/init.d/httpd restart
httpd を停止中:						[ OK ]
httpd を起動中: [Wed Jul 16 02:44:58 2014] [warn] module proxy_ajp_module is already loaded, skipping
							[ OK ]

普通に起動しているっぽいけどなんか「イラッ」とする。
[ proxy_ajp_module ]は既にロードされているよ、的なことなので httpd.conf を確認すると

vi /etc/httpd/conf/httpd.conf
196 LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

とあった。

もう一つは conf.d の中にある proxy_ajp.conf に書いてあった。

vi /etc/httpd/conf.d/proxy_ajp.conf
2 LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

確かに2ヶ所の指定はいらないので、httpd.conf 側をコメントアウトする。

CentALTリポジトリからForbiddenが返される…

CentALTをenableにしてアップデートしようとしても、Forbiddenが返されることに気づいた。
しかたがないので、CentALTをミラーしている[ sysadminguide.net ]に鞍替えする。
しかもそこにはリポジトリインストール用のRPMまで置いてあった…

  1. wget http://mirror.sysadminguide.net/centalt/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
  2. rpm -ivh centalt-release-6-1.noarch.rpm
  3. vi /etc/yum.repos.d/centalt.repo
    [CentALT]
    name=CentALT Packages for Enterprise Linux 6 - $basearch
    baseurl=http://mirror.sysadminguide.net/centalt/repository/centos/6/$basearch/
    enabled=0
    gpgcheck=0

これで今までどおり[ enablerepo=CentALT ]を付ければ動く。

analysis-kuromoji plugin もインストール

bin/plugin -install elasticsearch/elasticsearch-analysis-kuromoji

でインストールしようとしたら

# bin/plugin -install elasticsearch/elasticsearch-analysis-kuromoji
-> Installing elasticsearch/elasticsearch-analysis-kuromoji...
Trying https://github.com/elasticsearch/elasticsearch-analysis-kuromoji/archive/master.zip...
Downloading ....................................DONE
Installed elasticsearch/elasticsearch-analysis-kuromoji into /usr/share/elasticsearch/plugins/analysis-kuromoji
Message:
   Error while installing plugin, reason: IllegalArgumentException: Plugin installation assumed to be site plugin, but contains source code, aborting installation.

って言われた。
バージョンが書いてないとダメなのね。

bin/plugin -install elasticsearch/elasticsearch-analysis-kuromoji/2.1.0

で、行けました。

elasticsearch インストール

やろうやろうと思っているうちに 1.1 まで上がってた。
取り急ぎインストールだけでも。

事前にjavaをインストールしておかないと起動できません。

# yum install java

で、インストールしておく。

# wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.noarch.rpm

で、ダウンロードしたら、

# rpm -ivh elasticsearch-1.1.1.noarch.rpm

で、インストール。

# /sbin/chkconfig --add elasticsearch

で、chkconfigに追加してあげて、

# /etc/init.d/elasticsearch start

で、起動。

elasticsearch の plugin をProxy環境内からインストール

bin/plugin -install mobz/elasticsearch-head

で、プラグインをインストールしたいんだけど、

# bin/plugin -install mobz/elasticsearch-head
-> Installing mobz/elasticsearch-head...
Trying https://github.com/mobz/elasticsearch-head/archive/master.zip...
Failed to install mobz/elasticsearch-head, reason: failed to download out of all possible locations..., use -verbose to get detailed information

こんなカンジでインストール失敗。
例によってうちの環境だからProxyを通過できてないんだろうということで、
Unable to install plugin because of proxy の回答を参考に

bin/plugin -install mobz/elasticsearch-head -DproxyHost=***.***.***.*** -DproxyPort=****

で、Proxy経由のダウンロード&インストール。

よく見たら回答してる人、日本の方だった。
・・・今日注文したElasticsearchの本を翻訳した人だった!
スバラシス!

Cannot proceed because system tables used by Event Scheduler were found damaged at server start

MySQLは普通に動いているようにみえるのだけど、こんなエラーが出ている。
Google翻訳曰く、
「イベントスケジューラが使用するシステムテーブルがサーバ起動時に損傷が認められたため、続行できません」
だ、そうだ。
本番サーバなんですが。。。

レプリケーションしているのだが、レプリケーション先にはこのエラーは出ていない。

ググってみると、「mysql_upgrade」を実行しなさい、ということなので素直に従う。

# mysql_upgrade -h localhost -u root -p --verbose --force

途中で出てきたWarningは

Running 'mysqlcheck' with connection arguments: '--host=localhost'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--host=localhost'
Warning: Using a password on the command line interface can be insecure.
Running 'mysql_fix_privilege_tables'...
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--host=localhost'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--host=localhost'
Warning: Using a password on the command line interface can be insecure.

このくらい。あとは全部[ OK ]だった。
1分もかからずに終了したので、

/etc/rc.d/init.d/mysqld restart

で再起動。
おお!出なくなった!

ServerProtectに必要な32ビットライブラリのインストール

64bit版のCentOS6でServerProtectをインストールしようとすると

# /root/SProtectLinux-3.0.bin -s -S ********
Installing ServerProtect for Linux:
Unpacking...
Installing rpm file...
エラー: 依存性の欠如:
libz.so.1 は SProtectLinux-3.0-1362.x86_64 に必要とされています
libuuid.so.1 は SProtectLinux-3.0-1362.x86_64 に必要とされています

ということで、ストップします。

http://esupport.trendmicro.com/solution/ja-jp/1302795.aspx
この辺りで、32ビット版のライブラリが必要ということがわかるので、これらをインストール。
でも32ビット版ってどうやって指定するのかな?

ぐぐってみると、それぞれのライブラリの後ろに「i686」をつけて、32ビット版ということを明示してあげると吉らしい。

yum install zlib.i686 libuuid.i686

これでいいかな?いいみたい。