Linuxは単一のRedis6.2をインストールします


序文

Redis 6.2には、多くの新しいコマンドと改善された機能が含まれていますが、主要な機能は含まれていません。これは主に、Redisをより完全なものにし、多くのユーザーが頻繁にまたは長期的に必要とする問題を解決することです。


ヒント:以下はこの記事の内容です。以下のケースは参照用です。

1. Redisとは何ですか?

Redisは現在最も人気のあるNoSQLデータベースの1つです。RedisはANSICで記述されたオープンソースであり、さまざまなデータ構造を含み、ネットワーク、メモリベース、およびオプションの永続性キーと値のペアのストレージデータベースをサポートします。次の特徴があります。 :

メモリ操作、高性能、
サポート分散、理論的に無制限の
キー値ストレージシステムの拡張
ANSI C言語で記述されたオープンソース、BSDプロトコルに準拠、サポートネットワーク、ログベース、メモリに基づくことができるキー値データベース永続化でき
複数の言語でAPI提供します。他のデータベースタイプと比較して、Redisには次の特徴があります。

C / S通信モデル
シングルプロセスシングルスレッドモデル
豊富なデータ型
操作の原子性
持続性
高い同時読み取りおよび書き込み
サポートLuaスクリプト

次に、最初のインストール手順

1.インストール

インストール手順は次のとおりです。

cd /usr/local/
wget https://download.redis.io/releases/redis-6.2.1.tar.gz
tar xzf redis-6.2.1.tar.gz
cd redis-6.2.1
make

注:上記の実行が失敗した場合!次に、次の文を実行します。make
はC言語で記述されているため、失敗することに注意してください。

yum install gcc
make dist clean
make

実行可能ファイルの表示には実行可能ファイルがあります

cd src

c
グローバルをインストールする:コマンドを使用して、いつでもどこでもredisを開始します

cd /opt/
mkdir myredis
cd myredis/
mkdir redis6
# /opt/myredis/redis6  这个是我安装的目录
# 回到原来的redis目录
cd /usr/local/redis-6.2.1
make install PREFIX=/opt/myredis/redis6
vi /etc/profile
export REDIS_HOME=/opt/myredis/redis6
export PATH=$PATH:$REDIS_HOME/bin
source /etc/profile

したがって、startコマンドを使用できます!

service redis start
service redis stop

2. Install_server.shを使用します(複数回実行できます)2番目のインストール方法

物理マシンには複数のredisインスタンスプロセスがあり、実行可能プログラムはポートの区別によってディレクトリにありますが、メモリ内の将来の複数のインスタンスには、独自の構成ファイル、永続ディレクトリ、およびその他のリソースが必要です。
cd utils

スクリプトinstall_server.shを実行すると、次のエラーが報告される場合があります。

This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!

install_server.shを開き、以下をコメントアウトします。

vi install_server.sh
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
#	echo "This systems seems to use systemd."
#	echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
#	exit 1
#fi
#unset _pid_1_exe

次の準備

mkdir -p /etc/redis/6379
mkdir -p /etc/redis/6378
mkdir -p /etc/redis/6377

[root@localhost utils]# ./install_server.sh 
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 6379
Please select the redis config file name [/etc/redis/6379.conf] /etc/redis/6379/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] /etc/redis/6379/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] /etc/redis/6379/
Please select the redis executable path [/opt/myredis/redis6/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /etc�/redis/6379/6379.conf
Log file       : /etc/redis/6379/redis_6379.log
Data dir       : /etc/redis/6379/
Executable     : /opt/myredis/redis6/bin/redis-server
Cli Executable : /opt/myredis/redis6/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.

スクリプトの実行後、Redisはデフォルトで開始されます。

コマンド

service redis_6379 start
service redis_6379 stop
service redis_6379 status

Redis.confの構成/etc/redis/6379/6379.confの構成を
見てみましょう。

开启守护进程模式
daemonize yes

デーモン設定のyesまたはnoの違い:

はい:デーモンプロセスモードを開くことを意味します。redisはバックグラウンドで実行され、redis.confオプションpidfileで設定されたファイルにプロセスpid番号を書き込みます。
いいえ:スタートアップはredisコマンドラインインターフェイスに入り、接続ツール(putty、xshellなど)を終了または閉じると、redisプロセスが終了します。bind ipを削除し、次の行をコメントアウトします。そうしないと、リモート接続を使用できず、redisへのローカル接続のみが使用できます。

バインド127.0.0.1

关闭保护模式,将protected-mode的yes改为no,也是开启远程连接。
protected-mode no

クライアントを実行する

[root@localhost run]# redis-cli -p 6379
127.0.0.1:6379> set name qjc
OK
127.0.0.1:6379> get name
"qjc"
127.0.0.1:6379> 

おすすめ

転載: blog.csdn.net/qq_42731358/article/details/115316933