This document contains the installation instructions for installing PeerCache on the Linux platform. The instructions are made with Debian in mind, but can also be applied on other Linux distributions.
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.
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 http://www.tldp.org/HOWTO/Hardware-HOWTO/ for supported hardware.
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-RELEASE_1_1-linux.tar.gz, then you need statistics package peercache-stats_1_1-linux.tar.gz or peercache-stats_1_1_x-linux.tar.gz
1.3 Obtaining third party software
Obtaining Debian is well described in the Debian Installation Manual. Supported Debian version is “Woody”.
All needed software can be installed classical way (get tarball, ./configure & so on) or from Debian packages. We recommend installing all software from Debian packages to make software management easier.
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.
1.4 Operating System Installation
If you are not familiar with Debian installation, the Debian Installation Manual will be very helpful.
1.5 Operating System Preparation
Note: most of this should be performed as root user.
When kernel 2.4 or 2.6 is used, in most cases no kernel tuning is necessary.
So far, XFS filesystem seems to be most suited for peercache data storage.
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
# groupadd peercache # useradd -m -g peercache You can assign password to peercache user using passwd, so you will be able to log in, not only with su(1). In most cases it is necessary to modify shell limits for open files. Edit /etc/security/limits.conf and add line: <literal> peercache hard nofile 200000
And check /etc/pam.d/su file, line: “sessionrequired pam_limits.so”must be uncommented.
Before installing additional software from Debian packages, make sure your /etc/apt/sources.list is up-to-date. List of Debian mirrors is in http://www.debian.org/mirror/list
2.1 Apache
Please consult the installation instructions for Apache..
Server version 1.3 from debian packages is used
# apt-get update # apt-get install apache # ln -s /var/www/ ~peercache/htdocs # chown peercache:www-data /var/www
Edit /etc/group so peercache user will be in www-date group
In httpd.conf enable .htaccess authentication by locating the section
Directory “var/www” 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
# apt-get install mysql-server # mysqladmin -u root password<sqlrootpassword>
2.3 php
Tested version is 4.1.2.
# apt-get install php4 php4-cgi php4-mysql
In php.ini check and correct if necessary following settings:
register_globals = On register_argc_argv = On error_reporting = E_ALL & ~E_NOTICE
2.4 Perl
Go here to get perl help. Perl is installed by default with Debian.
2.5 RRDTool
RRDToot manual
Version 1.0.xx is OK
# apt-get install rrdtool
3.1 PeerCache main product
Log in as peercache and copy included tar file to ~/. Unpack it with command:
$ tar xvfz peercache-<revision>.-linux.tar.gz
Copy license file (not included in this bundle) to ~peercache/license/license
(Optional) Alter settings in PeerCache.ini:
Start PeerCache
$ ./peercache.sh start
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
Switch to peercache user:
# su - peercache
Unpack tar file
$ tar xzf peercache-stats_<revision>-linux.tar.gz $ cd peercache-stats_<revision>
Create a secure web area:
Create user authentication file:
$ htpasswd -c /home/peercache/auth.users peercache
Install cacti (see also Cacti docs)
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-data /home/peercache/htdocs/cacti $ cd ../cacti $ mysqladmin -u root --password=<sqlrootpassword> create peercachecacti $ mysql -u root --password=< sqlrootpassword> peercachecacti < cacti.sql $ mysql -u root --password=< sqlrootpassword> 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 ofadmin and create more users if needed.
Custom statistics scripts:
$ cd peercache-stats_<revision> $ 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:
$ cd peercache-stats_<revision> $ mv cacti/*.pl /home/peercache/htdocs/cacti/scripts
$ 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 Cacti docs)
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-data /home/peercache/htdocs/cacti $ cd ~peercache/htdocs/cacti $ mysqladmin -u root --password=<sqlrootpassword> create peercachecacti $ mysql -u root --password=< sqlrootpassword> peercachecacti < cacti.sql $ mysql -u root --password=< 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 cacti/*.pl /home/peercache/htdocs/cacti/scripts
4.1 Crontab
*/5 * * * * peercache /home/peercache/stats/poll.pl localhost > /dev/null 2>&1 */1 * * * * peercache /home/peercache/stats/lognetstat.sh */5 * * * * peercache /usr/bin/php4 /home/peercache/htdocs/cacti/cmd.php > /dev/null 2>/home/peercache/htdocs/cacti/log/cronerr.log