世界都没见过
谈什么世界观

如何在FreeBSD11或者FreeBSD12上安装Redis 5.x

本篇分享如何在FreeBSD上安装Redis,以及如何将Redis注册为系统服务使用service命令管理,包括redis在FreeBSD系统中开机启动。

最近在FreeBSD上安装MySQL和Nginx时一起把Redis安装了,本篇记录一下如何在FreeBSD上安装Redis。过程也非常简单,几个命令即可安装完成。

1.更新FreeBSD的仓库(ports)

输入下面的命令即可更新仓库,更新仓库源之后有很多软件的新版本,同时也保留旧版本。

portsnap fetch update

提示:更新如果很慢的话可以更改一下FreeBSD的源,可以直接在本站搜索“FreeBSD更换仓库源”。网上很多人说FreeBSD的仓库源只能用官方的,其实不然。

2.直接使用pkg命令安装Redis

在使用pkg安装nginx之前可以搜索一下有哪些Redis版本可以安装,运行以下命令:

pkg search redis

输出如下,可以看到和redis相关的软件很多,在这里可以带上redis版本,例如redis5或者redis-5。

credis-0.2.3                   Library for communicating with Redis serverserlang-eredis-1.1.0            Non-blocking Redis client for Erlanghiredis-0.13.3                 Minimalistic C client library for the Redis databaselua-resty-redis-0.27_1         Redis client driver for the ngx_lua nginx modulenagios-check_redis-0.1_1       Nagios plugin to check redis serverp5-AnyEvent-Redis-0.24_2       Non-blocking Redis client written in Perlp5-CHI-Driver-Redis-0.10       Redis driver for CHIp5-Dancer-Plugin-Redis-0.8_1   Redis database connector for Dancerp5-Redis-1.9950                Perl binding for Redis databasep5-Redis-Fast-0.26             Perl binding for Redis databasep5-Redis-JobQueue-1.19         Job queue management implemented using Redis serverp5-Redis-RateLimit-1.0002      Sliding window rate limiting with Redisp5-Redis-hiredis-0.11.0_2      Simple wrapper around hiredis C clientp5-RedisDB-2.53                Perl extension to access redis databasep5-RedisDB-Parser-2.22         Perl extension for Redis protocol parserp5-Test-Mock-Redis-0.22        Use in place of Redis for unit testingphp72-pecl-redis-5.3.1         Extension to access Redisphp73-pecl-redis-5.3.1         Extension to access Redisphp74-pecl-redis-5.3.1         Extension to access Redispy27-hiredis-0.2.0             Python extension that wraps hiredispy27-redis-3.5.3               Python client for Redis key-value storepy27-redis2-2.10.6_1           Python client for Redis key-value storepy27-txredisapi-1.4.7          Non-blocking redis client for pythonpy37-aioredis-1.3.1            Python asyncio (PEP 3156) Redis client librarypy37-azure-mgmt-redis-7.0.0.r1 Microsoft Azure Redis Cache Management Client Library for Pythonpy37-django-redis-4.12.1       Full featured Redis cache/session backend for Djangopy37-fakeredis-1.4.3           Fake version of databases/py-redis for unit testingpy37-hiredis-0.2.0             Python extension that wraps hiredispy37-redis-3.5.3               Python client for Redis key-value storepy37-redis2-2.10.6_1           Python client for Redis key-value storepy37-txredisapi-1.4.7          Non-blocking redis client for pythonredis-5.0.9                    Persistent key-value database with built-in net interfaceredis-devel-6.0.8.20200910     Persistent key-value database with built-in net interfaceredis4-4.0.14_1                Persistent key-value database with built-in net interfaceredis_exporter-1.10.0          Prometheus exporter for redis statsredisearch-1.6.14              Full-text search over Redisrubygem-azure_mgmt_redis-0.17.4 Microsoft Azure Redis Management Client Library for Rubyrubygem-brpoplpush-redis_script-0.1.1 Bring your own LUA scripts into redisrubygem-em-redis-unified-1.0.1 Eventmachine-based implementation of the Redis protocolrubygem-hiredis-0.6.3_3        Ruby wrapper for hiredisrubygem-mario-redis-lock-1.2.1 Ruby distributed lock using Redis, with emphasis in transparencyrubygem-openid-redis-store-0.0.2_1 Redis store for OpenIDrubygem-peek-redis-rails52-1.2.0 Provide a peek into the Redis calls maderubygem-redis-4.2.2            Ruby client library for Redis, the key value storage serverrubygem-redis-actionpack-5.2.0 Redis session store for ActionPackrubygem-redis-actionpack-rails5-5.2.0 Redis session store for ActionPackrubygem-redis-actionpack-rails50-5.2.0 Redis session store for ActionPackrubygem-redis-actionpack-rails52-5.2.0 Redis session store for ActionPackrubygem-redis-actionpack-rails60-5.2.0 Redis session store for ActionPackrubygem-redis-activesupport-5.2.0 Redis store for ActiveSupport::Cacherubygem-redis-activesupport-rails5-5.2.0 Redis store for ActiveSupport::Cacherubygem-redis-activesupport-rails50-5.2.0 Redis store for ActiveSupport::Cacherubygem-redis-activesupport-rails52-5.2.0 Redis store for ActiveSupport::Cacherubygem-redis-activesupport-rails60-5.2.0 Redis store for ActiveSupport::Cacherubygem-redis-namespace-1.8.0  Ruby client class for Redis with namespace supportrubygem-redis-namespace16-1.6.0 Ruby client class for Redis with namespace supportrubygem-redis-namespace17-1.7.0 Ruby client class for Redis with namespace supportrubygem-redis-rack-2.1.2       Redis Store for Rackrubygem-redis-rack1-1.6.0_1    Redis Store for Rackrubygem-redis-rails-5.0.2      Redis for Ruby on Railsrubygem-redis-rails-rails5-5.0.2 Redis for Ruby on Railsrubygem-redis-rails-rails50-5.0.2 Redis for Ruby on Railsrubygem-redis-rails-rails52-5.0.2 Redis for Ruby on Railsrubygem-redis-rails-rails60-5.0.2 Redis for Ruby on Railsrubygem-redis-store-1.5.0      Namespaced Redis stores for Ruby web frameworksrubygem-uri-redis-0.4.2        Support for parsing redis://host:port/dbindex/keyname

该列表有redis5和redis4,我们安装最新的:

pkg install redis

3.检查Redis是否安装成功

运行如下命令检查redis是否安装成功

redis-server --version

输出:

Redis server v=5.0.9 sha=00000000:0 malloc=libc bits=64 build=b677c39380b27608

4.注册redis为系统服务,使用service命令管理redis

FreeBSD注册为系统service是为了使用service管理该软件。使用如下命令注册是为系统service:

echo 'redis_enable="YES"' >> /etc/rc.conf

或者

sysrc redis_enable="YES"

运行完以上命令之后可以使用cat /etc/rc.conf查看一下rc.conf里是否增加了redis服务。redis_enable="YES"出现在rc.conf中。(注:rc.conf规定了哪些应用在系统引导时启动)

root@iZuf6ex1vq9wpu4qyuu2:~ # cat /etc/rc.confhostname="AlibabaCloud"sshd_enable="YES"dumpdev="NO"ip6addrctl_enable="NO"ip6addrctl_policy="ipv4_prefer"ipv6_activate_all_interfaces="NO"ipv6_network_interfaces="none"ifconfig_lo0="inet 127.0.0.1      netmask 255.0.0.0"ifconfig_vtnet0="inet 172.19.55.205 netmask 255.255.240.0"defaultrouter="172.19.63.253"hostname="iZuf6ex1vq9wpu4qyuu"mysql_enable="YES"nginx_enable="YES"redis_enable="YES"

5.启动redis-server

service redis start

如果没有报错说明成功了,可以使用service redis status查看状态

redis is running as pid 90743.

6.FreeBSD Redis配置文件路径

/usr/local/etc/redis/redis.conf

以上就是安装Redis的全过程。以后用的着就收藏吧。

赞(0) 打赏
未经允许不得转载:VPS排行榜 » 如何在FreeBSD11或者FreeBSD12上安装Redis 5.x

相关推荐

  • 暂无文章

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏