Spa*_*ust -1 port port-forwarding forwarding memcached memcache
我的客户正在运行许多使用 memcached 的脚本,但他们都使用 localhost 作为地址。我的本地主机服务器现在内存不足,因为它正在做很多其他事情,比如 WWW 和 MySQL 服务器。
现在我有了一个全新的 16 GB RAM 服务器,我可以将它用作专用的 memcached 服务器。如何将 localhost:12111 重定向到 domain.com:12111 服务器?
我无法将 localhost 切换到 /etc/hosts 中的其他内容,因为我所有的数据库都使用这样的地址。
努力吧,1分钟的谷歌搜索会给你答案。
没有特定的顺序,您可以使用:
或者对 localhost 执行简单的 grep 并将其替换为您可以更改的主机名。
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t nat -A PREROUTING -d 127.0.0.1 -p tcp --dport 11211 -j DNAT --to 192.168.1.2:11211
iptables -P FORWARD ACCEPT
Run Code Online (Sandbox Code Playgroud)
echo " 127.0.0.1 11211 192.168.1.2 11211" >> /etc/rinetd.conf
/etc/init.d/rinetd restart
Run Code Online (Sandbox Code Playgroud)
nc -l -p 11211 -c "nc 192.168.1.2 11211"
Run Code Online (Sandbox Code Playgroud)
ssh user@192.168.1.2 -L 11211:192.168.1.2:11211
Run Code Online (Sandbox Code Playgroud)
cat > /etc/xinet.d/memfw << eof
service memfw {
disable = no
type = UNLISTED
socket_type = stream
protocol = tcp
user = nobody
wait = no
redirect = 192.168.1.2 11211
port = 11211
}
eof
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1700 次 |
最近记录: |