OpenResty Redis 安装部署测试SET GET功能
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了OpenResty Redis 安装部署测试SET GET功能,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4314字,纯文字阅读大概需要7分钟。
内容图文
![OpenResty Redis 安装部署测试SET GET功能](/upload/InfoBanner/zyjiaocheng/1064/de7195ec8e10412f96a1b74c20634f0e.jpg)
OpenResty Redis 安装部署测试SET GET功能
参考文档
http://www.redis.cn/download.html
https://openresty.org/cn/installation.html
https://github.com/openresty/redis2-nginx-module
一,安装OpenResty
1,安装最新稳定版本的OpenResty-1.11.2.5
[root@server ~]# yum -y install tclyum -y install perl-devel gcc gmake
[root@server ~]# yum -y install tclwget https://openresty.org/download/openresty-1.11.2.5.tar.gz
[root@server ~]# yum -y install tcltar zxvf openresty-1.11.2.5.tar.gz
[root@server ~]# yum -y install tclcd openresty-1.11.2.5
[root@server ~]# yum -y install tcl./configure
[root@server ~]# yum -y install tclgmake
[root@server ~]# yum -y install tclgmake install
2,查看Nginx版本
[root@server ~]# yum -y install tclnginx -V
nginx version: openresty/1.11.2.5
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.31 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.06 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.10 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.32 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.18 --add-module=../redis2-nginx-module-0.14 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-http_ssl_module
二,安装Redis
1,安装最新稳定版本的Redis-4.0.1
[root@server ~]# yum -y install tcl
[root@server ~]# wget http://download.redis.io/releases/redis-4.0.1.tar.gz
[root@server ~]# tar zxvf redis-4.0.1.tar.gz
[root@server ~]# cd redis-4.0.1
[root@server ~]# make
[root@server ~]# make test
[root@server ~]# make install
[root@server ~]# sh utils/install_server.sh
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
2,启动
[root@server ~]# /etc/init.d/redis_6379 start
三,配置redis_pass
1,主配置文件
[root@server ~]# cat /usr/local/openresty/nginx/conf/nginx.conf |grep -Ev "^#|^$"
user www www;
worker_processes auto;
worker_cpu_affinity auto;
error_log logs/error.log error;
pid logs/nginx.pid;
worker_rlimit_nofile 409600;
events
{
use epoll;
worker_connections 409600;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
upstream redis{
server 127.0.0.1:6379;
keepalive 10;
}
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# GET /get?key=some_key
location = /get {
set_unescape_uri $key $arg_key; # this requires ngx_set_misc
redis2_query get $key;
redis2_pass 127.0.0.1:6380;
}
# GET /set?key=one&val=first%20value
location = /set {
set_unescape_uri $key $arg_key; # this requires ngx_set_misc
set_unescape_uri $val $arg_val; # this requires ngx_set_misc
redis2_query set $key $val;
redis2_pass 127.0.0.1:6380;
}
}
}
2,检测语法
[root@server ~]# /usr/local/openresty/nginx/sbin/nginx -t
3,启动
[root@server ~]# /usr/local/openresty/nginx/sbin/nginx
四,测试功能
1,SET Key
[root@client ~]# curl "http://172.17.6.60/set?key=name&val=minyt"
+OK
2,GET Key
[root@client ~]# curl http://172.17.6.60/get?key=name
$5
minyt
五,备注
经了解,目前OpenResty第三方Redis模块都不支持集群协议
[root@server ~]# ./configure --help|grep redis
--without-http_redis2_module disable ngx_http_redis2_module
--without-http_redis_module disable ngx_http_redis_module
--without-lua_redis_parser disable the lua-redis-parser library
--without-lua_resty_redis disable the lua-resty-redis library
原文:http://jerrymin.blog.51cto.com/3002256/1962015
内容总结
以上是互联网集市为您收集整理的OpenResty Redis 安装部署测试SET GET功能全部内容,希望文章能够帮你解决OpenResty Redis 安装部署测试SET GET功能所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。