Linux环境下安装redis
一、准备工作
- 下载
redis
安装包, 放到root
目录里面下载地址 - 在 /usr/local/ 下创建 redis ?件夹并进?
cd /usr/local/ mkdir redis cd redis
- 将
redis
安装包解压到/usr/local/redis
tar -zxvf /root/redis-6.2.5.tar.gz -C ./
解压完之后,/usr/local/redis
?录中会出现?个redis-6.2.5
的?录
- 编译并安装
cd redis-6.2.5 make && make install
- 进?
utils
?录,并执?下面命令
cd utils/ ./install_server.sh
这步可能会报错
Welcome to the redis service installer This script will help you easily set up a running redis serverThis 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!
注释下面的代码vim install_server.sh
76行 #bail if this system is managed by systemd #_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
- 查看redis服务启动情况
systemctl status redis_6379.service
看状态是不是Active: active (running)
, 如果状态是Active: active (exited)
● redis_6379.service - LSB: start and stop redis_6379 Loaded: loaded (/etc/rc.d/init.d/redis_6379; bad; vendor preset: disabled) Active: active (exited) since 二 2021-09-14 16:46:05 CST; 8min ago Docs: man:systemd-sysv-generator(8) Process: 8528 ExecStart=/etc/rc.d/init.d/redis_6379 start (code=exited, status=0/SUCCESS)9月 14 16:46:05 localhost.localdomain systemd[1]: Starting LSB: start and stop redis_6379... 9月 14 16:46:05 localhost.localdomain redis_6379[8528]: /var/run/redis_6379.pid exists, process is al...ed 9月 14 16:46:05 localhost.localdomain systemd[1]: Started LSB: start and stop redis_6379. Hint: Some lines were ellipsized, use -l to show in full.
Active: active (exited)
状态 删除pid文件
cd /var/run rm redis_6379.pid
Active: active (exited)
状态 删除dump.rdb(内存快照)文件
cd /var/lib/redis/6379 mv dump.rdb dump.rdb_bak
Active: active (exited)
状态
ps -ef |grep redis kill -9 进程id(如果有) systemctl start redis
- 设置允许远程连接, 编辑
redis
配置?件
vim /etc/redis/6379.conf
将bind 127.0.0.1
修改为0.0.0.0
bind 0.0.0.0 systemctl restart redis_6379.service
- 设置访问密码
vim /etc/redis/6379.conf
找到#requirepass foobared
去掉注释,修改foobared为??想要的密码,保存即可。
requirepass admin
【Linux环境下安装redis】保存,重启 Redis 服务即可
systemctl restart redis_6379.service
推荐阅读
- 开学第一天(下)
- 【故障公告】周五下午的一次突发故障
- 人生感悟记#环境仪器宋庆国成长记#072
- 生活随笔|好天气下的意外之喜
- MongoDB,Wondows下免安装版|MongoDB,Wondows下免安装版 (简化版操作)
- 汇讲-勇于突破
- Android中的AES加密-下
- 说的真好
- 六步搭建ES6语法环境
- 放下心中的偶像包袱吧