將Centos的yum源更換爲國內的163源redis
備份你的原鏡像文件,保證出錯後能夠恢復:vim
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup緩存
下載新的CentOS-Base.repo
到/etc/yum.repos.d/
ui
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/...code
生成緩存server
yum clean all
yum makecache進程
yum install redisip
systemctl start redis.serviceget
systemctl enable redis.servicerequire
vim /etc/redis.conf
//開啓守護進程
將daemonize yes 改成daemonize yes
//將運行的ip設置爲全部
將bind 127.0.0.1 改成bind 0.0.0.0
//運行公網訪問redis
將protected-mode yes 改成protected-mode yes
注: 可使用?直接進行搜索關鍵字
打開文件/etc/redis.conf
,找到其中的# requirepass foobared
,去掉前面的#
,並把foobared
改爲你的密碼。
redis.conf
文件默認在/etc
目錄下,你能夠更改它的位置和名字,更改後,注意在文件/usr/lib/systemd/system/redis.service
中,把ExecStart=/usr/bin/redis-server /etc/redis/6379.conf --daemonize no
中的redis.conf
的路徑改爲的新的路徑。