root 发表于 2018-11-3 11:42:02

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
  # yum -y install tclyum -y install perl-devel gcc gmake
  # yum -y install tclwget https://openresty.org/download/openresty-1.11.2.5.tar.gz
  # yum -y install tcltar zxvf openresty-1.11.2.5.tar.gz
  # yum -y install tclcd openresty-1.11.2.5
  # yum -y install tcl./configure
  # yum -y install tclgmake
  # yum -y install tclgmake install
  2,查看Nginx版本
  # 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
  # yum -y install tcl
  # wget http://download.redis.io/releases/redis-4.0.1.tar.gz
  # tar zxvf redis-4.0.1.tar.gz
  # cd redis-4.0.1
  # make
  # make test
  # make install
  # 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,启动
  # /etc/init.d/redis_6379 start
  三,配置redis_pass
  1,主配置文件
  # cat /usr/local/openresty/nginx/conf/nginx.conf |grep -Ev "^#|^$"
  userwww www;
  worker_processesauto;
  worker_cpu_affinity auto;
  error_loglogs/error.logerror;
  pid      logs/nginx.pid;
  worker_rlimit_nofile 409600;
  events
  {
  use epoll;
  worker_connections 409600;
  }
  http {
  include       mime.types;
  default_typeapplication/octet-stream;
  log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
  '$status $body_bytes_sent "$http_referer" '
  '"$http_user_agent" "$http_x_forwarded_for"';
  access_loglogs/access.logmain;
  sendfile      on;
  tcp_nopush   on;
  keepalive_timeout65;
  upstream redis{
  server 127.0.0.1:6379;
  keepalive 10;
  }
  server {
  listen       80;
  server_namelocalhost;
  location / {
  root   html;
  indexindex.html index.htm;
  }
  #error_page404            /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,检测语法
  # /usr/local/openresty/nginx/sbin/nginx -t
  3,启动
  # /usr/local/openresty/nginx/sbin/nginx
  四,测试功能
  1,SET Key
  # curl "http://172.17.6.60/set?key=name&val=minyt"
  +OK
  2,GET Key
  #curl http://172.17.6.60/get?key=name
  $5
  minyt
  五,备注
  经了解,目前OpenResty第三方Redis模块都不支持集群协议
  # ./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

页: [1]
查看完整版本: OpenResty Redis 安装部署测试SET GET功能