This document contains the installation instructions for installing PeerCache on the FreeBSD platform. Version 4.x (stable) or 5.x can be used.
This paper tries to be a complete source of information sufficient to perform successful installation of Peercache.
If you find mistakes or inaccuracies on this page please contact your support person at Joltid and we will be happy to help you out and make this document better with your help.
This section covers everything to be done before you may start installation of PeerCache itself.
1.1 Hardware
If you are reading this document, probably you already know how much savings you may get having this or that size of storage, speed of network and processor.
Please consult the following websites for supported hardware.
http://www.freebsd.org/releases/4.9R/hardware.html
or
http://www.freebsd.org/releases/5.2R/hardware.html
1.2 Obtaining Joltid software
You can get the software from the URL emailed to you by your support contact at Joltid.
You will need 3 files:
Note: the main version number of statistics tools package should be same as main binary version number,but it can have additional minor revision number, i.e. if main binary package is PeerCache_1_3_FreeBSD.tgz, then you need statistics PeerCache_1_3_Stats_FreeBSD.tgz or PeerCache_1_3_Stats_x_FreeBSD.tgz
1.3 Obtaining third party software
Obtaining FreeBSD is well described in the FreeBSD handbook.http://www.freebsd.org/handbook/Supported FreeBSD version is 4-STABLE and 5.x.
All needed software can be installed classical way (get tarball, ./configure & so on), using ports or with pkg_add(1), but we recommend installation from ports. Be careful with version numbers, configuration file formats and locations may differ from version to version, so installing wrong versions may lead to different problems installing PeerCache. If you have difficulties obtaining right versions please feel free to contact our support person.http://www.freebsd.org/handbook/ports.html
1.4 Operating System Installation
If you are not familiar with FreeBSD installation, the FreeBSD handbook will be the perfect guide for you. It is better to install minimal set adding src/sys and ports.
1.5 Operating System Preparation
Note: most of this should be performed as root user.
Make the following changes in system configuration files loader.conf(5) and sysctl.conf(5):
in /boot/loader.conf:
kern.ipc.nmbclusters="65536"
in /etc/sysctl.conf:
net.inet.tcp.sendspace=8192 net.inet.tcp.recvspace=8192 kern.maxfiles=65536 kern.maxfilesperproc=32768
Recompile the kernel to support larger data segments:
The default data segment size for FreeBSD 4 is 512MB, it is recommended to increase it to 75% of physical memory, i.e. 1536MB in case of 2GB RAM. But it must be lower than 2GB, otherwise some problems will appear.
Recompile the kernel with:
options: MAXDSIZ="(1536*1024*1024)"
Check the BSD Handbook for greater details.http://www.freebsd.org/handbook/kernelconfig.html
Set noatime option for cache volumes:
In order to support the high load that PeerCache creates on hard disks, turn off the file access time updating by adding option noatime for the filesystem volumes that are used for PeerCache.
Note: you should use separate volumes for PeerCache content directories, not part of /usr or other volumes that could also be used by other applications.
Create peercache group and user
# pw groupadd peercache # pw useradd peercache -n peercache -g peercache -d /usr/home/peercache -m -s /bin/sh
You can assign password to peercache user using passwd, so you will be able to log in, not only with su(1).
2.1 Apache
Please consult the installation instructions for Apache..
Server version 1.3 from ports is used
# cd /usr/ports/www/apache13 # make install # ln -s /usr/local/www/data-dist ~peercache/htdocs # chown peercache:www /usr/local/www/data-dist
Edit /etc/group so peercache user will be in www-date group
In httpd.conf enable .htaccess authentication by locating the section
Directory “usr/local/www/data” and changing line “AllowOverride None” to “AllowOverride AuthConfig”
2.2 MySQL
Check out the MySQL documentation if you need any help.
Tested version is 3.23
# cd /usr/ports/databases/mysql323-server # make install # mysqladmin -u root password<sqlrootpassword>
2.3 php
Documentation for php: http://www.php.net/manual/en/
Tested version is 4.2.3
# cd /usr/ports/lang/php4 # make install (default options are ok) # cd /usr/ports/lang/php4-extensions # make install (default options are ok) # cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
In php.ini check and correct if necessary following settings:
extension_dir = "/usr/local/lib/php/20020429" (or very similar) include_path = ".:/home/peercache/htdocs/cacti" register_globals = On register_argc_argv = On error_reporting = E_ALL & ~E_NOTICE
2.4 Perl
Go to http://www.perldoc.com/perl5.6/ to get perl help.
2.5 RRDTool
RRDtool manual:http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/manual/index.html
Version 1.0.xx is OK
2.6 Linuxthreads
# cd /usr/ports/devel/linuxthreads # make install
3.1 PeerCache main product
Log in as peercache and copy included tar file to ~/. Unpack it with command:
$ tar xvfz peercache_<revision>_FreeBSD.tgz
Copy license file (not included in this bundle) to ~peercache/license/license
(Optional) Alter settings in PeerCache.ini:
Start PeerCache
$ ./peercache
Verify that PeerCache is up and running
$ tail logs/cache.log
You should see a line like “2002/11/12 09:31:34 CORE 1 Starting serving requests”
After a while, verify that the cache is being used and is working efficiently, by checking entries in access.log file. The normal FastTrack requests should show up like:
1036752786.000 1000 1.1.1.1 TCP_MISS/0000 GET http://192.168.100.122:1214/.hash=- DIRECT/192.168.100.122 –
If there are no requests displayed in access.log, then verify that the cache is running and accessible at port 1214.
If there are only requests for .p2pinfo, but no actual requests, verify the validity and existence of license file.
Add crontab entry under peercache user for daily log rotation:
0 0 * * * peercache /home/peercache -k rotate > /dev/null 2>&1
Additional notes:
It is possible to run PeerCache without creating user ‘peercache’. However, as most paths default to “/home/peercache”, all path settings in the configuration file should be changed accordingly. Also, the path to the configuration file for peercache should be indicated in command line, for example:
$ peercache -f /etc/peercache/PeerCache.ini
Most of the settings have an explanation in the form of comments in the configuration file. Some of the settings are already predefined at the optimal setting for peercache operation, so exercise caution when changing these settings and ask for support if you are unsure.
3.2 Statistics and monitoring package
Unpack tar file
$ tar xzf PeerCache_<revision>_Stats_FreeBSD.tgz $ cd peercache-stats_<revision>
Create a secure web area:
Copy sample index.html and .htaccess from peercache-stats_ to /home/peercache/htdocs:
$ cp htdocs/index.html /home/peercache/htdocs $ cp htdocs/.htaccess /home/peercache/htdocs
Create user authentication file:
$ htpasswd -c /home/peercache/auth.users peercache
Install cacti (see also http://www.raxnet.net/products/cacti/docs/INSTALL.htm)Unpack cacti tar file which can be found in the peercache statistics tools under the directory “packages”..
$ cd packages $ tar xzf cacti-0.6.8a.tar.gz $ mv cacti-0.6.8a /home/peercache/htdocs/cacti $ rm cacti-0.6.8a.tar.gz $ chown -R peercache.www /home/peercache/htdocs/cacti $ cd ../cacti $ mysqladmin -u root -p< sqlrootpassword> create peercachecacti $ mysql -u root -p< sqlrootpassword> peercachecacti <cacti.sql $ mysql -u root -p< sqlrootpassword> mysql mysql> GRANT ALL ON peercachecacti.* TO peercache@localhost IDENTIFIED BY '< cactipassword>'; mysql> flush privileges; mysql> quit $ vi /home/peercache/htdocs/cacti/include/config.php
change lines in config.php:
$database_default= "peercachecacti"; $database_username="peercache"; $database_password="<cactipassword>";
Complete the installation by running:
http://<server ip></server>/cacti
Default login & password: “admin/admin”
Click “Cacti settings” on Configuration section:(specify correct paths during setup, i.e. rrdtool will probably be in/usr/local/bin/rrdtool, php in /usr/local/bin/php, snmpwalk and snmpgetbinaries are not needed)
On Utilities section under “User Administration” you can change password of admin and create more users if needed.
Custom statistics tools:
$ cd peercache-stats_<revision>
Custom statistics scripts:
$ mv stats /home/peercache/stats $ cd /home/peercache/stats $ ./create.sh
Copy “stats/*.conf.dist” files to “stats/*.conf”, unless you are upgrading, in which case use diff command to determine differences in configuration files and what needs to be installed.You must specify the interface which traffic to measure in stats/lognetstat.sh script.
PeerCache cacti installation:
$ mv peercache-stats_<revision>/cacti/*.pl /home/peercache/htdocs/cacti/scripts
4.1 Crontab
For FreeBSD 4.x
*/5 * * * * peercache /usr/local/bin/php /home/peercache/htdocs/cacti/cmd.php > /dev/null 2>/home/peercache/htdocs/cacti/log/cronerr.log */5 * * * * peercache /home/peercache/stats/poll.pl localhost > /dev/null 2>&1 0 0 * * * peercache /home/peercache/peercache -k rotate > /dev/null 2>&1
For FreeBSD 5.x
*/5 * * * * peercache /usr/local/bin/php /home/peercache/htdocs/cacti/cmd.php > /dev/null 2>/home/peercache/htdocs/cacti/log/cronerr.log */5 * * * * peercache /home/peercache/stats/poll.pl localhost > /dev/null 2>&1 */1 * * * * peercache /home/peercache/stats/lognetstat >/dev/null 2>&1 & 0 0 * * * * peercache /home/peercache/peercache -k rotate > /dev/null 2>&1