openwrt redis
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的更多相关文章
- 记录一次widora sdk编译ipk 实战编译redis
因为业务需求,需要用到redis存储一点简单的数据,因为redis有良好的哈希机制,可以完美实现我的某些需求,但openwrt官方提供memcached的ipk并没有提供redis,没办法,只能自 ...
- Openwrt路由器上安装python
在路由器安装python之前,还是经过了一番折腾的.淘宝上买了个已经刷好系统的小米迷你路由器,但里面安装的不是预期的Pandorbox,而是LEDE. 这个固件已经带了大量自带的软件,128的内存实在 ...
- 使用redis构建可靠分布式锁
关于分布式锁的概念,具体实现方式,直接参阅下面两个帖子,这里就不多介绍了. 分布式锁的多种实现方式 分布式锁总结 对于分布式锁的几种实现方式的优劣,这里再列举下 1. 数据库实现方式 优点:易理解 缺 ...
- Ignite性能测试以及对redis的对比
测试方法 为了对Ignite做一个基本了解,做了一个性能测试,测试方法也比较简单主要是针对client模式,因为这种方法和使用redis的方式特别像.测试方法很简单主要是下面几点: 不作参数优化,默认 ...
- mac osx 安装redis扩展
1 php -v查看php版本 2 brew search php|grep redis 搜索对应的redis ps:如果没有brew 就根据http://brew.sh安装 3 brew ins ...
- Redis/HBase/Tair比较
KV系统对比表 对比维度 Redis Redis Cluster Medis Hbase Tair 访问模式 支持Value大小 理论上不超过1GB(建议不超过1MB) 理论上可配置(默认配置1 ...
- Redis数据库
Redis是k-v型数据库的典范,设计思想及数据结构实现都值得学习. 1.数据类型 value支持五种数据类型:1.字符串(strings)2.字符串列表(lists)3.字符串集合(sets)4.有 ...
- redis 学习笔记(2)
redis-cluster 简介 redis-cluster是一个分布式.容错的redis实现,redis-cluster通过将各个单独的redis实例通过特定的协议连接到一起实现了分布式.集群化的目 ...
- redis 学习笔记(1)
redis持久化 snapshot数据快照(rdb) 这是一种定时将redis内存中的数据写入磁盘文件的一种方案,这样保留这一时刻redis中的数据镜像,用于意外回滚.redis的snapshot的格 ...
随机推荐
- 微信小程序的加载机制和运行机制
一.运行机制 冷启动指的是重新启动,热启动指的是5分钟内从后台切换到前台,只有冷启动才能加载最新的包. 小程序什么时候会关闭? 5min后台运行,连续收到两次(2s)系统告警. 二.加载机制 三.小程 ...
- ASE19 团队项目 alpha 阶段 Frontend 组 scrum7 记录
本次会议于11月11日,11:30 在微软北京西二号楼13158,持续15分钟. 与会人员:Jingyi Xie, , Ziwei Wu, Jiaqi Xu, Jingwei Yi, Hanyue T ...
- WPF textbox 鼠标滚动更新日期,text文本值更改
/// <summary> /// 选择日期 /// </summary> private void RQTxt_MouseWheel(object sender, Mouse ...
- 企业级NginxWeb服务优化实战(上)
企业级NginxWeb服务优化实战(上) 1. Nginx基本安全优化 1.1 调整参数隐藏Nginx软件版本号信息 一般来说,软件的漏洞都和版本有关,这个很像汽车的缺陷,同一批次的要有问题就都有问题 ...
- PHP-缺失的第一个正数
给定一个未排序的整数数组,找出其中没有出现的最小的正整数. 示例 1: 输入: [1,2,0]输出: 3示例 2: 输入: [3,4,-1,1]输出: 2示例 3: 输入: [7,8,9,11,12] ...
- 使用eclipse开发java web网页
前面说了手动配置一个应用,手动配置可以更深入的理解web应用的分布,但是一般的编辑器没有语法错误提示,所以开发起来对于错误的寻找不太容易,效率相对较低,所以在理解清楚web项目的结构之后,我们使用ec ...
- html中设置一个div可编辑文本
<div contenteditable="true"></div> <!-- outline: none;设置获取焦点没有高亮边框 -->
- Unity HOME
{ https://unity.com/cn?_ga=2.134655153.1528856053.1574826116-818341090.1574826116 }
- 神建模+dp——cf1236E
首先将两个人的所有可能的操作建立成一个模型:m+2行n列的矩阵 序列A对应图上的格子(i,Ai),第0行作为起点,最后一行作为终点,每个点可以向左下,下,右下走,每种可行的情况对应图上的一条路径 推出 ...
- iOS 7 认识 TextKit
本文由 伯乐在线 - 和谐老约翰 翻译自 Max Seelemann.欢迎加入技术翻译小组.转载请参见文章末尾处的要求. iOS7 的发布给开发者的案头带来了很多新工具.其中一个就是 TextKit( ...