我使用memcached pecl扩展安装了Drupal站点的memcache。 这一切都运行良好,但我还在努力configuration设置。
例如,遵循drupal.org上的build议
You should probably lock down the memcache server so that it only listens for connections from the hosts that need to be served, as the default is that memcache listens to connections from all addresses. So, to close that hole, edit /etc/sysconfig/memcached with: OPTIONS="-l ${HOSTIP}"
问题是我的服务器上没有这个文件,无论如何都不在这个位置。 其他一些文章提到/etc/memcached.conf,但是我也找不到这个文件。
考虑到/ etc / sysconfig / memcached或/etc/memcached.conf不会退出我的服务器,我可以安全地创build它们吗? 这些文件可能位于其他地方,在这种情况下,我应该看看还是有什么方法可以find这些信息?
最后,任何资源,教程或文档链接将不胜感激。 我浏览过memcache的网站Wiki,只能find一些适合初学者的相关文章。
你没有告诉我们你的操作系统/发行版。 另外,你没有告诉我们你是如何安装memcached的。
通常,当你在基于debian的系统上使用apt-get安装memcached,并在redhat,fedora或者centos下运行rpm或yum时,你会在/etc/下得到一个configuration文件示例。
如果你是从源代码安装的,你可能不会在/etc/下得到一个示例文件(我没有从源代码自己安装memcached)。 但是,您可以在解压后的源文件夹中查找示例configuration文件。
无论如何,您可以使用locate memcached.conf在您的系统中查找一个。 在更新searchcaching之前,您需要先执行sudo updatedb 。
这是来自我的系统的configuration文件。 你可以使用它:
# Run memcached as a daemon. This command is implied, and is not needed for the # daemon to run. See the README.Debian that comes with this package for more # information. -d # Log memcached's output to /var/log/memcached logfile /var/log/memcached.log # Be verbose # -v # Be even more verbose (print client commands as well) # -vv # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default # Note that the daemon will grow to this size, but does not start out holding this much # memory -m 64 # Default connection port is 11211 -p 11211 # Run the daemon as root. The start-memcached will default to running as root if no # -u command is present in this config file -u memcache # Specify which IP address to listen on. The default is to listen on all IP addresses # This parameter is one of the only security measures that memcached has, so make sure # it's listening on a firewalled interface. -l 127.0.0.1 # Limit the number of simultaneous incoming connections. The daemon default is 1024 # -c 1024 # Lock down all paged memory. Consult with the README and homepage before you do this # -k # Return error when memory is exhausted (rather than removing items) -M # Maximize core file limit # -r
您也可以从命令行传递相同的选项。
默认(CentOS)/ etc / sysconfig / memcached:
PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS=""
init脚本(CentOS)/etc/init.d/memcached:
... if [ -f /etc/sysconfig/memcached ];then . /etc/sysconfig/memcached fi ...
如果文件存在,上面的内容相当于“源”(即读取和评估其内容)。
据我所知,memcached没有configuration文件。 它使用命令行参数(例如,从RHEL / CentOS初始化脚本):
daemon --pidfile ${pidfile} memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P ${pidfile} $OPTIONS
(你会注意到上面定义的variables在这里使用)。
因此,底线是:
如果你在CentOS上找不到/etc/init.d/memcached,试试这个:
nano /usr/lib/systemd/system/memcached.service
并改变:
ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS
至:
ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -I $MAXITEMSIZE -c $MAXCONN $OPTIONS
在/ etc / sysconfig / memcached中添加后
MAXITEMSIZE="128m"
重新启动memcached
service memcached restart
要检查是否添加参数尝试:
ps aux | grep memcached