LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   problem with cache_dir in squid (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-cache_dir-in-squid-676200/)

sohailkmu 10-14-2008 02:40 AM

problem with cache_dir in squid
 
I changed the cache_dir in squid.conf and restart squid, but it failed to start. However as i set the cache_dir to the default it starts.

I have made two partitions to store cache i.e /cache1 and /Cache2 of about 20gb space,

now as i do the following changes

cache_dir ufs /Cache1/squid 18000 16 256
cache_dir ufs /Cache2/squid 18000 16 256

then squid doesnot start.
and as i comment the above statement(i.e. setting the cache to default /var/spool/squid 100 16 256) it starts working. plz help me to change the cache_dir.... what error i am doing.
kindly guide

bathory 10-14-2008 06:58 AM

After changing the cache_dir location you should run
Code:

squid -z
for the 1st time, to create the cache directories. Note that those dirs (/Cache1/squid, /Cache2/squid) should exist and owned by the user that runs squid.

Regards

sohailkmu 10-15-2008 12:24 AM

Quote:

Originally Posted by bathory (Post 3309638)
After changing the cache_dir location you should run
Code:

squid -z
for the 1st time, to create the cache directories. Note that those dirs (/Cache1/squid, /Cache2/squid) should exist and owned by the user that runs squid.

Regards

Thanks a lot for your quick response

I have tried but still it is not working.

bathory 10-15-2008 01:45 AM

What error do you get? Check the logfiles to see if you find out why squid does not start.
What is the output of:
Code:

ls -l /Cache1/squid
ls -l /Cache2/squid


landysaccount 10-15-2008 09:35 AM

Make sure that the new directory's owner is the same as the owner running squid, usually proxy. I had a similar problem like that.

chown proxy <dirname>

Hope that helps.

sohailkmu 10-16-2008 01:24 AM

Quote:

Originally Posted by bathory (Post 3310496)
What error do you get? Check the logfiles to see if you find out why squid does not start.
What is the output of:
Code:

ls -l /Cache1/squid
ls -l /Cache2/squid



This is the output of cache.log when I changed the cache_dir.

2008/10/16 12:18:35| Starting Squid Cache version 2.5.STABLE6 for i386-redhat-linux-gnu...
2008/10/16 12:18:35| Process ID 3936
2008/10/16 12:18:35| With 1024 file descriptors available
2008/10/16 12:18:35| DNS Socket created at 0.0.0.0, port 32771, FD 4
2008/10/16 12:18:35| Adding nameserver 202.147.176.40 from /etc/resolv.conf
2008/10/16 12:18:35| Adding nameserver 202.147.176.41 from /etc/resolv.conf
2008/10/16 12:18:35| User-Agent logging is disabled.
2008/10/16 12:18:35| Referer logging is disabled.
2008/10/16 12:18:35| Unlinkd pipe opened on FD 9
2008/10/16 12:18:35| Swap maxSize 36864000 KB, estimated 2835692 objects
2008/10/16 12:18:35| Target number of buckets: 141784
2008/10/16 12:18:35| Using 262144 Store buckets
2008/10/16 12:18:35| Max Mem size: 524288 KB
2008/10/16 12:18:35| Max Swap size: 36864000 KB
2008/10/16 12:18:35| /Cache1/squid: (13) Permission denied
FATAL: Failed to verify one of the swap directories, Check cache.log
for details. Run 'squid -z' to create swap directories
if needed, or if running Squid for the first time.
Squid Cache (Version 2.5.STABLE6): Terminated abnormally.
CPU Usage: 0.012 seconds = 0.005 user + 0.007 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0


The output of ls -l is given below:


ls -l /Cache1/squid
total 128
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 00
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 01
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 02
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 03
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 04
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 05
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 06
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 07
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 08
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 09
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 0A
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 0B
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 0C
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 0D
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 0E
drwxr-xr-x 258 squid squid 4096 Oct 9 10:53 0F

In the light of the above output please guide me.

Thanks

bathory 10-16-2008 01:47 AM

The cache.log you've posted is from when you're trying to start squid normally. I suggest you to delete the swap dirs and start over:
Code:

rm -rf /Cache1
mkdir -p /Cache1/squid
chown -R squid:squid /Cache1
squid -z

After that try to start squid normally.
From the logfile I see that you run Redhat. Check if it's not a SELinux problem

sohailkmu 10-16-2008 03:56 AM

Quote:

Originally Posted by bathory (Post 3311740)
The cache.log you've posted is from when you're trying to start squid normally. I suggest you to delete the swap dirs and start over:
Code:

rm -rf /Cache1
mkdir -p /Cache1/squid
chown -R squid:squid /Cache1
squid -z

After that try to start squid normally.
From the logfile I see that you run Redhat. Check if it's not a SELinux problem

Thanks a lot for your quick response

Actually /Cache1 and /Cache2 are the partitions created at the time of installation of redhat linux and the squid directory was created later on in both the partitions.

when I run squid -z it gives OK report. but then it fails to stop or start.

The permissions were set both to root user and squid but in vain.

Any further guidance will be highly appreciated.

bathory 10-16-2008 04:30 AM

Are you sure it's not a SELinux problem?
If I was you, I would delete those dirs and recreate them with the above procedure. Just make sure there is nothing else under /Cache1 /Cache2 and that squid is not running.

sohailkmu 10-16-2008 11:39 PM

Quote:

Originally Posted by bathory (Post 3311915)
Are you sure it's not a SELinux problem?
If I was you, I would delete those dirs and recreate them with the above procedure. Just make sure there is nothing else under /Cache1 /Cache2 and that squid is not running.

I am trying the commands but it is giving the following error messages

rm -rf /Cache1
rm: cannot remove directory `/Cache1': Device or resource busy

please help me.

shahz 10-16-2008 11:49 PM

don't make any dircectory within the cache1 partition and if you running the default squid which shiped with the OS I don't think changing directory for cache will work with that defaul squid package try to get a new squid download from

www.squid-cache.org

then install the package and give your cache path from the squid.conf,

I hope it will work.

thanks
shahz

bathory 10-17-2008 12:45 AM

Quote:

rm: cannot remove directory `/Cache1': Device or resource busy
How do you mount this partition? squid user must have r/w permissions on it. Please post /etc/fstab.

sohailkmu 10-17-2008 10:47 PM

Quote:

Originally Posted by bathory (Post 3313045)
How do you mount this partition? squid user must have r/w permissions on it. Please post /etc/fstab.


Output of vi /etc/fstab

# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/ / ext3 defaults 1 1
LABEL=/Cache1 /Cache1 ext3 defaults 1 2
LABEL=/Cache2 /Cache2 ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
LABEL=/home /home ext3 defaults 1 2
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults 1 2
LABEL=/var /var ext3 defaults 1 2
LABEL=SWAP-sda11 swap swap defaults 0 0
/dev/hda /media/cdrecorder auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
~
~

shahz 10-18-2008 12:15 AM

when you are within the partition/directory you can't remove direcotry. umount the partition and then remove the direcotry.


thanks
shahz

bathory 10-18-2008 09:55 AM

Ok, don't delete /Cache1, delete /Cache1/squid, recreate it and try again:
Code:

rm -rf /Cache1/squid
mkdir /Cache1/squid
chown squid.squid /Cache1/squid
squid -z



All times are GMT -5. The time now is 01:46 AM.