先将安装包拖入/opt目录
注意:这里的脚本bind修改后为 0.0.0.0
bind修改后为bind 127.0.0.1 +服务器ip在下面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#!/bin/bash
#yum源
echo -e "\033[31m =====正在验证当前为仅主机还是nat模式===== \033[0m"
ping -c1 -w1 www.baidu.com &> /dev/null
if [ $? - eq 0 ]; then echo -e "\033[31m 检测当前为nat模式,为您配置在线yum源 \033[0m"
mkdir -p /etc/yum .repos.d /repo .bak
mv -f /etc/yum .repos.d/* /etc/yum .repos.d /repo .bak &> /dev/null
wget -o /etc/yum .repos.d /centos-base .repo https: //mirrors .aliyun.com /repo/centos-7 .repo &> /dev/null
yum clean all &> /dev/null
yum list &> /dev/null
echo -e "\033[31m 在线源已配置完成 \033[0m"
else
echo -e "\033[31m 检测当前为仅主机模式,为您配置本地yum源 \033[0m"
mount /dev/sr0 /mnt &> /dev/null
cd /etc/yum .repos.d/
mkdir -p /etc/yum .repos.d /repo .bak
mv -f /etc/yum .repos.d/* /etc/yum .repos.d /repo .bak &> /dev/null
echo '[ local ]
name= local
baseurl= file : ///mnt
enabled=1
gpgcheck=0' > /etc/yum .repos.d /local .repo
yum clean all &> /dev/null
yum makecache &> /dev/null
df -h | grep "/mnt"
if [ $? - ne 0 ]; then
echo -e "\033[31m 检测当前为仅主机模式,但光盘未连接! \033[0m"
else
echo -e "\033[31m 本地yum源已配置完成 \033[0m"
fi
fi
#关闭防火墙
systemctl stop firewalld
setenforce 0
yum install -y gcc gcc-c++ make
rpm -q expect
rpm -q tcl
yum -y install expect
cd /opt
tar zxvf redis-5.0.7. tar .gz -c /opt/
cd /opt/redis-5 .0.7/
make
make prefix= /usr/local/redis install
#由于redis源码包中直接提供了makefile 文件,所以在解压完软件包后,不用先执行./configure进行配置,可直接执行make与make install 命令进行安装。
#在/utils里执行软件包提供的install_server.sh脚本文件设置redis服务所需要的相关配置文件
cd /opt/redis-5 .0.7 /utils
#开始免交换执行
/usr/bin/expect <<eof
#expect开始标志
spawn . /install_server .sh
#please select the redis port for this instance: [6379]
expect "instance"
send "\r"
#please select the redis config file name [/etc/redis/6379.conf]
expect "config"
send "\r"
#please select the redis log file name [/var/log/redis_6379.log]
expect "log"
send "\r"
#please select the data directory for this instance [/var/lib/redis/6379]
expect "data"
send "\r"
#please select the redis executable path []
expect "executable"
send "/usr/local/redis/bin/redis-server\r"
#is this ok? then press enter to go on or ctrl-c to abort.
expect "abort"
send "\r"
expect eof
eof
ln -s /usr/local/redis/bin/ * /usr/local/bin/
netstat -natp | grep redis
/etc/init .d /redis_6379 restart
/etc/init .d /redis_6379 status
sed -i '/bind 127.0.0.1/c bind 0.0.0.0' /etc/redis/6379 .conf
sed -i 's/appendonly no/appendonly yes/' /etc/redis/6379 .conf
/etc/init .d /redis_6379 restart
/etc/init .d /redis_6379 status
|
bind修改后为bind 127.0.0.1 +服务器ip脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/bin/bash
#yum源
echo -e "\033[31m =====正在验证当前为仅主机还是nat模式===== \033[0m"
ping -c1 -w1 www.baidu.com &> /dev/null
if [ $? - eq 0 ]; then echo -e "\033[31m 检测当前为nat模式,为您配置在线yum源 \033[0m"
mkdir -p /etc/yum .repos.d /repo .bak
mv -f /etc/yum .repos.d/* /etc/yum .repos.d /repo .bak &> /dev/null
wget -o /etc/yum .repos.d /centos-base .repo https: //mirrors .aliyun.com /repo/centos-7 .repo &> /dev/null
yum clean all &> /dev/null
yum list &> /dev/null
echo -e "\033[31m 在线源已配置完成 \033[0m"
else
echo -e "\033[31m 检测当前为仅主机模式,为您配置本地yum源 \033[0m"
mount /dev/sr0 /mnt &> /dev/null
cd /etc/yum .repos.d/
mkdir -p /etc/yum .repos.d /repo .bak
mv -f /etc/yum .repos.d/* /etc/yum .repos.d /repo .bak &> /dev/null
echo '[ local ]
name= local
baseurl= file : ///mnt
enabled=1
gpgcheck=0' > /etc/yum .repos.d /local .repo
yum clean all &> /dev/null
yum makecache &> /dev/null
df -h | grep "/mnt"
if [ $? - ne 0 ]; then
echo -e "\033[31m 检测当前为仅主机模式,但光盘未连接! \033[0m"
else
echo -e "\033[31m 本地yum源已配置完成 \033[0m"
fi
fi
#防火墙关闭
systemctl stop firewalld
setenforce 0
yum install -y gcc gcc-c++ make
rpm -q expect
rpm -q tcl
yum -y install expect
cd /opt
tar zxvf redis-5.0.7. tar .gz -c /opt/
cd /opt/redis-5 .0.7/
make
make prefix= /usr/local/redis install
#由于redis源码包中直接提供了makefile 文件,所以在解压完软件包后,不用先执行./configure进行配置,可直接执行make与make install 命令进行安装。
#在/utils里执行软件包提供的install_server.sh脚本文件设置redis服务所需要的相关配置文件
cd /opt/redis-5 .0.7 /utils
#开始免交换执行
/usr/bin/expect <<eof
#expect开始标志
spawn . /install_server .sh
#please select the redis port for this instance: [6379]
expect "instance"
send "\r"
#please select the redis config file name [/etc/redis/6379.conf]
expect "config"
send "\r"
#please select the redis log file name [/var/log/redis_6379.log]
expect "log"
send "\r"
#please select the data directory for this instance [/var/lib/redis/6379]
expect "data"
send "\r"
#please select the redis executable path []
expect "executable"
send "/usr/local/redis/bin/redis-server\r"
#is this ok? then press enter to go on or ctrl-c to abort.
expect "abort"
send "\r"
expect eof
eof
ln -s /usr/local/redis/bin/ * /usr/local/bin/
netstat -natp | grep redis
/etc/init .d /redis_6379 restart
/etc/init .d /redis_6379 status
xyw=$(ip a | grep "ens33" | awk nr==2 '{print$2}' | awk -f/ '{print$1}' )
sed -i "/bind 127.0.0.1/c bind 127.0.0.1 $xyw" /etc/redis/6379 .conf
sed -i 's/appendonly no/appendonly yes/' /etc/redis/6379 .conf
/etc/init .d /redis_6379 restart
/etc/init .d /redis_6379 status
|
到此这篇关于redis如何一键部署脚本的文章就介绍到这了,更多相关redis 部署脚本内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://blog.csdn.net/IvyXYW/article/details/114083870