Pat*_*ckS 14 memcached memcache
我已经使用 memcached pecl 扩展为 Drupal 站点安装了 memcache。一切正常,但我仍在为配置设置而苦苦挣扎。
例如,遵循 drupal.org 上的建议
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}"
Run Code Online (Sandbox Code Playgroud)
问题是我的服务器上没有这个文件,无论如何都没有在这个位置。其他一些文章提到了 /etc/memcached.conf 但我也找不到这个文件。
考虑到 /etc/sysconfig/memcached 或 /etc/memcached.conf 没有在我的服务器上退出,我可以安全地创建它们吗?这些文件是否可能位于其他地方,在这种情况下,我应该在哪里查看或有什么方法可以找到该信息?
最后,将不胜感激任何资源、教程或文档链接。我浏览过 memcache 的站点 Wiki,只能找到几篇适合初学者的相关文章。
Kha*_*led 18
您没有告诉我们您的操作系统/发行版。另外,您没有告诉我们您是如何安装 memcached 的。
通常,/etc/当您apt-get在基于 debian 的系统和/rpm或yumredhat、fedora 或 centos 下安装 memcached 时,您将获得一个示例配置文件。
如果你从源代码安装它,你可能不会得到一个示例文件/etc/(我自己没有从源代码安装 memcached)。但是,您可以在解压的源文件夹中查找示例配置文件。
无论如何,您可以使用locate memcached.conf来在您的系统中查找。您需要在此sudo updatedb之前更新搜索缓存。
这是我系统中的配置文件。你可以使用它:
# 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
Run Code Online (Sandbox Code Playgroud)
您还可以从命令行传递相同的选项。
cyb*_*x86 12
默认 (CentOS) /etc/sysconfig/memcached:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
Run Code Online (Sandbox Code Playgroud)
初始化脚本(CentOS)/etc/init.d/memcached:
...
if [ -f /etc/sysconfig/memcached ];then
. /etc/sysconfig/memcached
fi
...
Run Code Online (Sandbox Code Playgroud)
以上相当于,如果文件存在,“来源”它(即读取并评估其内容)。
据我所知,memcached 没有配置文件。例如,它使用命令行参数(来自 RHEL/CentOS init 脚本):
daemon --pidfile ${pidfile} memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P ${pidfile} $OPTIONS
Run Code Online (Sandbox Code Playgroud)
(您会注意到这里使用了上面定义的变量)。
因此,底线是:
| 归档时间: |
|
| 查看次数: |
98432 次 |
| 最近记录: |