Compile and install Bandwidthd and Postgrsql in CentOS6.4

Source: Internet
Author: User

1. Pay attention to the order of compiling Bandwidthd and Postgrsql in centos

(1) download Postgrsql

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


It is best to download the file in the/root directory.

Tar-zxvf postgresql-8.4.2.tar.gz Decompression


(2) download 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) install the required software package for compilation

Postgresql compilation needs

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

Compile Bandwidthd

Yum install libpcap-devel libpng-devel gd-devel

(4) Go to the S directory and start compiling postgres

./Configure

After the command is executed, check whether there are any errors.

[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 fordefault 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 forinline... inlinechecking for preprocessor stringizing operator... yeschecking forsigned types... yeschecking for working volatile... yeschecking for __func__... yeschecking whether structtm is in sys/time.h or time.h... time.hchecking forstructtm.tm_zone... yeschecking for tzname... yeschecking forunion semun... nochecking forstruct sockaddr_un... yeschecking forstruct sockaddr_storage... yeschecking forstruct sockaddr_storage.ss_family... yeschecking forstruct sockaddr_storage.__ss_family... nochecking forstruct sockaddr_storage.ss_len... nochecking forstruct sockaddr_storage.__ss_len... nochecking forstruct sockaddr.sa_len... nochecking forstruct addrinfo... yeschecking forstruct cmsgcred... nochecking forstruct fcred... nochecking forstruct sockcred... nochecking forstruct option... yeschecking for z_streamp... yeschecking forint 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 forstruct 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 longint is 64 bits... yeschecking for unsigned long... yeschecking size of unsigned long... 8checking forvoid *... yeschecking size of void *... 8checking forsize_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 forshort... yeschecking alignment of short... 2checking forint... yeschecking alignment of int... 4checking forlong... yeschecking alignment of long... 8checking fordouble... yeschecking alignment of double... 8checking for int8... nochecking for uint8... nochecking for int64... nochecking for uint64... nochecking forsig_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]#

Then execute 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.

The ready to instal operation is successful.


After the compilation is complete, there is no error, and then execute gmake install

For more information, see


(5) Compile Bandwidthd

Before compiling Bandwithd, check whether the library and header file required by bandwidthd exist in/usr/local/pgsql.

Go to the bandwidthd directory

./Configure

After configure is executed, check whether there are any errors. Note that if the Postgresq compilation involves issues, the programs compiled by Bandwidthd will not support Postgresql.

Make

It can be determined by the program file size.

The size of 11 xxxx is supported if the parameter sq is not included.


The two must be yes to compile a program that supports Postgrsql.

After make install, the configuration file of the program is in the/usr/local/bandwidthd/etc directory.

##################################################### 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

2. If you want to successfully run Bandwidthd, you also need to create a database

There is a schema. postgresql script under the Bandwidthd directory. You must first import it to the database.

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]$

After the bandwidthd is restarted, the postgresql database will have data in the database two minutes later.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.