前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >OpenResty Redis 安装部署测试SET GET功能

OpenResty Redis 安装部署测试SET GET功能

作者头像
三杯水Plus
发布2018-11-14 16:40:05
8310
发布2018-11-14 16:40:05
举报
文章被收录于专栏:运维运维运维

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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-09-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 Redis
腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档