Skip to content

Commit 860ac6e

Browse files
committed
update readme
1 parent e178a75 commit 860ac6e

File tree

2 files changed

+276
-63
lines changed

2 files changed

+276
-63
lines changed

README.md

+63-63
Original file line numberDiff line numberDiff line change
@@ -3,70 +3,70 @@
33
[![Conda](https://img.shields.io/conda/pn/conda-forge/python.svg)]()
44
[![GitHub license](https://img.shields.io/github/license/Tinywan/tinywan-react-app.svg)](https://github.com/Tinywan/tinywan-react-app/blob/master/LICENSE)
55
## <a name="index"/>目录
6-
+ Nginx 教程 (Nginx tutorial)
7-
+ [Nginx编译安装](/Nginx/nginx-install.md)
8-
+ [Nginx.conf详解和配置](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx/nginx-base-config.md)
9-
+ [Location 详解和配置](https://github.com/Tinywan/lua-nginx-redis/blob/master/docs/Nginx/location-detail.md)
10-
+ [Nginx基础知识](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx/nginx-basic.md)
11-
+ [Nginx高性能WEB服务器详解](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx/nginx-high-basic.md)
12-
+ [Nginx高并发系统内核优化和PHP7配置文件优化](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx/nginx-parameter-config.md)
13-
+ [Nginx和PHP-FPM启动脚本](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx/nginx-start-script.md)
14-
   +   [如何在工作中提高Ngixn服务器性能?达到高效](https://juejin.im/post/5adb45e96fb9a07ab773c767?utm_source=gold_browser_extension)
15-
   +   项目案例 (Project notes)
16-
+ [Nginx 同一个IP上配置多个HTTPS主机](https://github.com/Tinywan/lua-nginx-redis/blob/master/Nginx/more-domain-config.md)
17-
+ [Nginx 如何配置一个安全的HTTPS网站服务器](http://www.cnblogs.com/tinywan/p/7542629.html)
18-
+ [Nginx 配置启用 HTTP/2](http://www.cnblogs.com/tinywan/p/7860774.html)
19-
+ 扩展模块 (Third-party module)
20-
+ [nginx-vod-module](http://www.cnblogs.com/tinywan/p/7879559.html)
21-
+ [nginx-module-vts](http://www.cnblogs.com/tinywan/p/7872366.html)
22-
+ [ngx_cache_purge](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx/Nginx-Web/Nginx-8-proxy_cache.md)
23-
+ [lua-nginx-module](http://www.cnblogs.com/tinywan/p/6538006.html)
24-
+ [nginx-rtmp-module](http://www.cnblogs.com/tinywan/p/6639360.html)
25-
+ Lua 教程
26-
+ [Lua 基础语法](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Lua-Script/lua-basic.md)
27-
+ [luajit 执行文件默认安装路径](#Nginx_base_knowledge)
28-
+ [lua中self.__index = self 详解](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Lua-Script/oop/self__index.md)
29-
+ Redis 教程
30-
+ [Redis 安装](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis/redis-install.md)
31-
+ [Redis 配置详解](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis/redis-config.md)
32-
+ [Redis 基础知识](#Redis_base_knowledge)
33-
+ [Redis 开发与运维](#Redis-DevOps)
34-
+ [Redis执行Lua脚本基本用法](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis/redis-lua.md)
35-
+ Openresty 教程
36-
+ [安装默认配置信息](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-basic.md)
37-
+ [如何编译一个高性能 OpenResty](https://yq.aliyun.com/articles/228399)
38-
+ [ngx_lua APi 方法和常量](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-api.md)
39-
+ [ngx_lua 扩展模块学习](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-resty-module.md)
40-
+ [lua-resty-upstream-healthcheck使用](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/lua-resty-upstream-healthcheck.md)
41-
+ [Openresty与Nginx_RTMP](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/openresty-rtmp.md)
42-
+ [自己写的一个简单项目lua_project_v0.01](https://github.com/Tinywan/lua_project_v0.01)
43-
+ PHP 教程
44-
+ [PHP脚本](#PHP_base_knowledge)
45-
+ [PHP脚本运行Redis](#PHP_Run_Redis)
46-
+ [PHP7中php.ini/php-fpm/www.conf的配置,Nginx和PHP-FPM的开机自动启动脚本](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/PHP/PHP-FPM/config.md)
47-
+ [PHP 脚本执行一个Redis 订阅功能,用于监听键过期事件,返回一个回调,API接受改事件](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis-PHP/Php-Run-Redis-psubscribe/nohupRedisNotify.php)
48-
+ Linux 教程
49-
+ [Linux 基础知识](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Linux/linux-basic.md)
50-
+ Systemd 入门教程
51-
+ [命令篇](http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html)
52-
+ [实战篇](http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html)
53-
+ [定时器教程](http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html)
54-
+ Shell 教程
55-
+ Shell脚本
56-
+ [编写快速安全Bash脚本的建议](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Shell/write-shell-suggestions.md)
57-
+ [shell脚本实现分日志级别记录日志](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/Shell_Log.sh)
58-
+ [Nginx日志定时备份和删除](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/Shell_Nginx_Log_cut.sh)
59-
+ [SHELL脚本小技巧](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/Shell_script.md)
60-
+ [Mysql 自动备份脚本安全加锁机制](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/backup_mysql.sh)
61-
+ 流媒体教程
62-
+ [Nginx配置Rtmp支持Hls的直播和点播功能](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/HLS-live-vod.md)
63-
+ [HLS视频直播和点播的Nginx的Location的配置信息(成功)](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Nginx-Rtmp/HLS-live-vod-locatiuon-config.md)
6+
#### Nginx 教程 (Nginx tutorial)
7+
* [Nginx编译安装](/Nginx/nginx-install.md)
8+
* [Nginx.conf详解和配置](/Nginx/nginx-base-config.md)
9+
* [Location 详解和配置](/docs/Nginx/location-detail.md)
10+
* [Nginx基础知识](/Nginx/nginx-basic.md)
11+
* [Nginx高性能WEB服务器详解](/Nginx/nginx-high-basic.md)
12+
* [Nginx高并发系统内核优化和PHP7配置文件优化](/Nginx/nginx-parameter-config.md)
13+
* [Nginx和PHP-FPM启动脚本](/Nginx/nginx-start-script.md)
14+
* [如何在工作中提高Ngixn服务器性能?达到高效](https://juejin.im/post/5adb45e96fb9a07ab773c767?utm_source=gold_browser_extension)
15+
* 项目案例 (Project notes)
16+
* [Nginx 同一个IP上配置多个HTTPS主机](https://github.com/Tinywan/lua-nginx-redis/blob/master/Nginx/more-domain-config.md)
17+
* [Nginx 如何配置一个安全的HTTPS网站服务器] (http://www.cnblogs.com/tinywan/p/7542629.html)
18+
* [Nginx 配置启用 HTTP/2](http://www.cnblogs.com/tinywan/p/7860774.html)
19+
* 扩展模块 (Third-party module)
20+
* [nginx-vod-module](http://www.cnblogs.com/tinywan/p/7879559.html)
21+
* [nginx-module-vts](http://www.cnblogs.com/tinywan/p/7872366.html)
22+
* [ngx_cache_purge](/Nginx/Nginx-Web/Nginx-8-proxy_cache.md)
23+
* [lua-nginx-module](http://www.cnblogs.com/tinywan/p/6538006.html)
24+
* [nginx-rtmp-module](http://www.cnblogs.com/tinywan/p/6639360.html)
25+
26+
#### Lua 教程
27+
* [Lua 基础语法](/Lua-Script/lua-basic.md)
28+
* [luajit 执行文件默认安装路径](#Nginx_base_knowledge)
29+
* [lua中self_indes详解](/Lua-Script/oop/self__index.md)
30+
31+
#### Redis 教程
32+
* [Redis 安装](/Redis/redis-install.md)
33+
* [Redis 配置详解](/Redis/redis-config.md)
34+
* [Redis 基础知识](#Redis_base_knowledge)
35+
* [Redis 开发与运维](#Redis-DevOps)
36+
* [Redis执行Lua脚本基本用法](/Redis/redis-lua.md)
37+
* [Redis漏洞如何防止被黑客攻击](/Redis/redis-safety.md)
38+
39+
#### Openresty 教程
40+
* [安装默认配置信息](/Openresty/openresty-basic.md)
41+
* [如何编译一个高性能 OpenResty](https://yq.aliyun.com/articles/228399)
42+
* [ngx_lua APi 方法和常量](/Openresty/openresty-api.md)
43+
* [ngx_lua 扩展模块学习](/Openresty/openresty-resty-module.md)
44+
* [lua-resty-upstream-healthcheck使用](/Openresty/lua-resty-upstream-healthcheck.md)
45+
* [Openresty与Nginx_RTMP](/Openresty/openresty-rtmp.md)
46+
* [自己写的一个简单项目lua_project_v0.01] (https://github.com/Tinywan/lua_project_v0.01)
47+
48+
#### PHP 相关
49+
* [PHP脚本运行Redis](#PHP_Run_Redis)
50+
* [PHP7中php.ini/php-fpm/www.conf的配置,Nginx和PHP-FPM的开机自动启动脚本](/PHP/PHP-FPM/config.md)
51+
* [PHP 脚本执行一个Redis 订阅功能,用于监听键过期事件,返回一个回调,API接受改事件](/Redis-PHP/Php-Run-Redis-psubscribe/nohupRedisNotify.php)
52+
53+
#### Linux 教程
54+
* [Linux 基础知识](/Linux/linux-basic.md)
55+
* Systemd 入门教程
56+
* [命令篇](http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html)
57+
* [实战篇](http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html)
58+
* [定时器教程](http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html)
59+
#### Shell 教程
60+
* [编写快速安全Bash脚本的建议](/Shell/write-shell-suggestions.md)
61+
* [shell脚本实现分日志级别记录日志](/Nginx-Rtmp/Shell_Log.sh)
62+
* [Nginx日志定时备份和删除](/Nginx-Rtmp/Shell_Nginx_Log_cut.sh)
63+
* [SHELL脚本小技巧](/Nginx-Rtmp/Shell_script.md)
64+
* [Mysql 自动备份脚本安全加锁机制](/Nginx-Rtmp/backup_mysql.sh)
65+
66+
#### 流媒体教程
67+
* [Nginx配置Rtmp支持Hls的直播和点播功能](/Nginx-Rtmp/HLS-live-vod.md)
68+
* [HLS视频直播和点播的Nginx的Location的配置信息(成功)](/Nginx-Rtmp/HLS-live-vod-locatiuon-config.md)
6469

6570
## Lua-Ngx
6671
![Markdown](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Images/Nginx-Phase.png)
6772

68-
## 随意打赏
69-
70-
|支付宝打赏|微信打赏|
71-
|:----:|:----:|
72-
|![image](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Images/alipay.png)|![image](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Images/wechat.png)|

Redis/redis-safety.md

+213
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
## Redis 简易安装教程
2+
#### 一、编译安装
3+
+ 下载、解压
4+
5+
```javascript
6+
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
7+
tar -zxvf redis-3.2.8.tar.gz
8+
cd redis-3.2.8
9+
```
10+
+ make 编译
11+
+ 编译之前
12+
13+
```lua
14+
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README.md redis.conf runtest
15+
runtest-cluster runtest-sentinel sentinel.conf src tests utils
16+
```
17+
+ 编译完成之后,可以看到解压文件redis-3.0.7 中会有对应的src、conf等文件
18+
+ 这和windows下安装解压的文件一样,大部分安装包都会有对应的类文件、配置文件和一些命令文件。
19+
+ 进入src文件夹,执行make install进行Redis安装
20+
21+
```bash
22+
tinywan@tinywan:~/redis-3.2.8/src$ sudo make install
23+
[sudo] tinywan 的密码:
24+
25+
Hint: It's a good idea to run 'make test' ;)
26+
27+
INSTALL install
28+
INSTALL install
29+
INSTALL install
30+
INSTALL install
31+
INSTALL install
32+
```
33+
#### 二、部署文件结构
34+
+ 首先为了方便管理,将Redis文件中的conf配置文件和常用命令移动到统一文件中
35+
+ 创建以下文件目录
36+
37+
```bash
38+
~/redis-3.2.8/src$ sudo mkdir -p /usr/local/redis/bin
39+
~/redis-3.2.8/src$ sudo mkdir -p /usr/local/redis/etc
40+
```
41+
+ 切换到`redis-3.2.8`目录,移动`redis.conf`配置文件:
42+
43+
```javascript
44+
~/redis-3.2.8/src$ cd ..
45+
~/redis-3.2.8$ sudo mv /home/tinywan/redis-3.2.8/redis.conf /usr/local/redis/etc
46+
```
47+
+ 继续进入到`src`目录执行其他文件移动:
48+
49+
```javascript
50+
~/redis-3.2.8$ cd src/
51+
sudo mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli
52+
redis-sentinel redis-server redis-trib.rb /usr/local/redis/bin
53+
```
54+
#### 三、配置和启动redis服务
55+
+ 编辑`redis.conf`
56+
57+
```
58+
cd /usr/local/redis/etc
59+
vi redis.conf
60+
```
61+
+ 需要修改的参数
62+
63+
```lua
64+
--后台运行
65+
daemonize yes
66+
67+
--端口号
68+
port 63700
69+
70+
--和哪个网卡绑定,和客户端是什么网段没有关系,这里我绑定的是内网网卡,
71+
bind 10.10.101.127
72+
73+
-- AES("https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Redis/redis-install.md") 加密
74+
-- 结果:b6Pbc42gP8hXPNLzZaDnhREijtn1BSVSIYTkhTXw8SuPGpWZvN5kVpVeEVBdEQDw7M/+EZuDS6FxTOtgD2QrPe6014LPEdv2DY+YSUQZ4cE=
75+
76+
requirepass b6Pbc42gP8hXPNLzZaDnhREijtn1BSVSIYTkhTXw8SuPGpWZvN5kVpVeEVBdEQDw7M/+EZuDS6FxTOtgD2QrPe6014LPEdv2DY+YSUQZ4cE=
77+
78+
-- db文件名
79+
dbfilename dump63700.rdb
80+
81+
-- log 日志文件路径
82+
logfile "/usr/local/redis/etc/redis_63700.log"
83+
84+
-- 安全考虑,rename-command 配置以下命令
85+
rename-command FLUSHALL "tinywangithubFLUSHALL"
86+
87+
rename-command CONFIG "tinywangithubCONFIG"
88+
89+
rename-command SHUTDOWN "tinywangithubSHUTDOWN"
90+
91+
rename-command DEBUG "tinywangithubDEBUG"
92+
```
93+
+ 启动redis服务,并指定启动服务配置文件,检测运行端口,为了安全,请不要使用root用户去启动
94+
```java
95+
$ sudo chown -R www:www /usr/local/redis/ //赋予指定该用户组,而非root账号
96+
$ /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis63700.conf
97+
$ ps -aux | grep redis
98+
www 70764 0.6 0.1 38160 0:00 /usr/local/redis/bin/redis-server 127.0.0.1:63700
99+
www 70768 0.0 0.0 15984 0:00 grep --color=auto redis
100+
```
101+
+ redis-cli启动、检测重置命令是否生效(结果:配置文件已经OK
102+
```lua
103+
$ redis-cli -h 127.0.0.1 -p 63700 -a b6Pbc42gP8hXPNLzZaDnhREijtn1BSVSIYTkhTXw8SuPGpWZvN5kVpVeEVBdEQDw7M/+EZuDS6FxTOtgD2QrPe6014LPEdv2DY+YSUQZ4cE=
104+
127.0.0.1:63700> set username tinywan
105+
OK
106+
127.0.0.1:63700> get username
107+
"tinywan"
108+
127.0.0.1:63700> SHUTDOWN
109+
(error) ERR unknown command 'SHUTDOWN'
110+
127.0.0.1:63700> FLUSHALL
111+
(error) ERR unknown command 'FLUSHALL'
112+
127.0.0.1:63700> tinywangithubFLUSHALL
113+
OK
114+
127.0.0.1:63700> get username
115+
(nil)
116+
127.0.0.1:63700>
117+
```
118+
+ 远程链接出现的错误:
119+
+ 错误信息
120+
121+
```lua
122+
DENIED Redis is running in protected mode because protected mode is enabled,
123+
no bind address was specified, no authentication password is requested to clients.......
124+
```
125+
+ 修改配置文件:`protected-mode yes` 修改为`protected-mode no `
126+
+ 查看远程Redis服务器的版本 `redis-cli -h 192.168.1.3 info | grep 'redis_version'`
127+
128+
#### 四、Redis开机启动的方法
129+
+ [Linux中设置Redis开机启动的方法](http://www.jb51.net/article/110286.htm)
130+
+ 环境:`Ubuntu 16.04.2 LTS`
131+
+ 编辑脚本:`vim /etc/init.d/redis `
132+
133+
```javascript
134+
#!/bin/sh
135+
#
136+
# Simple Redis init.d script conceived to work on Linux systems
137+
# as it does use of the /proc filesystem.
138+
### BEGIN INIT INFO
139+
# Provides: redis6379
140+
# Required-Start: $local_fs $network
141+
# Required-Stop: $local_fs
142+
# Default-Start: 2 3 4 5
143+
# Default-Stop: 0 1 6
144+
# Short-Description: redis6379
145+
# Description: penavico redis 6379
146+
### END INIT INFO
147+
148+
REDISPORT=6379 # 【1】修改一
149+
EXEC=/usr/local/bin/redis-server
150+
CLIEXEC=/usr/local/bin/redis-cli
151+
152+
PIDFILE=/var/run/redis_${REDISPORT}.pid
153+
CONF="/usr/local/redis/etc/redis_6379.conf" # 【2】修改二
154+
155+
case "$1" in
156+
start)
157+
if [ -f $PIDFILE ]
158+
then
159+
echo "$PIDFILE exists, process is already running or crashed"
160+
else
161+
echo "Starting Redis server..."
162+
$EXEC $CONF
163+
fi
164+
;;
165+
stop)
166+
if [ ! -f $PIDFILE ]
167+
then
168+
echo "$PIDFILE does not exist, process is not running"
169+
else
170+
PID=$(cat $PIDFILE)
171+
echo "Stopping ..."
172+
$CLIEXEC -p $REDISPORT shutdown
173+
while [ -x /proc/${PID} ]
174+
do
175+
echo "Waiting for Redis to shutdown ..."
176+
sleep 1
177+
done
178+
echo "Redis stopped"
179+
fi
180+
;;
181+
*)
182+
echo "Please use start or stop as first argument"
183+
;;
184+
esac
185+
```
186+
+ 注册事件,开机启动:`update-rc.d redis defaults`
187+
+ 启动服务:`sudo systemctl start redis`
188+
+ 停止服务:`sudo systemctl stop redis`
189+
+ 查看服务是否启动:
190+
191+
```javascript
192+
www@Tinywan:~/redis-4.0.0/utils$ ps -aux | grep redis
193+
root 1722 0.0 0.8 44752 8300 ? Ssl 13:08 0:00 /usr/local/bin/redis-server 127.0.0.1:6379
194+
www 1730 0.0 0.1 14224 1024 pts/0 S+ 13:08 0:00 grep --color=auto redis
195+
196+
```
197+
198+
#### 五、Redis数据迁移
199+
+ 查找RDB文件:
200+
201+
```sudo find / -name dump.rdb```
202+
+ 进行远程拷贝备份文件:
203+
204+
```scp ./dump.rdb [email protected]:/home/www/redis/```
205+
+ 数据迁移步骤如下
206+
+1)关闭目标Redis服务;
207+
+2)将相应的RDB文件或者AOF文件复制过去;
208+
+3)设置REDISDIR或者开启AOF功能;
209+
+4)启动目标REDIS服务;
210+
211+
212+
213+

0 commit comments

Comments
 (0)