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

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

你可能感兴趣的:(OpenResty Redis 安装部署测试SET GET功能)