Redis开发与运维:阿里云redis安装
-
redis5.0.7安装
-
配置\ 启动
-
关闭
-
安装
1、下载: home]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
home]# ll
total 1940
-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz
2、解压: home]# tar xzf redis-5.0.7.tar.gz
home]# ll
total 1944
drwxrwxr-x 6 root root 4096 Nov 20 01:05 redis-5.0.7
-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz
3、 移动: home]# mv redis-5.0.7 /usr/local/redis
local]# ll
[lighthouse@VM-4-6-centos local]$ ll
total 48
drwxrwxr-x 6 lighthouse lighthouse 4096 Nov 20 2019 redis
4、 编译:cd 到 /usr/local/redis]# make
redis]# make
cd src && make all
make[1]: Entering directory `/home/redis-5.0.7/src'
CC Makefile.dep
......
5、 安装: redis]# make install
redis]# make install
cd src && make install
make[1]: Entering directory `/home/redis-5.0.7/src'
CC Makefile.dep
make[1]: Leaving directory `/home/redis-5.0.7/src'
make[1]: Entering directory `/home/redis-5.0.7/src'
Hint: It's a good idea to run 'make test' ;)
启动
1、准备复制了两个实例配置
复制 redis6999.conf ,修改端口6999
复制 redis7999.conf ,修改端口7999
/]$ cd /usr/local/bin
/]$ redis-server /usr/local/redis/redis6399.conf
/]$ cd /usr/local/bin
/]$ redis-server /usr/local/redis/redis6399.conf
redis]# ll
total 404
-rw-rw-r-- 1 root root 115100 Nov 20 01:05 00-RELEASENOTES
-rw-rw-r-- 1 root root 53 Nov 20 01:05 BUGS
-rw-rw-r-- 1 root root 2381 Nov 20 01:05 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 Nov 20 01:05 COPYING
drwxrwxr-x 6 root root 4096 Jan 5 14:56 deps
-rw-rw-r-- 1 root root 11 Nov 20 01:05 INSTALL
-rw-rw-r-- 1 root root 151 Nov 20 01:05 Makefile
-rw-rw-r-- 1 root root 6888 Nov 20 01:05 MANIFESTO
-rw-rw-r-- 1 root root 20555 Nov 20 01:05 README.md
-rw-r--r-- 1 root root 61797 Jan 5 15:30 redis6999.conf
-rw-r--r-- 1 root root 61797 Jan 5 15:30 redis7999.conf
-rw-rw-r-- 1 root root 61797 Nov 20 01:05 redis.conf
-rwxrwxr-x 1 root root 275 Nov 20 01:05 runtest
-rwxrwxr-x 1 root root 280 Nov 20 01:05 runtest-cluster
-rwxrwxr-x 1 root root 373 Nov 20 01:05 runtest-moduleapi
-rwxrwxr-x 1 root root 281 Nov 20 01:05 runtest-sentinel
-rw-rw-r-- 1 root root 9710 Nov 20 01:05 sentinel.conf
drwxrwxr-x 3 root root 4096 Jan 5 14:58 src
drwxrwxr-x 11 root root 4096 Nov 20 01:05 tests
drwxrwxr-x 8 root root 4096 Nov 20 01:05 utils
2、设置登陆密码
修改 redis6999.conf --> 找到 requirepass --> 设置密码 requirepass xxxxx
3、客户端登陆
~]# redis-cli -h 127.0.0.1 -p 6999
127.0.0.1:6999> AUTH xxxxx
OK
127.0.0.1:6999> PING
PONG
127.0.0.1:6999>
4、 远程登陆
注意
a. 阿里云web安全组
b. redis6999.conf --> bind --> bind 0.0.0.0
5、关闭
127.0.0.1:6999> SET sc SC
OK
127.0.0.1:6999> get sc
"SC"
127.0.0.1:6999>
127.0.0.1:6999> SHUTDOWN
not connected>
6、重新启动
~]# redis-cli -h 127.0.0.1 -p 6999
127.0.0.1:6999> AUTH 453460205
OK
127.0.0.1:6999> get sc
"SC"
127.0.0.1:6999>
可以看出,我们退出时,先断开连接,然后保存数据库,是优雅关闭~
更多精彩原创心得,请关注微信公众号: 梯形