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的格 ...
随机推荐
- 2、eureka注册中心集群
1. Eureka作为spring cloud的服务发现与注册中心,在整个的微服务体系中,处于核心位置.单机模式下的eureka服务,显然不能满足高可用的实际生产环境,这就要求配置一个能够应对各种突发 ...
- vue aliasConfig(模块别名配置)
今天研究了下鹏哥搭建的项目代码,一个人捣鼓了半天模块别名配置,边写边测试,才慢慢明白,所有写下来当个笔记: 在vue项目中,经常根据需要引入不同的功能模块,默认情况下我们通过代码 import mod ...
- iOS音频Error
最近在cocos应用上发现一个比较奇怪的bug,当应用正在调用录音的时候,按下home键回到后台,然后打开一个音乐播放器播放一个音乐,再回到游戏中游戏就会卡死. 之前录音和播放设置是下方: 播放: [ ...
- 使用androidstudio时遇到的一些小错误
1 路径名字中不能有汉字 报如下错误:Error:(1, 0) Your project path contains non-ASCII characters. This will most lik ...
- 搜索solr
这是我第一次写博客,没有系统性.专业性,东西很杂,也不知道自己在写些什么. SOA分布式架构,所以,使用solr,搜索层的服务层需要搭建起来.搜索系统的表现层搭建 ,打包方式是war包 域名改变代表系 ...
- netstat 指令
netstat 指令将所有的网络端口监听情况进行罗列 语法 netstat -tuln 几个常见的服务端口 例 通过grep 查看端口来获得上面的服务是否开启,并给予提示 1 #!/bin/bas ...
- C#排序 转
本文链接:https://blog.csdn.net/fysuccess/article/details/36416255 C#中List<T>排序的两种方法 List<Studen ...
- vue filters 日期
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- PHP中session存储及删除变量的方法
Session 变量保存的信息是单一用户的,并且可供应用程序中的所有页面使用.但是session会话信息是临时的,在用户离开网站后就会被删除.如果需要永久储存信息,就需要把数据存储在数据库中. < ...
- python实现收邮件判断模块poplib,email
一.代码 # 输入邮件地址, 口令和POP3服务器地址: import datetime import email import poplib import email.policy from ema ...