In-memory database-4-[redis] offline installation in ubuntu

Ubuntu20.04 (linux) install redis offline

Official website redis download link
insert image description here
Download the installation package redis-6.0.9.tar.gz.

1 download and install

(1)解压
sudo tar -xzvf redis-6.0.9.tar.gz -C /usr/local/
cd /usr/local/redis-6.0.9/

(2)编译
sudo make

(3)测试
sudo dpkg -i libtcl8.6_8.6.10+dfsg-1_amd64.deb
sudo dpkg -i tcl8.6_8.6.10+dfsg-1_amd64.deb
sudo make test【依赖tcl模块】
出现如下内容表示测试通过
\o/ All tests passed without errors!

Cleanup: may take some time... OK
make[1]: Leaving directory '/usr/local/redis-6.0.9/src'

(4)安装
sudo make install     
PREFIX未指定目录,默认安装到/usr/local/bin里面了
该目录下生成几个可执行文件
redis-benchmark   性能测试程序
redis-check-aof
redis-check-rdb
redis-cli     客户端可执行程序
redis-server  服务端可执行程序

2 Modify the configuration file

cd /usr/local/redis-6.0.9
sudo cp redis.conf redis.conf.backup

sudo mkdir /usr/local/redis-6.0.9/data
sudo touch /usr/local/redis-6.0.9/myredis.log

configuration file

#外网可访问
#bind 127.0.0.1
protected-mode no
#以后台进程方式启动
daemonize yes
#修改log存放路径
logfile /usr/local/redis-6.0.9/myredis.log
stop-writes-on-bgsave-error no
#修改AOF及RBD存放路径
dir /usr/local/redis-6.0.9/data
#设置密码
requirepass bigdata

3 Start up automatically

(8) Add redis service to systemctl management
#cd /usr/lib/systemd/system
#sudo vi redis.service

[Unit]
Description=redis.server
After=network.target
[Service]
Type=forking
PIDFILE=/var/run/redis_6379.pid
ExecStart=/usr/local/bin/redis-server /usr/local/redis-6.0.9/redis.conf
ExecRepload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

#sudo chmod a+x redis.service
#sudo systemctl daemon-reload
#sudo systemctl start redis.service
#sudo systemctl enable redis#Set boot self-start

4 Test use

redis-cli
127.0.0.1:6379> set “name” “lucy”
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth bigdata
OK
127.0.0.1:6379> set “name” “lucy”
OK
127.0.0.1:6379> get “name”
“lucy”

Guess you like

Origin blog.csdn.net/qq_20466211/article/details/129199506