centos中redis的安装配置和使用

1.所需的软件:VMware14、centos7
2.安装步骤:
2.1准备工作:关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示 running)
2.2配置编译环境
sudo yum install gcc-c++
2.3虚拟集中centos7网络配置
进入 /etc/sysconfig/network-scipts 文件夹下
查看 ifcfg-eno16777736 网卡配置文件
将onboot修改为=yes 重启网络服务(systemctl restart network)问题就解决了!
2.4进入/usr/ocal 下载源码:
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
当提示wget: command not found时,可运行yum -y install wget 这个命令来先安装wget
2.5解压源码
tar -zxvf redis-3.2.8.tar.gz
2.6进入到解压目录
cd redis-3.2.8
2.7执行make编译redis
make MALLOC=libc
注意:make命令执行完成编译后,会在src目录下生成6个可执行文件,分别是redis-server、redis-cli、redis-benchmark、redis-check-aof、redis-check-rdb、redis-sentinel。
2.8在src目录下安装Redis:
cd src && make install
当执行这个命令时提示先make test ,当执行make test命令时提示
You need tcl 8.5 or newer in order to run the Redis test
这时候我们得安装tcl,执行wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
当tcl安装成功后,我们再执行make test 这时候就能成功的安装redis了
2.9在redis-3.2.8目录下配置Redis能随系统启动:
./utils/install_server.sh
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service…
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server…
Installation successful!
3.0redis服务查看、开启和关闭
3.01查看redis进程
ps -aux|grep redis
3.02开启Redis服务操作
/etc/init.d/redis_6379 start
#或
service redis_6379 start
3.03关闭Redis服务操作
/etc/init.d/redis_6379 stop
#或
service redis_6379 stop

3.1测试下,直接运行
#连接redis
redis-cli
#然后测试
set name aaa
get name

在这里插入代码片


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章