极
极核实验室
A Step-by-Step Guide to Installing Garnet

A Step-by-Step Guide to Installing Garnet

AI summary
Garnet 是微软用 C# 开发的 Redis 兼容缓存组件,需 .NET8 环境。文章介绍了在 Ubuntu 22.04 服务器上编译 Garnet 的步骤,包括下载源码、安装 .NET8 SDK、设置环境变量、构建和运行。编译成功后,Garnet 会在 3278 端口运行,支持 Redis 客户端连接。文章建议使用境外服务器避免网络问题,并提供了具体命令和操作截图说明。

Repost license

Request authorization before reposting and retain the authorization code, original URL, and go/affiliate links.

Original URL:https://www.geekcorelab.com/post/hand-in-hand-teaching-you-how-to-install-garnet

The commercial link is an authorized go short link that must stay on the reposted page. It records the source before sending readers to the original article.

What is Garnet

Garnet is a Redis client-compatible caching component written in C# by Microsoft. You can connect to Garnet using the same connection method as a Redis client.

However, Garnet requires the .NET8 runtime to run. For convenience, you can consider building it into a Docker image.

Bare-metal deployment

First, it is recommended to use an overseas server for building to avoid the domestic network environment affecting the installation process. This tutorial uses a 雨云 server and Ubuntu 22.04 provided by 雨云 with no preinstalled apps. If you encounter any problems during installation, you can try a 1 元 one-day trial machine from 雨云; one day is enough to compile Garnet. Because the process involves compilation, here we directly try a machine with 8 cores and 16G memory.


First, you need to download the Garnet source code.

git clone https://github.com/microsoft/garnet.git

After that, you need to install a .NET8 SDK1

First, we download the installation script provided by Microsoft and grant it execute permission.

wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh

Run the script to install the .NET8 SDK.

./dotnet-install.sh --channel 8.0


Wait a moment until the following appears:

Installation finished successfully.

That means the installation was successful. Next, you need to set an environment variable.

export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

After that, run the build command to start building.

cd garnet
dotnet restore
dotnet build -c Release


After a moment, you will see a build success message. These three lines mean:

  • Build succeeded
  • 0 warnings
  • 0 errors

Next, let's try running it.

cd main/GarnetServer
dotnet run -c Release -f net8.0


You can see that there is already a red gem. Try connecting to it. Note that Garnet uses port 3278. Those migrating directly from Redis should pay attention to changing the connection method, but there is no need to change the client; just use the Redis client to connect.

Create a Key:


Success

Comments

Discussion

Be kind and keep the discussion friendly.

Complete your profile details to improve the chance of approval.

Your email will not be shown publicly.

Loading...

Markdown supported.

Discussion

0 comments

Internal link graph

Loading internal links…

View linked articles