1打开redis官网 下载最新的安装包
wget 这个路径
解压当前目录
tar xzvf redis-xxx
进入redis目录
cd redis-xxx
按照对应的依赖make
更新make install
配置redis为后台启动
vim /usr/local/redis.xxx/redis.conf //将daemonize no 改成daemonize yes
5添加开机启动服务
vim /etc/systemd/system/redis-server.service
添加如下内容
[Unit]
Description=Redis Server Manager
After=syslog.target
After=network.target
[Service]
Type=simple
User=redis
Group=redis
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/redis/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
设置为开机启动
systemctl daemon-reload
systemctl start redis-server.service
systemctl enable redis-server.service
创建redis-cli软连接
ln -s /usr/local/redis/redis-cli /usr/bin/redis-cli
7.开启redis
第一种: /安装目录/redis-server /安装目录/redis.conf
8.停止redis
pkill redis
9-检测后台进程是否存在
ps -ef |grep redis
10-检测6379端口是否在监听
netstat -lntp | grep 6379
redis设置密码访问
你的redis在真是环境中不可以谁想访问就可以访问,所以必须要设置密码
设置密码的流程如下:
vim /sort/redis/etc/redis.conf
#requirepass foobared去掉注释,foobared改为自己的密码,我在这里改为
requirepass 123456
然后保存,重启服务
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/var/run/redis_6379.pid
ExecStart=/home/redis-5.0.3/redis-server /home/redis-5.0.3/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
ln -s /home/redis-5.0.3/redis-cli /usr/bin/redis
网友评论