Difference between revisions of "Compiling ipvsadm on different Linux distributions"

From LVSKB
Jump to: navigation, search
m (Red Hat Enterprise Linux 3)
(Cannot find kernel source directory)
 
(4 intermediate revisions by 3 users not shown)
Line 32: Line 32:
 
Note that ipvsadm-1.21-11.src.rpm is for IPVS 1.0.12 or later, IPVS 1.0.12 is in the Linux kernel 2.4.28 or later 2.4.xx versions.
 
Note that ipvsadm-1.21-11.src.rpm is for IPVS 1.0.12 or later, IPVS 1.0.12 is in the Linux kernel 2.4.28 or later 2.4.xx versions.
  
== Red Hat Enterprise 4 ==
+
== Red Hat Enterprise Linux 4 ==
 +
 
 +
On Red Hat Enterprise Linux 4, make sure that kernel-source rpm is installed at system (as showed at http://kbase.redhat.com/faq/FAQ_85_5109.shtm).
 +
 
 +
<pre>
 +
# up2date redhat-rpm-config rpm-build kernel-utils
 +
 
 +
# up2date --get-source kernel
 +
 
 +
# rpm -ivh /var/spool/up2date/kernel*.src.rpm
 +
 
 +
# cd /usr/src/redhat/SPECS
 +
 
 +
# rpmbuild -bp --target=i686 kernel-2.6.spec
 +
 
 +
# cp -a /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9 /usr/src
 +
 
 +
# ln -s /usr/src/linux-2.6.9 /usr/src/linux
 +
</pre>
  
On Red Hat Enterprise Linux 4, make sure that kernel-source rpm is installed at system.
 
[root@cheetah src]# rpm -q kernel-source
 
kernel-source-2.6.9-42.0.3.EL
 
[root@cheetah src]# pwd
 
/usr/src
 
[root@cheetah src]# ln -s linux-2.6.9-42.0.3.EL linux
 
  
 
Then, we can build the ipvsadm-1.24 rpm in the following command:
 
Then, we can build the ipvsadm-1.24 rpm in the following command:
 
  rpmbuild --rebuild ipvsadm-1.24-6.src.rpm
 
  rpmbuild --rebuild ipvsadm-1.24-6.src.rpm
 +
 +
And install using:
 +
rpm -ivh /usr/src/redhat/RPMS/i386/ipvsadm-1.24-6.i386.rpm
 +
 +
== Red Hat Enterprise Linux 5 ==
 +
 +
== Red Hat Enterprise Linux 6 ==
  
 
== Compiling Error Analysis ==
 
== Compiling Error Analysis ==
Line 179: Line 198:
 
The problem is that compiler cannot find the kernel source directory. The fix is to make a symbolic link of kernel source directory to /usr/src/linux.
 
The problem is that compiler cannot find the kernel source directory. The fix is to make a symbolic link of kernel source directory to /usr/src/linux.
  
 +
 +
'''Problems when make''' :
 +
make error :  can't find file  'netlink/netlink.h'
 +
 +
'''Solution''':    install the libnl and popt develop packages
 +
<pre>
 +
#yum install libnl* popt*
 +
</pre>
  
 
[[Category:IPVS]]
 
[[Category:IPVS]]

Latest revision as of 09:11, 17 March 2012

Introduction

Since IPVS interface to user-space is different in different Linux kernel versions, there are different versions of ipvsadm for IPVS inside the different Linux kernel versions.

For IPVS inside the Linux kernel 2.6, you need to use ipvsadm version 1.24 or later.

For IPVS inside the Linux kernel 2.4, you need to use ipvsadm 1.21 series.

For IPVS patch for the Linux kernel 2.2, you need to use ipvsadm version 1.15.

Red Hat Enterprise Linux 3

Red Hat Enterprise Linux 3 (or CentOS 3) kernel has already included the IPVS patch, so that we do not need to build the kernel image with IPVS support ourselves.

[root@penguin root]# modprobe ip_vs
[root@penguin root]# cat /proc/net/ip_vs
IP Virtual Server version 1.0.8 (size=65536)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port Forward Weight ActiveConn InActConn

For the IPVS version 1.0.8, we should use the ipvsadm version 1.21-10, which support the Linux kernel 1.0.4 or later.

On Red Hat Enterprise Linux 3, make sure that kernel-source rpm is installed at system.

[root@penguin src]# rpm -q kernel-source
kernel-source-2.4.21-47.0.1.EL
[root@penguin src]# pwd
/usr/src
[root@penguin src]# ln -s linux-2.4.21-47.0.1.EL linux

Then, we can build the ipvsadm-1.21-10 rpm in the following command:

rpmbuild --rebuild ipvsadm-1.21-10.src.rpm

Note that ipvsadm-1.21-11.src.rpm is for IPVS 1.0.12 or later, IPVS 1.0.12 is in the Linux kernel 2.4.28 or later 2.4.xx versions.

Red Hat Enterprise Linux 4

On Red Hat Enterprise Linux 4, make sure that kernel-source rpm is installed at system (as showed at http://kbase.redhat.com/faq/FAQ_85_5109.shtm).

# up2date redhat-rpm-config rpm-build kernel-utils

# up2date --get-source kernel

# rpm -ivh /var/spool/up2date/kernel*.src.rpm

# cd /usr/src/redhat/SPECS

# rpmbuild -bp --target=i686 kernel-2.6.spec

# cp -a /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9 /usr/src

# ln -s /usr/src/linux-2.6.9 /usr/src/linux


Then, we can build the ipvsadm-1.24 rpm in the following command:

rpmbuild --rebuild ipvsadm-1.24-6.src.rpm

And install using: rpm -ivh /usr/src/redhat/RPMS/i386/ipvsadm-1.24-6.i386.rpm

Red Hat Enterprise Linux 5

Red Hat Enterprise Linux 6

Compiling Error Analysis

Cannot find kernel source directory

Here is the compiling error message

# make
make -C libipvs
make[1]: Entering directory `/var/tmp/ipvsadm-1.24/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g -O2 -I/usr/src/linux/include  -DHAVE_NET_IP_VS_H -c -o libipvs.o libipvs.c
In file included from libipvs.c:23:
libipvs.h:14:23: net/ip_vs.h: No such file or directory
In file included from libipvs.c:23:
libipvs.h:119: error: syntax error before "fwmark"
libipvs.h:119: warning: function declaration isn't a prototype
libipvs.c:27: error: field `svc' has incomplete type
libipvs.c:28: error: field `dest' has incomplete type
libipvs.c: In function `ipvs_init':
libipvs.c:40: error: invalid application of `sizeof' to incomplete type `ip_vs_getinfo'
libipvs.c:44: error: `IP_VS_SO_GET_INFO' undeclared (first use in this function)
libipvs.c:44: error: (Each undeclared identifier is reported only once
libipvs.c:44: error: for each function it appears in.)
libipvs.c: In function `ipvs_getinfo':
libipvs.c:56: error: invalid application of `sizeof' to incomplete type `ip_vs_getinfo'
libipvs.c:57: error: `IP_VS_SO_GET_INFO' undeclared (first use in this function)
libipvs.c: In function `ipvs_version':
libipvs.c:64: error: invalid use of undefined type `struct ip_vs_getinfo'
libipvs.c: In function `ipvs_flush':
libipvs.c:70: error: `IP_VS_SO_SET_FLUSH' undeclared (first use in this function)
libipvs.c: In function `ipvs_add_service':
libipvs.c:79: error: `IP_VS_SO_SET_ADD' undeclared (first use in this function)
libipvs.c:79: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_update_service':
libipvs.c:87: error: `IP_VS_SO_SET_EDIT' undeclared (first use in this function)
libipvs.c:87: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_del_service':
libipvs.c:95: error: `IP_VS_SO_SET_DEL' undeclared (first use in this function)
libipvs.c:95: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_zero_service':
libipvs.c:103: error: `IP_VS_SO_SET_ZERO' undeclared (first use in this function)
libipvs.c:103: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_add_dest':
libipvs.c:109: error: dereferencing pointer to incomplete type
libipvs.c:109: error: dereferencing pointer to incomplete type
libipvs.c:112: error: `IP_VS_SO_SET_ADDDEST' undeclared (first use in this function)
libipvs.c: In function `ipvs_update_dest':
libipvs.c:119: error: dereferencing pointer to incomplete type
libipvs.c:119: error: dereferencing pointer to incomplete type
libipvs.c:122: error: `IP_VS_SO_SET_EDITDEST' undeclared (first use in this function)
libipvs.c: In function `ipvs_del_dest':
libipvs.c:129: error: dereferencing pointer to incomplete type
libipvs.c:129: error: dereferencing pointer to incomplete type
libipvs.c:132: error: `IP_VS_SO_SET_DELDEST' undeclared (first use in this function)
libipvs.c: In function `ipvs_set_timeout':
libipvs.c:140: error: `IP_VS_SO_SET_TIMEOUT' undeclared (first use in this function)
libipvs.c:141: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_start_daemon':
libipvs.c:148: error: `IP_VS_SO_SET_STARTDAEMON' undeclared (first use in this function)
libipvs.c:149: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_stop_daemon':
libipvs.c:156: error: `IP_VS_SO_SET_STOPDAEMON' undeclared (first use in this function)
libipvs.c:157: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_get_services':
libipvs.c:166: error: dereferencing pointer to incomplete type
libipvs.c:167: error: invalid application of `sizeof' to incomplete type `libipvs.h'
libipvs.c:167: error: invalid use of undefined type `struct ip_vs_getinfo'
libipvs.c:172: error: dereferencing pointer to incomplete type
libipvs.c:172: error: invalid use of undefined type `struct ip_vs_getinfo'
libipvs.c:174: error: `IP_VS_SO_GET_SERVICES' undeclared (first use in this function)
libipvs.c: In function `ipvs_cmp_services':
libipvs.c:189: error: dereferencing pointer to incomplete type
libipvs.c:189: error: dereferencing pointer to incomplete type
libipvs.c:193: error: dereferencing pointer to incomplete type
libipvs.c:193: error: dereferencing pointer to incomplete type
libipvs.c:197: error: dereferencing pointer to incomplete type
libipvs.c:197: error: dereferencing pointer to incomplete type
libipvs.c:201: error: dereferencing pointer to incomplete type
libipvs.c:201: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_sort_services':
libipvs.c:208: error: dereferencing pointer to incomplete type
libipvs.c:208: error: dereferencing pointer to incomplete type
libipvs.c:209: error: invalid application of `sizeof' to incomplete type `libipvs.h'
libipvs.c: In function `ipvs_get_dests':
libipvs.c:218: error: dereferencing pointer to incomplete type
libipvs.c:218: error: invalid application of `sizeof' to incomplete type `libipvs.h'
libipvs.c:218: error: dereferencing pointer to incomplete type
libipvs.c:224: error: dereferencing pointer to incomplete type
libipvs.c:224: error: dereferencing pointer to incomplete type
libipvs.c:225: error: dereferencing pointer to incomplete type
libipvs.c:225: error: dereferencing pointer to incomplete type
libipvs.c:226: error: dereferencing pointer to incomplete type
libipvs.c:226: error: dereferencing pointer to incomplete type
libipvs.c:227: error: dereferencing pointer to incomplete type
libipvs.c:227: error: dereferencing pointer to incomplete type
libipvs.c:228: error: dereferencing pointer to incomplete type
libipvs.c:228: error: dereferencing pointer to incomplete type
libipvs.c:231: error: `IP_VS_SO_GET_DESTS' undeclared (first use in this function)
libipvs.c: In function `ipvs_cmp_dests':
libipvs.c:243: error: dereferencing pointer to incomplete type
libipvs.c:243: error: dereferencing pointer to incomplete type
libipvs.c:247: error: dereferencing pointer to incomplete type
libipvs.c:247: error: dereferencing pointer to incomplete type
libipvs.c: In function `ipvs_sort_dests':
libipvs.c:253: error: dereferencing pointer to incomplete type
libipvs.c:253: error: dereferencing pointer to incomplete type
libipvs.c:254: error: invalid application of `sizeof' to incomplete type `libipvs.h'
libipvs.c: At top level:
libipvs.c:259: error: syntax error before "fwmark"
libipvs.c:260: warning: function declaration isn't a prototype
libipvs.c: In function `ipvs_get_service':
libipvs.c:264: error: dereferencing pointer to incomplete type
libipvs.c:270: error: dereferencing pointer to incomplete type
libipvs.c:270: error: `fwmark' undeclared (first use in this function)
libipvs.c:271: error: dereferencing pointer to incomplete type
libipvs.c:271: error: `protocol' undeclared (first use in this function)
libipvs.c:272: error: dereferencing pointer to incomplete type
libipvs.c:272: error: `addr' undeclared (first use in this function)
libipvs.c:273: error: dereferencing pointer to incomplete type
libipvs.c:273: error: `port' undeclared (first use in this function)
libipvs.c:274: error: `IP_VS_SO_GET_SERVICE' undeclared (first use in this function)
libipvs.c: In function `ipvs_get_timeout':
libipvs.c:288: error: dereferencing pointer to incomplete type
libipvs.c:293: error: `IP_VS_SO_GET_TIMEOUT' undeclared (first use in this function)
libipvs.c: In function `ipvs_get_daemon':
libipvs.c:309: error: dereferencing pointer to incomplete type
libipvs.c:315: error: `IP_VS_SO_GET_DAEMON' undeclared (first use in this function)
libipvs.c: At top level:
libipvs.c:33: error: storage size of `ipvs_info' isn't known
make[1]: *** [libipvs.o] Error 1
make[1]: Leaving directory `/var/tmp/ipvsadm-1.24/libipvs'
make: *** [libs] Error 2

The problem is that compiler cannot find the kernel source directory. The fix is to make a symbolic link of kernel source directory to /usr/src/linux.


Problems when make : make error : can't find file 'netlink/netlink.h'

Solution: install the libnl and popt develop packages

#yum install libnl* popt*