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

在這裏插入代碼片


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