LoginSignup
0
2

More than 5 years have passed since last update.

net-snmpをインストール(ソースからコンパイル)for CentOS7.3

Last updated at Posted at 2016-12-29

SNMPを利用する際に必要な、net-snmp。net-snmpをソースからコンパイルしインストールする方法を紹介します。
2016年12月現在の最新バージョンは、「5.7.3」ですが、Perl5.24に対応をしていないため、sourceforgeより直接新しいソースコードを取得します。

事前準備

あらかじめ以下のツールのインストールが必要です。
OpenSSL(1.0.x)をインストールする(ソースからコンパイル)for CentOS 7.2
Python2.xをインストール(ソースからコンパイル)for CentOS7.2
Perl5.8をインストールする(ソースからコンパイル) for CentOS7.2

インストール

SourceForgeのページから、最新のソースコードをダウンロードします。
尚、5.7.3を利用した場合、perl5.24の場合以下のようなエラーが出ます。

makeエラー内容
RGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2  -I/usr/local/lib/perl5/5.24.0/x86_64-linux/CORE   -c -o snmp_perl.lo snmp_perl.c
libtool: compile:  gcc -I../include -I. -I../agent -I../agent/mibgroup -I../snmplib -fno-strict-aliasing -g -O2 -Ulinux -Dlinux=linux -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -I/usr/local/lib/perl5/5.24.0/x86_64-linux/CORE -c snmp_perl.c  -fPIC -DPIC -o .libs/snmp_perl.o
In file included from ../include/net-snmp/utilities.h:42:0,
                 from ../include/net-snmp/net-snmp-includes.h:71,
                 from snmp_perl.c:9:
../include/net-snmp/library/int64.h:8:30: error: conflicting types for 'U64'
     typedef struct counter64 U64;
                              ^
In file included from /usr/local/lib/perl5/5.24.0/x86_64-linux/CORE/perl.h:2684:0,
                 from snmp_perl.c:6:
/usr/local/lib/perl5/5.24.0/x86_64-linux/CORE/handy.h:179:17: note: previous declaration of 'U64' was here
 typedef U64TYPE U64;
                 ^
make[1]: *** [snmp_perl.lo] エラー 1

そのため、souceforgeより、最新のソースコードをダウンロードします。
https://sourceforge.net/p/net-snmp/code/ci/master/tree/

image

cd /usr/local/src
wget --trust-server-name https://sourceforge.net/code-snapshots/git/n/ne/net-snmp/code.git/net-snmp-code-af04cde5792d0daa265245d28349c32347d3430e.zip
unzip net-snmp-code-af04cde5792d0daa265245d28349c32347d3430e.zip
cd net-snmp-code-af04cde5792d0daa265245d28349c32347d3430e
./configure  \
#--with-perl-modules=/usr/local/ \
--with-openssl=/usr/local/ssl \
#--with-python-modules=/usr/local
make
make install

./configure \
--with-python-modules=/usr/local/src/Python-2.7.13

ヒント1

make時に、
libperl.a: could not read symbols: Bad value
と出る場合、perlの./configureにパラメーターがないのが原因かもしれないので、以下を一度確認します。
Perl5.8をインストールする(ソースからコンパイル) for CentOS7.2

ヒント2

make[1]: Leaving directory `/usr/local/src/net-snmp-code-af04cde5792d0daa265245d28349c32347d3430e/agent'
make: *** [subdirs] Error 1
と出る場合、SELinuxが有効になっている可能性がある。

参考

0
2
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
0
2