2071 make V=s
2072 cd build_dir/target-x86_64_uClibc-0.9.33.2/root-x86/

cd package/network/services/zk-audit/

redis 远程登录   bind 0.0.0.0  /etc/redis/redis.confi 修改这个配置文件就可远程登录上去

启动服务端 redis-server      1162 root     27372 S    redis-server 0.0.0.0:6379

启动客户端 redis-cli

常用命令 :

1 显示所有的键值   keys *

127.0.0.1:6379> keys *
1) "term_app_info:1"
2) "term_info:18"
3) "term_info:23"
4) "term_info:29"
5) "term_info:11"

   2  获取值的信息

127.0.0.1:6379> HGETall term_info:36
1) "timestamp"
2) "1533185362"
3) "mac"

  

  3 准备用lua 连接redis 数据库

然后从找到了开源的redis lua   https://github.com/openresty/lua-resty-redis

    https://github.com/gitforks/redis-lua

然后又来个了nigx配置

     D:\GIT\Q3_mysql\zk_openwrt\wac\nginx.conf

  

    location /demo {
      default_type text/html;
      content_by_lua '
      ngx.say("<p>hello, nginx</p>")';  
    }

通过web可以访问      http://192.168.1.1:8080/demo

页面看到    hello, nginx       (ngx.say 说在页面上的  )

文件路径很重要          /etc/nginx/nginx.conf

新加一个server的配置

  

    server {
listen ;
server_name localhost;
root /tmp/portal_cache/; location /test {
content_by_lua '
local redis = require "luci.lib.redis"
local red = redis:new() red:set_timeout() -- sec -- or connect to a unix domain socket file listened
-- by a redis server:
-- local ok, err = red:connect("unix:/path/to/redis.sock") local ok, err = red:connect("127.0.0.1", )
if not ok then
ngx.say("failed to connect: ", err)
return
end ok, err = red:set("dog", "an animal")
if not ok then
ngx.say("failed to set dog: ", err)
return
end ngx.say("set result: ", ok) local res, err = red:get("dog")
if not res then
ngx.say("failed to get dog: ", err)
return
end if res == ngx.null then
ngx.say("dog not found.")
return
end ngx.say("dog: ", res) red:init_pipeline()
red:set("cat", "Marry")
red:set("horse", "Bob")
red:get("cat")
red:get("horse")
local results, err = red:commit_pipeline()
if not results then
ngx.say("failed to commit the pipelined requests: ", err)
return
end for i, res in ipairs(results) do
if type(res) == "table" then
if res[] == false then
ngx.say("failed to run command ", i, ": ", res[])
else
-- process the table value
end
else
-- process the scalar value
end
end -- put it into the connection pool of size ,
-- with seconds max idle time
local ok, err = red:set_keepalive(, )
if not ok then
ngx.say("failed to set keepalive: ", err)
return
end -- or just close the connection right away:
-- local ok, err = red:close()
-- if not ok then
-- ngx.say("failed to close: ", err)
-- return
-- end
';
}
}

http://192.168.1.1:8822/test 通过访问触发就可以修改数据库, 测试有效

/usr/local/openresty/nginx/nginx.conf

在我的虚拟机里面执行的: openresty -c ~/work/conf/nginx.conf

这个是他的中文网站 : http://openresty.org/cn/components.html

www.xiaohuamao.top:8022 体验了下openresty

git hub 地址 https://github.com/openresty/openresty  可以学习下

这里还有个开源项目 https://gitee.com/alexa/VeryNginx

Redis transactions  事务 所以 Redis 的内部可以保持简单且快速

client:select(15) -- for testing purposes 选择15号数据库, 默认在0号数据库, 你在15号数据库找0号数据库的东西怎么找得到呢?

从redis 里面读取数据然后写入mysql 里面永久存储

从redis 里面读取数据然后显示到页面上  速度快的很嘛

DBSIZE 可以看到有多少条数据 keys * 可能卡

-- 演示将多条记录数据组合成一条sql插入语句(for mysql)

function getTpl0(tname)     -- 获取表各个字段
local t = {
tpl_pack = {"packId","itemId","`group`","num","rate","rateType"},
}
for k, v in pairs(t) do
if tname == k then
return t[k]
end
end
end --tpl = {3813,10,0,2,0,1,1,0,350,5,220,6,0,0,0,0,154,0,0,0,210,80,29}
tpl9122 = {
-- "packId","itemId","`group`","num","rate","rateType"
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , }, {, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
} tpl9123 = {
-- "packId","itemId","`group`","num","rate","rateType"
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , }, {, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
{, , '', , , },
} function createInsertSql(tname, tpl)
local tpl0 = getTpl0(tname) -- 获取表各个字段
local ret = {} -- 插入记录sql table.insert(ret, string.format("insert into `%s`(", tname))
for k, v in pairs(tpl0) do
if k > then
table.insert(ret, ",")
end
table.insert(ret, v)
end
table.insert(ret, ") values ") for k, v in pairs(tpl) do
if k > then
table.insert(ret, ",")
end
table.insert(ret, "(")
for k2, v2 in pairs(v) do
if k2 > then
table.insert(ret, ",")
end
if type(v2) == "string" then
table.insert(ret, string.format("'%s'", v2))
else
table.insert(ret, v2)
end
end
table.insert(ret, ")")
end
table.insert(ret, ";") local result = table.concat(ret) -- 最终的sql语句
print(result)
print()
end
createInsertSql("tpl_pack", tpl9122)
createInsertSql("tpl_pack", tpl9123)
最终的执行结果如下: [zcm@lua ]$lua t1.lua
insert into `tpl_pack`(packId,itemId,`group`,num,rate,rateType) values (,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,); insert into `tpl_pack`(packId,itemId,`group`,num,rate,rateType) values (,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,),(,,'',,,);

openwrt redis的更多相关文章

  1. 记录一次widora sdk编译ipk 实战编译redis

      因为业务需求,需要用到redis存储一点简单的数据,因为redis有良好的哈希机制,可以完美实现我的某些需求,但openwrt官方提供memcached的ipk并没有提供redis,没办法,只能自 ...

  2. Openwrt路由器上安装python

    在路由器安装python之前,还是经过了一番折腾的.淘宝上买了个已经刷好系统的小米迷你路由器,但里面安装的不是预期的Pandorbox,而是LEDE. 这个固件已经带了大量自带的软件,128的内存实在 ...

  3. 使用redis构建可靠分布式锁

    关于分布式锁的概念,具体实现方式,直接参阅下面两个帖子,这里就不多介绍了. 分布式锁的多种实现方式 分布式锁总结 对于分布式锁的几种实现方式的优劣,这里再列举下 1. 数据库实现方式 优点:易理解 缺 ...

  4. Ignite性能测试以及对redis的对比

    测试方法 为了对Ignite做一个基本了解,做了一个性能测试,测试方法也比较简单主要是针对client模式,因为这种方法和使用redis的方式特别像.测试方法很简单主要是下面几点: 不作参数优化,默认 ...

  5. mac osx 安装redis扩展

    1 php -v查看php版本 2 brew search php|grep redis 搜索对应的redis   ps:如果没有brew 就根据http://brew.sh安装 3 brew ins ...

  6. Redis/HBase/Tair比较

    KV系统对比表 对比维度 Redis Redis Cluster Medis Hbase Tair 访问模式    支持Value大小 理论上不超过1GB(建议不超过1MB) 理论上可配置(默认配置1 ...

  7. Redis数据库

    Redis是k-v型数据库的典范,设计思想及数据结构实现都值得学习. 1.数据类型 value支持五种数据类型:1.字符串(strings)2.字符串列表(lists)3.字符串集合(sets)4.有 ...

  8. redis 学习笔记(2)

    redis-cluster 简介 redis-cluster是一个分布式.容错的redis实现,redis-cluster通过将各个单独的redis实例通过特定的协议连接到一起实现了分布式.集群化的目 ...

  9. redis 学习笔记(1)

    redis持久化 snapshot数据快照(rdb) 这是一种定时将redis内存中的数据写入磁盘文件的一种方案,这样保留这一时刻redis中的数据镜像,用于意外回滚.redis的snapshot的格 ...

随机推荐

  1. 5、springcloud整合mybatis注解方式

    1.上一篇学习了服务提供者provider,但是并不是单单就学习了服务提供者.中间还穿插使用了Hikari数据源和spring cloud整合mybatis.但是上篇使用mybatis时还是沿用了老的 ...

  2. LeetCode Array Easy 1. Two Sum

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...

  3. 使用jquery Ajax异步刷新 下拉框

    一个下拉框 <label>产品类型:</label> <select id="protype" name="protype" on ...

  4. MySQL数据库企业级应用实践(多实例源码编译)

    MySQL数据库企业级应用实践(多实例源码编译) 链接:https://pan.baidu.com/s/1ANGg3Kd_28BzQrA5ya17fQ 提取码:ekpy 复制这段内容后打开百度网盘手机 ...

  5. gradle笔记

    gradle笔记 一.基础知识 1.1.groovy语言 Groovy适用于Java虚拟机的一种敏捷的动态语言,他是一种成熟的面向对象编程语言,既可以用于面向对象编程,又可以用作纯粹的脚本语言,使用该 ...

  6. mysql 判断指定条件数据存不存在,不存在则插入

    折腾了半天终于把这个给折腾顺了,但是后来发现用不了竟然...悲剧啊,但是还是要记录下加深记忆 insert into table1 (field1, field2,field3) select ?fi ...

  7. day06 python is == 编码 解码

    day06 python   一. is 和 == 的区别     == :比较, 判断, 比较的是值: 可以比较数字, 字符串, 列表, 元组, 字典,等     is :是 比较, 比较的是内存地 ...

  8. 异步ajax请求数据处理

    jQuery.ajax(url,[settings]) 概述 通过 HTTP 请求加载远程数据. jQuery 底层 AJAX 实现.简单易用的高层实现见 $.get, $.post 等.$.ajax ...

  9. Ubuntu系统管理systemd

    systemctl命令 systemctl list-units - 列出所有jobs/serviceList all units (where unit is the term for a job/ ...

  10. 【leetcode】967. Numbers With Same Consecutive Differences

    题目如下: Return all non-negative integers of length N such that the absolute difference between every t ...