Re: Upgrading from squid v1.1.* to squid v1.2-beta18 ...

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Thu, 16 Apr 1998 00:42:22 +0200

> There is one slightly possible path which I've thought of, but
> it requires twice the amount of disk.

You could get by with the same amount of disk. If you purge each object
from the old cache as you load them into the new cache then disk usage
should stay same.

Revised upgrade path:

1. Configure the new and old caches running on different ports and cache
directories.
old squid.conf:
  http_port 13128
  icp_port 13130
2. Enable the PURGE method in the old cache
old squid.conf:
  acl PURGE method PURGE
  acl localhost 127.0.0.1/255.255.255.255
  http_access deny PURGE !localhost
3. Configure the old cache as a sibling to the new cache
new squid.conf:
  cache_peer localhost sibling 13128 13130
4. Get a list of objects cached in the old cache
  cat first_cache_dir/log | awk '{print $6}' >old_urls
5. Configure the new cache to not go direct on "upgrade" request.
new squid.conf:
   never_direct allow localhost
   (fails if you have a redirector and use in 1.2b19 or earlier)
6. Run a program that reads a the list of cached URLs, requests the URL
from the new cache and then purges it from the old cache. (C program
attached)
  rebuild_squid <old_urls
7. Shut down and reconfigure the new cache for normal use.
   - remove cache_peer localhost
   - remove never_direct
8. Restart the new cache
8. Shut down the old cache and remove old cache directories (should be
empty now).

If you'd like to have the new cache directories where the old cache
directories currently are then
for each cache directory; do
  cd cache_directory
  mkdir oldcache
  mv * oldcache
  edit old squid.conf:
     cache_dir /path/to/cachedir/oldcache
done

---
Henrik Nordström
Sparetime Squid Hacker

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#if NO_USLEEP
void usleep(int msec)
{
  struct timeval delay;
  delay.tv_sec=msec/1000/1000;
  delay.tv_usec=msec%(1000*1000);
  select(0,NULL,NULL,NULL,&tv);
}
#endif

char url[10240];
char buf[10240];
int dorequest(struct sockaddr_in *server, char *method, char *url)
{
  int s,i;
  sprintf(buf,"%s %s HTTP/1.0\r\nAccept: */*\r\n\r\n",method,url);
  s=socket(AF_INET, SOCK_STREAM, 0);
  if (!s) {
    fprintf(stderr, "Failed to %s %s\n",method,url);
    perror("socket:");
    return 0;
  }
  if(connect(s, (struct sockaddr *)server, sizeof *server)) {
    fprintf(stderr, "Failed to %s %s\n",method,url);
    perror("connect:");
    return 0;
  }
  if(write(s, buf, strlen(buf)) != strlen(buf)) {
    fprintf(stderr, "Failed to %s %s\n",method,url);
    perror("write:");
    return 0;
  }
  while((i=read(s, buf, sizeof(buf)))>0);
  if (i<0) {
    fprintf(stderr, "Failed to %s %s\n",method,url);
    perror("read:");
    return 0;
  }
  close(s);
  return 1;
}
      
int main(int argc, char **argv)
{
  struct sockaddr_in newserver,oldserver;
  
  memset ((char *)&newserver, 0, sizeof(newserver));
  newserver.sin_family = AF_INET;
  inet_aton("127.0.0.1",&newserver.sin_addr);
  memcpy ((char *)&oldserver, (char *)&newserver, sizeof(struct sockaddr_in));

  newserver.sin_port = htons(3128);
  oldserver.sin_port = htons(13128);
  
  while(gets(url)) {
    if (dorequest(&newserver,"GET",url))
      dorequest(&oldserver,"PURGE",url);
    printf("%s done\n",url);
#if !defined NO_DELAY
    /* Delay a short time before next request (1/10 seconds) */
    usleep(1000*1000 * 1/10);
#endif
  }
  return 0;
}
Received on Wed Apr 15 1998 - 16:49:40 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:39:42 MST