From owner-freebsd-questions@FreeBSD.ORG Wed Jul 27 07:40:21 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1064816A41F for ; Wed, 27 Jul 2005 07:40:21 +0000 (GMT) (envelope-from lei.sun@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8984843D45 for ; Wed, 27 Jul 2005 07:40:20 +0000 (GMT) (envelope-from lei.sun@gmail.com) Received: by wproxy.gmail.com with SMTP id i4so122852wra for ; Wed, 27 Jul 2005 00:40:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=af9TH1wJTarP3c7aRsG868RekDEkSwPcibINeqVfFw9QKATJoLWq1TWY8CpJjIcwg+rap6K+poILdQJ3BWZcJcLO1XFIJAUtI8ukPXG5R15AjmjIdL4oVEUtJWYIJJbpv3uGtCQXSrvZQUGYXisM221WpS7tIvzzRztQ4gXmEck= Received: by 10.54.47.69 with SMTP id u69mr227799wru; Wed, 27 Jul 2005 00:40:19 -0700 (PDT) Received: by 10.54.6.70 with HTTP; Wed, 27 Jul 2005 00:40:19 -0700 (PDT) Message-ID: Date: Wed, 27 Jul 2005 00:40:19 -0700 From: Lei Sun To: Glenn Dawson In-Reply-To: <6.1.0.6.2.20050727001634.1afcc400@cobalt.antimatter.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <6.1.0.6.2.20050726233906.198d9de0@cobalt.antimatter.net> <6.1.0.6.2.20050727001634.1afcc400@cobalt.antimatter.net> Cc: freebsd-questions@freebsd.org Subject: Re: how to run 2 instance of memcached from rc.conf? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Lei Sun List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2005 07:40:21 -0000 I did try this approach... but no luck.=20 whenever I try to start the second one, it says the pid already exists.=20 I think is is because of run_rc_command in rc.subr, it somehow records down the pid somewhere... :( any other good ideas? Thanks Lei On 7/27/05, Glenn Dawson wrote: > At 11:59 PM 7/26/2005, you wrote: > >Yeah, the tricky part is not to what to do, but how to do it. I know I > >need to configure 2 ip or 2 ports. > > > >As the memcached.sh is using run_rc_command, and somehow, even if when > >I am giving it 2 arguments with different port, it still can only > >start up 1 process instead of 2. > > > >So how do I use the same script to run 2 instance of memcached? > > > >Thanks in advance. >=20 > There's probably other ways to do this, but this one works: >=20 > create a second script called memcached2.sh in /usr/local/etc/rc.d with t= he > following contents: >=20 > #!/bin/sh > # >=20 > # PROVIDE: memcached2 > # REQUIRE: NETWORKING >=20 > # > # Add the following lines to /etc/rc.conf to run memcached: > # > #memcached2_enable=3D"YES" > #memcached2_flags=3D"" > # > . /etc/rc.subr >=20 > name=3D"memcached2" > rcvar=3D`set_rcvar` > command=3D/usr/local/bin/memcached2 > command_args=3D"-du nobody ${memcached2_flags}" >=20 > load_rc_config $name > run_rc_command "$1" >=20 >=20 >=20 > Then, create a symlink that points memcached2 to memcachd: >=20 > ln -s /usr/local/bin/memcached /usr/local/bin/memcached2 >=20 >=20 > then, you can use two sets of variables in /etc/rc.conf like: >=20 > memcached_enable=3D"YES" > memcached_flags=3D"-m 2 -l 10.1.1.245 -p 11211" >=20 > memcached2_enable=3D"YES" > memcached2_flags=3D"-m 2 -l 10.1.1.245 -p 11212" >=20 >=20 > That worked for me on one of my test systems. >=20 > -Glenn >=20 >=20 > >Lei > > > >On 7/26/05, Glenn Dawson wrote: > > > At 11:16 PM 7/26/2005, Lei Sun wrote: > > > >Hi, > > > > > > > >I am trying to run 2 instance of memcached from rc.conf, but wheneve= r > > > >I try to start it the second time, it tells me that the instance is > > > >already running. > > > > > > > >Please help... > > > > > > According to the documentation at http://www.danga.com/memcached runn= ing > > > more than one instance on the same machine is only helpful if you hav= e more > > > than 4GB of RAM. > > > > > > To load another instance, you just have to tell it to listen on a dif= ferent > > > port, or a different IP address (if the machine you're running it one= has > > > more than one IP). > > > > > > -Glenn > > > > > > > > > >my rc.conf > > > >-------------------------------------------- > > > >defaultrouter=3D"192.168.0.1" > > > >hostname=3D"aphrodite.us.8po.com" > > > >ifconfig_em0=3D"inet 192.168.0.200 netmask 255.255.255.0" > > > >sshd_enable=3D"YES" > > > >mysql_enable=3D"YES" > > > >mysql_limits=3D"YES" > > > >apache_enable=3D"YES" > > > >memcached_enable=3D"YES" > > > >memcached_flags=3D"-m 1024 -l 127.0.0.1 -p 11211" > > > >----------------------------------------------- > > > > > > > > > > > >my /usr/local/etc/rc.d/memcached.sh > > > >---------------------------------------------- > > > >#!/bin/sh > > > ># > > > > > > > ># PROVIDE: memcached > > > ># REQUIRE: NETWORKING > > > > > > > ># > > > ># Add the following lines to /etc/rc.conf to run memcached: > > > ># > > > ># memcached_enable=3D"YES" > > > ># memcached_flags=3D"" > > > ># > > > >. /etc/rc.subr > > > > > > > >name=3D"memcached" > > > >rcvar=3D`set_rcvar` > > > >command=3D/usr/local/bin/memcached > > > >command_args=3D"-du nobody ${memcached_flags}" > > > > > > > >load_rc_config $name > > > >run_rc_command "$1" > > > >-------------------------------------------------- > > > >_______________________________________________ > > > >freebsd-questions@freebsd.org mailing list > > > >http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > > >To unsubscribe, send any mail to > > "freebsd-questions-unsubscribe@freebsd.org" > > > > > > > >_______________________________________________ > >freebsd-questions@freebsd.org mailing list > >http://lists.freebsd.org/mailman/listinfo/freebsd-questions > >To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.= org" >=20 >