GNU/Linux >> Linux の 問題 >  >> Fedora

Fedora34にRedis6をインストールして設定する方法

このチュートリアルでは、Fedora34にRedis6をインストールする方法を学習します。

関連コンテンツ

  • FreeBSD13にRedis6をインストールして設定する方法
  • OpenSUSELeap15.3にRedis6をインストールして設定する方法
  • DockerとDockerでRedis6を実行する方法-作成
  • Fedora34にPostgres14をインストールして設定する方法
  • 新しいFedora34デスクトップインストールで行うこと

前提条件

フォローするには、次のことを確認してください。

  • 更新されたFedora34サーバー
  • インターネットへのアクセス
  • サーバーまたはsudoアクセス権を持つユーザーへのrootアクセス

目次

  1. Fedora34サーバーを更新する
  2. Redisのインストール
  3. Redisの設定
  4. Redisでの接続と基本操作の実行
  5. Redisベンチマークの実行

1。 Fedora34サーバーを更新する

続行する前に、次のコマンドを使用してサーバーが更新されていることを確認してください。

 sudo dnf -y update 

後で使用するので、このコマンドを使用してvimがインストールされていることも確認しましょう:

 sudo dnf install -y vim 

2。 redisのインストール

Redisは、デフォルトのFedora34リポジトリーで使用できます。インストールするには、次のコマンドを使用します:

 sudo dnf install redis 

次のコマンドを使用して、インストールされているredisパッケージを確認します。

 # rpm -qi redis
Name        : redis
Version     : 6.2.6
Release     : 1.fc34
Architecture: x86_64
Install Date: Thu 28 Oct 2021 07:22:18 PM UTC
Group       : Unspecified
Size        : 4939623
License     : BSD and MIT
Signature   : RSA/SHA256, Mon 04 Oct 2021 02:11:42 PM UTC, Key ID 1161ae6945719a39
Source RPM  : redis-6.2.6-1.fc34.src.rpm
Build Date  : Mon 04 Oct 2021 02:04:48 PM UTC
Build Host  : buildvm-x86-25.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://redis.io
Bug URL     : https://bugz.fedoraproject.org/redis
Summary     : A persistent key-value database
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. 

サービスがインストールされたので、次のコマンドでサービスを開始しましょう:

 sudo systemctl start redis 

起動時に開始するようにサービスを有効にします:

 $ sudo systemctl enable redis
Created symlink /etc/systemd/system/multi-user.target.wants/redis.service → /usr/lib/systemd/system/redis.service. 

サービスの開始後、次のコマンドを使用してサービスのステータスを確認します。

 $ sudo systemctl status redis
● redis.service - Redis persistent key-value database
     Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/redis.service.d
             └─limit.conf
     Active: active (running) since Thu 2021-10-28 19:34:31 UTC; 9s ago
   Main PID: 27610 (redis-server)
     Status: "Ready to accept connections"
      Tasks: 5 (limit: 4603)
     Memory: 2.1M
        CPU: 22ms
     CGroup: /system.slice/redis.service
             └─27610 /usr/bin/redis-server 127.0.0.1:6379

Oct 28 19:34:31 ip-10-2-40-182.us-west-2.compute.internal systemd[1]: Starting Redis persistent key-value database...
Oct 28 19:34:31 ip-10-2-40-182.us-west-2.compute.internal systemd[1]: Started Redis persistent key-value database. 

Active: active (running) サービスが正常に開始されたことを意味します。

3。 Redisの設定

redis構成ファイルはこのパスにあります /etc/redis/redis.conf 。このセクションでは、redis構成ファイルを更新して、リモートアクセスを許可し、認証パスワードを設定し、pidファイルを追加し、 Set Persistent StoreforRecoveryを実行します。

これを使用してredis設定ファイルを編集します:

 sudo vim /etc/redis/redis.conf 

redisインスタンスへのリモートアクセスを許可するには、次の行を使用してredisを0.0.0.0にバインドします。

 bind 0.0.0.0 

redisでパスワードを設定するには、次を使用します:

 requirepass j2GfJuLFR8 

pidファイルをredisに追加するには:

 pidfile /var/run/redis/redis-server.pid 

appendonlyvalueをyesに変更して、リカバリ用の永続ストアを設定します

 appendonly yes
appendfilename "appendonly.aof" 

変更を適用するには、redisサービスを再起動してください:

 sudo systemctl restart redis 

4。 Redisでの接続と基本操作の実行

アクティブなfirewalldサービスがある場合は、ポート6379を許可します

 sudo firewall-cmd --add-port=6379/tcp --permanent
sudo firewall-cmd --reload 

ローカルでredisに接続する:

 $ redis-cli 

認証するには:

 127.0.0.1:6379> auth j2GfJuLFR8
OK 

OKを受け取るはずです 出力で。間違ったパスワードを入力すると、認証は失敗します。

redis情報を確認してください。

 127.0.0.1:6379>情報

これにより、データの長いリストが出力されます。 Sectionを引数として渡すことにより、出力を制限できます。例:

 127.0.0.1:6379> INFO Server#Serverredis_version:6.2.6redis_git_sha1:00000000redis_git_dirty:0redis_build_id:db74a1b227e296feredis_mode:standaloneos:Linux 5.11.12-300.fc34.x86_64 x86_64arch_bits:64multiplexing_api:opp 27781process_supervised:systemdrun_id:9ba7b7785f0905ecc4dc3a6ecda2ffe5beaec53atcp_port:6379server_time_usec:1635451060104781uptime_in_seconds:241uptime_in_days:0hz:10configured_hz:10lru_clock:8061108exe 

5。 Redisベンチマークの実行

15でベンチマークを実行します 並列接続、合計10k ローカルredisに対して、そのパフォーマンスをテストするように要求します。

 $ redis-benchmark -h 127.0.0.1 -p 6379 -n 10000 -c 15 -a j2GfJuLFR8
====== PING_INLINE ======
  10000 requests completed in 0.23 seconds
  15 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 3600 1 300 100 60 10000
  host configuration "appendonly": no
  multi-thread: no

Latency by percentile distribution:
0.000% <= 0.055 milliseconds (cumulative count 2)
50.000% <= 0.127 milliseconds (cumulative count 5509)
75.000% <= 0.159 milliseconds (cumulative count 7514)

..........

99.940% <= 0.503 milliseconds (cumulative count 9994)
100.000% <= 0.607 milliseconds (cumulative count 10000)

Summary:
  throughput summary: 74074.07 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        0.159     0.072     0.151     0.239     0.279     0.567 

その他のオプションと例については、以下を使用してください:

 $ redis-benchmark --help 

結論

Fedora34にRedis6をインストールして構成することができました。


Fedora
  1. UbuntuにRedisサーバーをインストールして構成する方法

  2. Debian11にRedis6をインストールして設定する方法

  3. Debian に Redis をインストールして構成する方法

  1. CentOS8およびFedora33にFail2Banをインストールおよび構成する方法

  2. Debian11にRedis6.0をインストールして設定する方法

  3. Dovecotをインストールして構成する方法

  1. Fedora34にPostgres14をインストールして設定する方法

  2. Fedora35にAnsibleをインストールして設定する方法

  3. Fedora35にMariadbをインストールして設定する方法