创建实例
打开https://ecs.console.aliyun.com/,选择创建实例
然后选择按量付费,地域随机分配,实例规格ecs.t5-lc1m2.small,配置为1vCPU,2GiB内存
操作系统镜像为Alibaba Cloud Linux 3.2104 LTS 64位
选择专有网络,交换机,分配公网IP v4地址,这样可以用ssh远程登录,点下一步系统配置,配置自定义密码。密码的配置要求:8~30 个字符,必须同时包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号),其中 Windows 实例不能以斜线号(/)开头
点下一步,然后确认订单,同意协议,创建实例
创建成功,转到管理控制台,查看服务器的ip地址
使用客户端ssh工具,比如SecureCRT登录服务器
查看系统信息安装成功
[root@iZ2ze4v0qmpn8c4laatw8qZ ~]# cat /etc/os-release
NAME="Alibaba Cloud Linux"
VERSION="3 (Soaring Falcon)"
ID="alinux"
ID_LIKE="rhel fedora centos anolis"
VERSION_ID="3"
PLATFORM_ID="platform:al8"
PRETTY_NAME="Alibaba Cloud Linux 3 (Soaring Falcon)"
ANSI_COLOR="0;31"
HOME_URL="https://www.aliyun.com/"
从yum仓库安装redis
使用dnf info redis查看系统仓库中已有redis
Available Packages
Name : redis
Version : 6.0.5
Release : 1.11.al8
Architecture : x86_64
Size : 1.2 M
Source : redis-6.0.5-1.11.al8.src.rpm
Repository : alinux3-updates
Summary : A persistent key-value database
URL : https://redis.io
License : BSD and MIT
Description : Redis is an advanced key-value store. It is often referred to as a data
: structure server since keys can contain strings, hashes, lists, sets and
: sorted sets.
:
: You can run atomic operations on these types, like appending to a
: string; incrementing the value in a hash; pushing to a list; computing
: set intersection, union and difference; or getting the member with
: highest ranking in a sorted set.
:
: In order to achieve its outstanding performance, Redis works with an
: in-memory dataset. Depending on your use case, you can persist it either
: by dumping the dataset to disk every once in a while, or by appending
: each command to a log.
:
: Redis also supports trivial-to-setup master-slave replication, with very
: fast non-blocking first synchronization, auto-reconnection on net split
: and so forth.
:
: Other features include Transactions, Pub/Sub, Lua scripting, Keys with a
: limited time-to-live, and configuration settings to make Redis behave
: like a cache.
:
: You can use Redis from most programming languages also.
运行dnf install redis可以安装
=============================================================================================================
Package Architecture Version Repository Size
=============================================================================================================
Installing:
redis x86_64 6.0.5-1.11.al8 alinux3-updates 1.2 M
Installing dependencies:
daxctl-libs x86_64 71.1-2.1.al8 alinux3-updates 42 k
Transaction Summary
=============================================================================================================
Install 2 Packages
Total download size: 1.3 M
Installed size: 4.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): daxctl-libs-71.1-2.1.al8.x86_64.rpm 271 kB/s | 42 kB 00:00
(2/2): redis-6.0.5-1.11.al8.x86_64.rpm 7.4 MB/s | 1.2 MB 00:00
-------------------------------------------------------------------------------------------------------------
Total 7.5 MB/s | 1.3 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : daxctl-libs-71.1-2.1.al8.x86_64 1/2
Running scriptlet: daxctl-libs-71.1-2.1.al8.x86_64 1/2
Running scriptlet: redis-6.0.5-1.11.al8.x86_64 2/2
Installing : redis-6.0.5-1.11.al8.x86_64 2/2
Running scriptlet: redis-6.0.5-1.11.al8.x86_64 2/2
Verifying : daxctl-libs-71.1-2.1.al8.x86_64 1/2
Verifying : redis-6.0.5-1.11.al8.x86_64 2/2
Installed:
daxctl-libs-71.1-2.1.al8.x86_64 redis-6.0.5-1.11.al8.x86_64
Complete!
运行systemctl status redis查看服务状态为未启动
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: inactive (dead)
运行systemctl start redis启动服务,redis-cli连接服务端,设置键值和获取键值
[root@iZ2ze4v0qmpn8c4laatw8qZ ~]# redis-cli
127.0.0.1:6379> set test1 value1
OK
127.0.0.1:6379> get test1
"value1"
127.0.0.1:6379>
监听端口为127.0.0.1:6379,这只是开放本地端口,如果要外网访问,需要设置密码,然后再开放实际ip地址的访问
[root@iZ2ze4v0qmpn8c4laatw8qZ ~]# netstat -ntlp | grep 6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 2057/redis-server 1
下载redis源码编译
系统仓库的redis软件包的更新时间可能会延后,那有时也需要使用redis源码来编译,在dnf info redis中可以看到官网地址https://redis.io,找到下载地址下载
解压下载的文件进入目录
[root@iZ2ze4v0qmpn8c4laatw8qZ redis-7.0.2]# ls
00-RELEASENOTES CONTRIBUTING INSTALL README.md runtest-cluster SECURITY.md tests
BUGS COPYING Makefile redis.conf runtest-moduleapi sentinel.conf TLS.md
CONDUCT deps MANIFESTO runtest runtest-sentinel src utils
安装依赖包 dnf install jemalloc jemalloc-devel
进入deps/jemalloc目录编译jemalloc
[root@iZ2ze4v0qmpn8c4laatw8qZ redis-7.0.2]# cd deps/jemalloc/
[root@iZ2ze4v0qmpn8c4laatw8qZ jemalloc]# make
make: *** No targets specified and no makefile found. Stop.
[root@iZ2ze4v0qmpn8c4laatw8qZ jemalloc]# ./configure && make
运行make命令后编译
[root@iZ2ze4v0qmpn8c4laatw8qZ redis-7.0.2]# make
cd src && make all
make[1]: Entering directory '/root/redis-7.0.2/src'
CC Makefile.dep
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d eval.d bio.d rio.d rand.d memtest.d syscheck.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d tracking.d connection.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d resp_parser.d call_reply.d script_lua.d script.d functions.d function_lua.d commands.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d redisassert.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d redisassert.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d
(cd ../deps && make distclean)
编译完成显示信息
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory '/root/redis-7.0.2/src'
查看软件版本
[root@iZ2ze4v0qmpn8c4laatw8qZ redis-7.0.2]# src/redis-server --version
Redis server v=7.0.2 sha=00000000:0 malloc=libc bits=64 build=26ea65d61d8b2cac
[root@iZ2ze4v0qmpn8c4laatw8qZ redis-7.0.2]# src/redis-cli --version
redis-cli 7.0.2
运行make install安装到/usr/local/bin目录
[root@iZ2ze4v0qmpn8c4laatw8qZ redis-7.0.2]# make install
cd src && make install
make[1]: Entering directory '/root/redis-7.0.2/src'
Hint: It's a good idea to run 'make test' ;)
INSTALL redis-server
INSTALL redis-benchmark
INSTALL redis-cli
make[1]: Leaving directory '/root/redis-7.0.2/src'
[root@iZ2ze4v0qmpn8c4laatw8qZ redis-7.0.2]# ls /usr/local/bin/redis-*
/usr/local/bin/redis-benchmark /usr/local/bin/redis-check-rdb /usr/local/bin/redis-sentinel
/usr/local/bin/redis-check-aof /usr/local/bin/redis-cli /usr/local/bin/redis-server