CentOS6.4环境下编译安装Bandwidthd和Postgrsql心得笔记

来源:互联网 发布:java多线程框架有哪些 编辑:程序博客网 时间:2024/06/05 05:03

CentOS6.4环境下编译安装Bandwidthd和Postgrsql心得笔记


本系列文章由ex_net(张建波)编写,转载请注明出处。


http://blog.csdn.net/zjianbo/article/details/16796217


作者:张建波 邮箱: 281451020@qq.com 电话:13577062679 欢迎来电交流!



一、在CentOS6.4环境下编译Bandwidthd和Postgrsql需要注意顺序

(1)下载Postgrsql

     wget http://ftp.postgresql.org/pub/source/v8.4.2/postgresql-8.4.2.tar.gz


最好下载在 / 根目录下

tar -zxvf  postgresql-8.4.2.tar.gz 解压缩


(2)下载Bandwidthd

wget http://nchc.dl.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/bandwidthd-2.0.1.tgz


tar -zxvf bandwidthd-2.0.1.tgz

(3)安装编译需要的软件包

     编译Postgresql需要

     yum install gcc cpp glibc glibc-devel gcc-c++ make

     编译Bandwidthd需要

     yum install libpcap libpcap-devel libpng libpng-devel gd gd-devel

(4)进入postgres目录,开始编译postgres

      ./configure

      执行后,看看有没有错误

     

[root@bwd postgresql-8.4.2]# ./configurechecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking which template to use... linuxchecking whether to build with 64-bit integer date/time support... yeschecking whether NLS is wanted... nochecking for default port number... 5432checking for block size... 8kBchecking for segment size... 1GBchecking for WAL block size... 8kBchecking for WAL segment size... 16MBchecking for gcc... gccchecking for C compiler default output file name... a.outchecking whether the C compiler works... yeschecking whether we are cross compiling... nochecking for suffix of executables... checking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ISO C89... none neededchecking if gcc supports -Wdeclaration-after-statement... yeschecking if gcc supports -Wendif-labels... yeschecking if gcc supports -fno-strict-aliasing... yeschecking if gcc supports -fwrapv... yeschecking whether the C compiler still works... yeschecking how to run the C preprocessor... gcc -Echecking allow thread-safe client libraries... nochecking whether to build with Tcl... nochecking whether to build Perl modules... nochecking whether to build Python modules... nochecking whether to build with GSSAPI support... nochecking whether to build with Kerberos 5 support... nochecking whether to build with PAM support... nochecking whether to build with LDAP support... nochecking whether to build with Bonjour support... nochecking whether to build with OpenSSL support... nochecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking for ld used by GCC... /usr/bin/ldchecking if the linker (/usr/bin/ld) is GNU ld... yeschecking for ranlib... ranlibchecking for strip... stripchecking whether it is possible to strip libraries... yeschecking for ar... archecking for tar... /bin/tarchecking whether ln -s works... yeschecking for gawk... gawkchecking for bison... noconfigure: WARNING:*** Without Bison you will not be able to build PostgreSQL from CVS nor*** change any of the parser definition files.  You can obtain Bison from*** a GNU mirror site.  (If you are using the official distribution of*** PostgreSQL then you do not need to worry about this, because the Bison*** output is pre-generated.)checking for flex... noconfigure: WARNING:*** Without Flex you will not be able to build PostgreSQL from CVS or*** change any of the scanner definition files.  You can obtain Flex from*** a GNU mirror site.  (If you are using the official distribution of*** PostgreSQL then you do not need to worry about this because the Flex*** output is pre-generated.)checking for perl... /usr/bin/perlchecking for main in -lm... yeschecking for library containing setproctitle... nochecking for library containing dlopen... -ldlchecking for library containing socket... none requiredchecking for library containing shl_load... nochecking for library containing getopt_long... none requiredchecking for library containing crypt... -lcryptchecking for library containing fdatasync... none requiredchecking for library containing gethostbyname_r... none requiredchecking for library containing shmget... none requiredchecking for -lreadline... yes (-lreadline)checking for inflate in -lz... yeschecking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking crypt.h usability... yeschecking crypt.h presence... yeschecking for crypt.h... yeschecking dld.h usability... nochecking dld.h presence... nochecking for dld.h... nochecking fp_class.h usability... nochecking fp_class.h presence... nochecking for fp_class.h... nochecking getopt.h usability... yeschecking getopt.h presence... yeschecking for getopt.h... yeschecking ieeefp.h usability... nochecking ieeefp.h presence... nochecking for ieeefp.h... nochecking langinfo.h usability... yeschecking langinfo.h presence... yeschecking for langinfo.h... yeschecking poll.h usability... yeschecking poll.h presence... yeschecking for poll.h... yeschecking pwd.h usability... yeschecking pwd.h presence... yeschecking for pwd.h... yeschecking sys/ipc.h usability... yeschecking sys/ipc.h presence... yeschecking for sys/ipc.h... yeschecking sys/poll.h usability... yeschecking sys/poll.h presence... yeschecking for sys/poll.h... yeschecking sys/pstat.h usability... nochecking sys/pstat.h presence... nochecking for sys/pstat.h... nochecking sys/resource.h usability... yeschecking sys/resource.h presence... yeschecking for sys/resource.h... yeschecking sys/select.h usability... yeschecking sys/select.h presence... yeschecking for sys/select.h... yeschecking sys/sem.h usability... yeschecking sys/sem.h presence... yeschecking for sys/sem.h... yeschecking sys/socket.h usability... yeschecking sys/socket.h presence... yeschecking for sys/socket.h... yeschecking sys/shm.h usability... yeschecking sys/shm.h presence... yeschecking for sys/shm.h... yeschecking sys/tas.h usability... nochecking sys/tas.h presence... nochecking for sys/tas.h... nochecking sys/time.h usability... yeschecking sys/time.h presence... yeschecking for sys/time.h... yeschecking sys/un.h usability... yeschecking sys/un.h presence... yeschecking for sys/un.h... yeschecking termios.h usability... yeschecking termios.h presence... yeschecking for termios.h... yeschecking ucred.h usability... nochecking ucred.h presence... nochecking for ucred.h... nochecking utime.h usability... yeschecking utime.h presence... yeschecking for utime.h... yeschecking wchar.h usability... yeschecking wchar.h presence... yeschecking for wchar.h... yeschecking wctype.h usability... yeschecking wctype.h presence... yeschecking for wctype.h... yeschecking kernel/OS.h usability... nochecking kernel/OS.h presence... nochecking for kernel/OS.h... nochecking kernel/image.h usability... nochecking kernel/image.h presence... nochecking for kernel/image.h... nochecking SupportDefs.h usability... nochecking SupportDefs.h presence... nochecking for SupportDefs.h... nochecking netinet/in.h usability... yeschecking netinet/in.h presence... yeschecking for netinet/in.h... yeschecking for netinet/tcp.h... yeschecking readline/readline.h usability... yeschecking readline/readline.h presence... yeschecking for readline/readline.h... yeschecking readline/history.h usability... yeschecking readline/history.h presence... yeschecking for readline/history.h... yeschecking zlib.h usability... yeschecking zlib.h presence... yeschecking for zlib.h... yeschecking whether byte ordering is bigendian... nochecking for an ANSI C-conforming const... yeschecking for inline... inlinechecking for preprocessor stringizing operator... yeschecking for signed types... yeschecking for working volatile... yeschecking for __func__... yeschecking whether struct tm is in sys/time.h or time.h... time.hchecking for struct tm.tm_zone... yeschecking for tzname... yeschecking for union semun... nochecking for struct sockaddr_un... yeschecking for struct sockaddr_storage... yeschecking for struct sockaddr_storage.ss_family... yeschecking for struct sockaddr_storage.__ss_family... nochecking for struct sockaddr_storage.ss_len... nochecking for struct sockaddr_storage.__ss_len... nochecking for struct sockaddr.sa_len... nochecking for struct addrinfo... yeschecking for struct cmsgcred... nochecking for struct fcred... nochecking for struct sockcred... nochecking for struct option... yeschecking for z_streamp... yeschecking for int timezone... yeschecking types of arguments for accept()... int, int, struct sockaddr *, socklen_t *checking whether gettimeofday takes only one argument... nochecking for cbrt... yeschecking for dlopen... yeschecking for fcvt... yeschecking for fdatasync... yeschecking for getpeereid... nochecking for getpeerucred... nochecking for getrlimit... yeschecking for memmove... yeschecking for poll... yeschecking for pstat... nochecking for readlink... yeschecking for setproctitle... nochecking for setsid... yeschecking for sigprocmask... yeschecking for symlink... yeschecking for sysconf... yeschecking for towlower... yeschecking for utime... yeschecking for utimes... yeschecking for waitpid... yeschecking for wcstombs... yeschecking for posix_fadvise... yeschecking whether posix_fadvise is declared... yeschecking whether fdatasync is declared... yeschecking whether strlcat is declared... nochecking whether strlcpy is declared... nochecking whether F_FULLFSYNC is declared... nochecking for struct sockaddr_in6... yeschecking for PS_STRINGS... nochecking for snprintf... yeschecking for vsnprintf... yeschecking whether snprintf is declared... yeschecking whether vsnprintf is declared... yeschecking for isinf... yeschecking for crypt... yeschecking for getopt... yeschecking for getrusage... yeschecking for inet_aton... yeschecking for random... yeschecking for rint... yeschecking for srandom... yeschecking for strdup... yeschecking for strerror... yeschecking for strlcat... nochecking for strlcpy... nochecking for strtol... yeschecking for strtoul... yeschecking for unsetenv... yeschecking for getaddrinfo... yeschecking for getopt_long... yeschecking for rl_completion_append_character... yeschecking for rl_completion_matches... yeschecking for rl_filename_completion_function... yeschecking for replace_history_entry... yeschecking for sigsetjmp... yeschecking whether sys_siglist is declared... yeschecking for syslog... yeschecking syslog.h usability... yeschecking syslog.h presence... yeschecking for syslog.h... yeschecking for opterr... yeschecking for optreset... nochecking for strtoll... yeschecking for strtoull... yeschecking for atexit... yeschecking for fseeko... yeschecking for _LARGEFILE_SOURCE value needed for large files... nochecking test program... okchecking whether long int is 64 bits... yeschecking for unsigned long... yeschecking size of unsigned long... 8checking for void *... yeschecking size of void *... 8checking for size_t... yeschecking size of size_t... 8checking whether to build with float4 passed by value... yeschecking whether to build with float8 passed by value... yeschecking for short... yeschecking alignment of short... 2checking for int... yeschecking alignment of int... 4checking for long... yeschecking alignment of long... 8checking for double... yeschecking alignment of double... 8checking for int8... nochecking for uint8... nochecking for int64... nochecking for uint64... nochecking for sig_atomic_t... yeschecking for POSIX signal interface... yeschecking for special C compiler options needed for large files... nochecking for _FILE_OFFSET_BITS value needed for large files... nochecking for off_t... yeschecking size of off_t... 8checking for working memcmp... yeschecking for onsgmls... nochecking for nsgmls... nochecking for openjade... nochecking for jade... nochecking for DocBook V4.2... nochecking for DocBook stylesheets... nochecking for collateindex.pl... nochecking for sgmlspl... nochecking for docbook2man... checking if gcc supports -Wl,--as-needed... yesconfigure: using CFLAGS=-O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapvconfigure: using CPPFLAGS= -D_GNU_SOURCE configure: using LDFLAGS=  -Wl,--as-neededconfigure: creating ./config.statusconfig.status: creating GNUmakefileconfig.status: creating src/Makefile.globalconfig.status: creating src/include/pg_config.hconfig.status: src/include/pg_config.h is unchangedconfig.status: creating src/interfaces/ecpg/include/ecpg_config.hconfig.status: src/interfaces/ecpg/include/ecpg_config.h is unchangedconfig.status: linking ./src/backend/port/tas/dummy.s to src/backend/port/tas.sconfig.status: linking ./src/backend/port/dynloader/linux.c to src/backend/port/dynloader.cconfig.status: linking ./src/backend/port/sysv_sema.c to src/backend/port/pg_sema.cconfig.status: linking ./src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.cconfig.status: linking ./src/backend/port/dynloader/linux.h to src/include/dynloader.hconfig.status: linking ./src/include/port/linux.h to src/include/pg_config_os.hconfig.status: linking ./src/makefiles/Makefile.linux to src/Makefile.port[root@bwd postgresql-8.4.2]# 

然后执行gmake

rm -rf ./testtablespacemkdir ./testtablespacegmake[2]: Leaving directory `/postgresql-8.4.2/src/test/regress'gmake[1]: Leaving directory `/postgresql-8.4.2/src'gmake -C config allgmake[1]: Entering directory `/postgresql-8.4.2/config'gmake[1]: Nothing to be done for `all'.gmake[1]: Leaving directory `/postgresql-8.4.2/config'All of PostgreSQL successfully made. Ready to install.

看到ready to instal 基本就成功了

等编译完成后,没有错误,再执行 gmake install

详细说明,可以看



(5)编译Bandwidthd

       在编译Bandwithd前,请检查 /usr/local/pgsql/ 下是否已经有 bandwidthd需要的库和头文件了。

        

       进入bandwidthd目录

       ./configure

       执行configure后,看看是否有错误。注意,如果Postgresq编译有问题化,Bandwidthd编译出来的程序是不会支持Postgresql的。

       make

       可以通过程序文件大小判断

       

      如果不带Postgresq支持的是11xxxx 的大小。

     

这2个地方必须是yes,才能编译出支持Postgrsql的程序.



make install后,程序的配置文件在 /usr/local/bandwidthd/etc 目录

##################################################### Bandwidthd.conf# # Commented out options are here to provide# documentation and represent defaults# Subnets to collect statistics on.  Traffic that # matches none of these subnets will be ignored.# Syntax is either IP Subnet Mask or CIDR#subnet 10.0.0.0 255.0.0.0#subnet 192.168.0.0/16#subnet 172.16.0.0/12subnet 10.0.0.0 255.255.0.0subnet 10.1.0.0 255.255.0.0subnet 10.2.0.0 255.255.0.0subnet 10.3.0.0 255.255.0.0subnet 10.4.0.0 255.255.0.0subnet 10.5.0.0 255.255.0.0subnet 192.168.0.0/16subnet 172.16.25.0/24subnet 172.16.10.0/24subnet 172.16.11.0/24subnet 172.16.12.0/24subnet 172.16.13.0/24subnet 172.16.14.0/24subnet 172.16.15.0/24subnet 172.16.16.0/24subnet 172.16.17.0/24subnet 172.16.18.0/24subnet 172.16.19.0/24subnet 172.16.20.0/24subnet 172.16.31.0/24subnet 172.16.32.0/24subnet 172.16.33.0/24subnet 172.16.34.0/24subnet 172.16.35.0/24subnet 172.16.36.0/24pgsql_connect_string "user = postgres dbname = bandwidthd host = 127.0.0.1"sensor_id "sensor1.cn"# Device to listen on# Bandwidthd listens on the first device it detects# by default.  Run "bandwidthd -l" for a list of # devices. dev "eth1"#################################################### Options that don't usually get changed# An interval is 2.5 minutes, this is how many # intervals to skip before doing a graphing run#skip_intervals 150# Graph cutoff is how many k must be transfered by an# ip before we bother to graph itgraph_cutoff 1024#Put interface in promiscuous mode to score to traffic#that may not be routing through the host machine.promiscuous true#Log data to cdf file htdocs/log.cdfoutput_cdf true#Read back the cdf file on startuprecover_cdf false#Libpcap format filter string used to control what bandwidthd see's#Please always include "ip" in the string to avoid strange problemsfilter "ip"#Draw Graphs - This default to true to graph the traffic bandwidthd is recording#Usually set this to false if you only want cdf output or#you are using the database output option.  Bandwidthd will use very little#ram and cpu if this is set to false.graph false#Set META REFRESH seconds (default 150, use 0 to disable).meta_refresh 150



二、如果要能成功运行Bandwidthd,还需要创建数据库

 在Bandwidthd目录下,有个schema.postgresql脚本,要首先将他导入数据库


su - postgrespsqlcreate database bandwidthd;[postgres@bwd bandwidthd-2.0.1]$ psql bandwidthd postgres< schema.postgresqlCREATE TABLECREATE INDEXCREATE INDEXCREATE TABLECREATE INDEXCREATE INDEXCREATE TABLECREATE INDEXCREATE TABLECREATE INDEXNOTICE:  CREATE TABLE will create implicit sequence "sensors_sensor_id_seq" for serial column "sensors.sensor_id"NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "sensors_pkey" for table "sensors"CREATE TABLE[postgres@bwd bandwidthd-2.0.1]$ 


重启bandwidthd 后postgresql数据库,2分钟后,数据库里就有数据了。


      

原创粉丝点击