第一个Celery程序

来自CloudWiki
Cloud17讨论 | 贡献2020年5月30日 (六) 04:32的版本 (创建页面,内容为“==Redis配置和启动== 我们以Redis为例,首先修改Redis配置文件redis.conf,修改bind = 127.0.0.0.1为bind =0.0.0.0,意思是允许远程访问Redis…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

Redis配置和启动

我们以Redis为例,首先修改Redis配置文件redis.conf,修改bind = 127.0.0.0.1为bind =0.0.0.0,意思是允许远程访问Redis数据库。

redis-4.0.11/redis.conf

bind 0.0.0.0

接下来启动Redis

cd src

./redis-server ../redis.conf

[root@localhost src]# ps -ef |grep redis

root      84370  80953  0 12:07 pts/2    00:00:00 ./redis-server 0.0.0.0:6379
root      84388  84206  0 12:11 pts/3    00:00:00 grep --color=auto redis

python配置redis模块

[root@localhost op]# pip3 install redis

[root@localhost op]# python3

Python 3.7.5 (default, May  8 2020, 10:08:52)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import redis
>>> r = redis.Redis(host='localhost',port=6379,db=0)
>>> r.set('foo','bar')
True
>>> r.get('foo')
b'bar'
>>> exit()