3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS6 で Zabbix 3.0 を動かす (PatchELF編)

3
Posted at

オフィシャルな RHEL6/CentOS6 用の Zabbix Server パッケージは提供されていません。
サポート外となっていることにはいくつか理由があるようですが、RHEL6/CentOS6上で Zabbix Server を動かしたいという需要はまだあるでしょう。

もっとも良い方法としては、ソースからビルドする方法です。
CentOS6 で Zabbix 3.0 を動かす (自力ビルド編)
ビルドの手間はかかりますが、パッケージとして導入するため。管理しやすいでしょう。
また、curl を更新して /usr/local に配置するなど、互換性に考慮した配置が取れます。

以前、ビルドせずに、手軽に動作を確認したいという向きに CentOS6 で Zabbix 3.0 を動かす (力業編)で、rpm パッケージと、対応する glibc や libmysqlclient、libcurl をほどいて配置して動かす方法を書きました。

yum および rpm コマンドは代替パスを指定してパッケージをインストールできるので、PatchELF と組み合わせるとパッケージ管理ができるようになります。そこで力業編をすこし手直しして、比較的管理しやすくしたものをご紹介します。

EPEL、 Remi パッケージのリポジトリを追加します。

# yum install epel-release
# yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# yum update

MySQLのパッケージを導入します。

# yum install --enablerepo remi mysql-libs compat-mysql51 mysql perl-DBD-MySQL mysql-server

いくつか CentOS 7 のパッケージが必要なので、yum で取得できるようにします。

# sed 's/CentOS-6/CentOS-7/; s/\]$/7]/
/\[base/,/^$/{
  /^$/ienabled=0
}
/\[updates/,/^$/{
  /^$/ienabled=0
}
/\[extras/,/^$/{
  /^$/ienabled=0
}' /etc/yum.repos.d/CentOS-Base.repo >/etc/yum.repos.d/CentOS7-Base.repo

downloadonly プラグインを入れて、パッケージのダウンロードだけできるようにします。

註) yum-3.2.29-69.el6.centos.noarch が入っていると不要なようです。

# yum install yum-plugin-downloadonly

依存する CentOS7 のパッケージを代替パスにインストールします。

註) パッケージのバージョンが新しくなっているかもしれません。

# mkdir download
# cd download
# mkdir /opt/centos7
# yum --installroot=/opt/centos7 --releasever=7 --disablerepo base,updates --enablerepo base7,updates7 --downloadonly --downloaddir=`pwd` install glibc net-snmp-libs libcurl mariadb-libs
# rpm -r /opt/centos7/ --nodeps -ivh glibc-2.17-106.el7_2.4.x86_64.rpm net-snmp-libs-5.7.2-24.el7.x86_64.rpm libcurl-7.29.0-25.el7.centos.x86_64.rpm mariadb-libs-5.5.47-1.el7_2.x86_64.rpm

RemiリポジトリからPHPを導入します。

# yum --enablerepo remi install php-common php php-mysql php-bcmath php-xml httpd-tools httpd php-cli php-pdo php-mbstring php-gd php-ldap

Zabbix を導入します。EL6のリポジトリを追加します。

# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm

EL7のリポジトリのパッケージを流用できるようにします。

# rpm -r /opt/centos7 -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
# sed 's/\]/7]/; s/enabled=1/enabled=0/' /opt/centos7/etc/yum.repos.d/zabbix.repo >/etc/yum.repos.d/zabbix7.repo
# yum clean all
# yum install zabbix-agent zabbix-get zabbix-sender zabbix-java-gateway zabbix-proxy-mysql zabbix-sender
# yum install --enablerepo zabbix7 zabbix-web zabbix-web-japanese zabbix-web-mysql

iksemel だけ特別扱いする必要がありました。

# yum --downloadonly --downloaddir=`pwd` install iksemel
# yum install iksemel
# rpm -r /opt/centos7 --nodeps -ivh iksemel-1.4-2.el6.x86_64.rpm

CentOS 7 用のパッケージを通常のパスにインストールします。

# rpm --nodeps -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-server-mysql-3.0.1-1.el7.x86_64.rpm

PatchELF でインタプリタとrpathを置き換えます。

# /usr/local/bin/patchelf --set-interpreter /opt/zabbix/lib64/ld-linux-x86-64.so.2 --set-rpath /opt/zabbix/lib64:/opt/zabbix/usr/lib64:/opt/zabbix/usr/lib64/mysql /usr/sbin/zabbix_server_mysql

確認します。

ldd /usr/sbin/zabbix_server

お掃除。

yum clean all

スタートアップスクリプト

CentOS7 では systemd を使用する形になっているため、旧来のスタートアップスクリプトはパッケージに含まれていません。

そこで Zabbix 2.4 のパッケージに含まれるものを使用します。

$ curl http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-server-2.4.7-1.el6.x86_64.rpm >zabbix-server-2.4.7-1.el6.x86_64.rpm
# rpm2cpio zabbix-server-2.4.7-1.el6.x86_64.rpm | (cd / && cpio -idmvu ./etc/init.d/zabbix-server)

以上です。

 

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?