Redis4.0.10單機版安裝
阿新 • • 發佈:2018-12-08
1、準備環境:
- 作業系統:CentOS-7.5-x64
- Redis伺服器:192.168.1.23
- Redis管理參考:redis.cn
2、安裝Redis
2.1、安裝編譯環境
[[email protected] ~]# yum install -y gcc-c++ tcl
2.2、下載安裝包
[[email protected] ~]# cd /usr/local/src
[[email protected] ~]# wget http://download.redis.io/releases/redis-4.0.10.tar.gz
2.3、安裝Redis
[[email protected] ~]# cd /usr/local/src
[[email protected] ~]# tar zxf redis-4.0.10.tar.gz
[[email protected] ~]# cd redis-4.0.10
[[email protected] ~]# make
[[email protected] ~]# make install
2.4、配置redis.conf
主要修改四個引數:“bind”、“port”、“logfile”、“dir”,其他引數預設即可。
“bind”繫結服務端IP地址,使用者客戶端訪問;
“port”繫結服務端開放埠,結合IP地址,用於客戶端訪問;
“logfile”日誌路徑;
“dir”快取資料路徑。
[[email protected] ~]# mkdir -p /data/redis-6379 [[email protected] ~]# cd /data/redis-6379 [[email protected] ~]# redis_6379.conf bind 127.0.0.1 192.168.1.23 port 6379 logfile "/data/redis-6379/redis-6379.log" dir /data/redis-6379/DB-6379/
2.5、配置redis.service
[[email protected] ~]# vim /etc/systemd/system/redis-6379.service
[Unit]
Description=Redis
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/bin/redis-server /data/redis-6379/redis_6379.conf
ExecStop=/usr/local/bin/redis-cli -h 192.168.1.23 -p 6379 shutdown
[Install]
WantedBy=multi-user.target
2.5、配置開機啟動
[[email protected] ~]# systemctl enable redis-6379.service
2.6、啟動Redis
[[email protected] ~]# systemctl start redis-6379.service
[[email protected] ~]# systemctl status redis-6379.service
● redis-6379.service - Redis
Loaded: loaded (/etc/systemd/system/redis-6379.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2018-09-18 22:06:08 CST; 29min ago
Main PID: 4941 (redis-server)
CGroup: /system.slice/redis-6379.service
└─4941 /usr/local/bin/redis-server 127.0.0.1:6379
9月 18 22:06:08 redis.dev systemd[1]: Starting Redis...
9月 18 22:06:08 redis.dev systemd[1]: PID file /var/run/redis_6379.pid not readable (yet?) after start.
9月 18 22:06:08 redis.dev systemd[1]: Started Redis.
2.7、測試Redis
[[email protected] ~]# redis-cli -h 192.168.1.23 -p 6379
192.168.1.23:6379> set ko "ok"
OK
192.168.1.23:6379> get ko
"ok"
192.168.1.23:6379> exit
[[email protected] ~]#