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. android绑定usb前后摄像头

    在Android的系统会有前置摄像头和后置摄像头的定义,摄像头分为SOC类型的摄像头和USB这一类的摄像头,接下要分析就是USB摄像头这一类 . 一般在android或者linux系统中分析一个模块, ...

  2. 关于STLINK

    关于STLINK 1.STLIN固件升级 1)打开ST-LINK Utility,选择ST-LINK->Firmware update 2)连接ST-LINK 3)可以看到STLINK当前的软件 ...

  3. nexus私服仓库搭建以及项目引用

    第一步:使用ubunto下载安装nexus  并打开登录进入到nexus管理页面,默认账号为 admin  密码在 admin.password 中,首次登录会让你重新修改密码 第二步  配置自己本地 ...

  4. 【Luogu】【关卡2-15】动态规划的背包问题(2017年10月)【还差一道题】

    任务说明:这是最基础的动态规划.不过如果是第一次接触会有些难以理解.加油闯过这个坎. 01背包二维数组优化成滚动数组的时候有坑有坑有坑!!!必须要downto,downto,downto 情景和代码见 ...

  5. 【LeetCode】Hash

    [451] Sort Characters By Frequency [Medium] 给一个字符串,要求返回按照字母出现频率的排序后的字符串.(哈希表+桶排) 有个技巧是Hash用Value作为In ...

  6. loj2471[九省联考2018]一双木棋

    题意:在一个n*m的棋盘上,A和B轮流放置棋子.一个位置能够放置棋子当且仅当它上面没有棋子并且它的上面和左边一格都已经放了棋子(不难发现是一个上三角阶梯状).每个格子有两个权值,当A在上面放置棋子时A ...

  7. 利用Python批量重命名一系列文件名杂乱的文件

    假设目录下面有这样一系列命令杂乱的文件: OPENFOAM -TRAINING- PART- #1.pdf OPENFOAM - TRAINING- PART- #2.pdf OPENFOAM- TR ...

  8. leetcode-161周赛-5248-统计【优美子数组】

    题目描述: 自己的提交:超时: class Solution: def numberOfSubarrays(self, nums, k: int) -> int: dp = [0]* (len( ...

  9. 找关键字,分割字符串,输出一个vector

    vector<string> split(const string& str, const string& delim) { vector<string> re ...

  10. js委托事件-addEventListeners(冒泡方向)

    JQuery中live().delegate().on()事件都能给新增元素绑定事件,原理就是用了事件委托. 实例: 给id为div的元素绑定一个click委托,如果冒泡上来的元素是P元素就会执行al ...