1.配置hosts文件
[root@MYSQL8 ~]# cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
HOSTNAME=MYSQL8
[root@MYSQL8 ~]# hostname
MYSQL8.COM
[root@MYSQL8 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.40.8 MYSQL8 MYSQL8.COM
2.下载
[root@MYSQL8 ~]# cd /usr/local/src/
[root@MYSQL8 src]# pwd
/usr/local/src
[root@MYSQL8 src]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
3.解压缩
[root@MYSQL8 src]# tar -zxvf redis-5.0.7.tar.gz
4.建立redis目录的软连接
[root@MYSQL8 src]# ln -s redis-5.0.7 redis
[root@MYSQL8 src]# ls
redis redis-5.0.7 redis-5.0.7.tar.gz
5.进入redis目录
[root@MYSQL8 src]# cd redis
[root@MYSQL8 redis]# pwd
/usr/local/src/redis
6.安装
#确保已安装gcc
[root@MYSQL8 src]# make
[root@MYSQL8 src]# make install
7.查看redis的版本
[root@MYSQL8 usr]# cd /
[root@MYSQL8 /]# redis-cli -v
redis-cli 5.0.7
8.查看安装后所存放执行文件的目录
[root@MYSQL8 /]# cd /usr/local/bin
[root@MYSQL8 bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
- 修改系统参数
[root@MYSQL8 /]# vim /etc/sysctl.conf
#增加如下配置
vm.overcommit_memory = 1
net.core.somaxconn = 1024
[root@MYSQL8 /]# sysctl -p
[root@MYSQL8~]# vim /etc/rc.d/rc.local
增加下列内容:
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
保存退出,然后赋予rc.local文件执行权限:
[root@MYSQL8~]# chmod +x /etc/rc.d/rc.local
[root@MYSQL8 ~]# source /etc/rc.d/rc.local
最后重启系统,以后再检查THP应该就是被禁用了
[root@MYSQL8~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[root@MYSQL8~]# cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
- 启动redis(非推荐)
[root@MYSQL8 ~]# redis-server
1196:C 07 Feb 2020 16:50:32.966 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1196:C 07 Feb 2020 16:50:32.966 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1196, just started
1196:C 07 Feb 2020 16:50:32.966 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1196:M 07 Feb 2020 16:50:32.967 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1196
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
1196:M 07 Feb 2020 16:50:32.967 # Server initialized
1196:M 07 Feb 2020 16:50:32.967 * DB loaded from disk: 0.000 seconds
1196:M 07 Feb 2020 16:50:32.967 * Ready to accept connections
11.启动redis(通过配置文件)
[root@MYSQL8 /]# redis-server /usr/local/src/redis/redis.conf
1222:C 07 Feb 2020 16:58:28.007 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1222:C 07 Feb 2020 16:58:28.007 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1222, just started
1222:C 07 Feb 2020 16:58:28.007 # Configuration loaded
1222:M 07 Feb 2020 16:58:28.007 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 1222
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
1222:M 07 Feb 2020 16:58:28.008 # Server initialized
1222:M 07 Feb 2020 16:58:28.008 * DB loaded from disk: 0.000 seconds
1222:M 07 Feb 2020 16:58:28.008 * Ready to accept connections
- redis 命令行客户端连接
[root@MYSQL8 ~]# redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> set key1 xag
OK
127.0.0.1:6379> get key1
"xag"
13.启动redis(通过配置文件&以守护进程方式启动)
# 将 daemonize 改成 yes
[root@MYSQL8 redis]# sed -n -e '/daemonize/p' /usr/local/src/redis/redis.conf
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
# output for logging but daemonize, logs will be sent to /dev/null
[root@MYSQL8 /]# redis-server /usr/local/src/redis/redis.conf
1271:C 07 Feb 2020 17:13:13.693 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1271:C 07 Feb 2020 17:13:13.693 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1271, just started
1271:C 07 Feb 2020 17:13:13.693 # Configuration loaded
[root@MYSQL8 /]# redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> get key1
"xag"
- 停redis
[root@MYSQL8 redis]# redis-cli -h 127.0.0.1 -p 6379 shutdown