在Mac上安装Redis(Rails和VScode)
我想要在我的本地环境中查看使用别人提供的Redis创建的Web应用程序,因此我需要安装Redis。 Redis的官方网站在这里。
Redis是什么?
超高速数据库
被部分应用
被用于实时排名等
安装
首先需要安装Redis。
$brew install redis
==> Downloading from https://akamai.bintray.com/1c/1cf97b4ba2f47029f76979b430c76c760ce467786d85907031a86b58fd4b4960?__gda__=exp=1571060074~hmac=4f9428de0396e8
######################################################################## 100.0%
==> Pouring redis-5.0.6.mojave.bottle.tar.gz
==> Caveats
To have launchd start redis now and restart at login:
brew services start redis
Or, if you don't want/need a background service you can just run:
redis-server /usr/local/etc/redis.conf
==> Summary
? /usr/local/Cellar/redis/5.0.6: 13 files, 3.1MB
$redis-server --version
Redis server v=5.0.6 sha=00000000:0 malloc=libc bits=64 build=7a57e483d6f8b275
开始
打开收到的目录,然后运行$bin/rails db:migrate和bundle install。
$bin/rails s
用于启动Rails服务器和Redis服务器的两个终端,请按下添加新终端按钮,创建两个终端(请参考下方截图)。
$redis-server
55517:C 14 Oct 2019 22:44:35.927 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
55517:C 14 Oct 2019 22:44:35.928 # Redis version=5.0.6, bits=64, commit=00000000, modified=0, pid=55517, just started
55517:C 14 Oct 2019 22:44:35.928 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.6 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 55517
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
55517:M 14 Oct 2019 22:44:35.945 # Server initialized
55517:M 14 Oct 2019 22:44:35.946 * Ready to accept connections
因为显示”Ready to accept connections”,所以Redis已经成功启动。
你可以在本地查看Web应用。
结束
请在结束时分别使用Ctrl+C关闭Puma和Redis。
(虽然Redis也有其他的关闭方式,但此次我们选择了使用Ctrl+C以简单地结束。)
VScode的终端添加按钮
