Redis initial installation script

. 1 ! # / Bin / the bash
 2  echo  " the Redis Initialization installation scripts " 
. 3 << the COMMENT
 . 4    NOTE:
 . 5     the AUTHOR: WS, 779 269 823 @ qq.com
 . 6     CREATED: 2019.11 . 06 
. 7     VERSION: 1.0 
. 8     the Redis Version: 4.0 . . 11 
. 9     Release the Linux the CentOS 7.6 . 1810 (Core) 
 10  the COMMENT
 . 11  
12 is  # dependent libraries
 13 is  yum  the install -Y CPP binutils glibc-kernheaders glibc-common glibc-devel gcc make wget    
14 
15 #下载解压
16 cd /opt
17 wget -c http://download.redis.io/releases/redis-4.0.11.tar.gz
18 if [ -f /opt/redis-4.0.11.tar.gz ];then
19     tar zxvf redis-4.0.11.tar.gz
20     mv redis-4.0.11 /usr/local/redis
21     cd /usr/local/Redis
 22 is      the make 
23 is      CD the src /
 24      the make  the install  
25  the else 
26 is      echo  " file does not exist! " 
27      Exit;
 28  Fi 
29  
30  # to configure system parameters
 31 is  echo  512 > / proc / SYS / NET / Core / SOMAXCONN
 32  echo  . 1 > / proc / SYS / VM / overcommit_memory
 33 is  echo Never> / SYS / Kernel / mm / transparent_hugepage / Enabled
 34 is  Sed -i ' / \ # End of File / * Soft nofile 65535 I ' / etc / Security /limits.conf
35 sed -i '/\# End of file/i * hard nofile 65535' /etc/security/limits.conf
36 echo ulimit -SHn 65535 >> /etc/profile
37 source /etc/profile
38 
39 #Redis配置文件
40 sed -e "s/#.*//g" /usr/local/redis/redis.conf | awk '{if (length !=0) print $0}'
41 sed -i '136s/daemonize no/daemonize yes/' /usr/local/redis/redis.conf    
42 sed -i '69s/127.0.0.1/0.0.0.0/' /usr/local/redis/redis.conf 
43 sed -i '88s/protected-mode yes/protected-mode no/' /usr/local/redis/redis.conf
44 sed -i 's/^appendonly yes/appendonly no/' /usr/local/redis/redis.conf  
45 sed -i 's/^dbfilename dump.rdb/dbfilename dump.rdb/' /usr/local/redis/redis.conf 
46 sed -i 's/^dir .\//dir \/backup/' /usr/local/redis/redis.conf 
47 echo logfile /var/log/redis.log >> /usr/local/redis/redis.conf
48 mkdir -p /etc/redis
49 ln -s /usr/local/redis/redis.conf /etc/redis/6379.conf   
50 ln -s /usr/local/redis/utils/redis_init_script /etc/init.d/redisd    
51 /sbin/chkconfig redisd on
52 
53 #(开启redis服务,服务名为:redisd)
54 systemctl start redisd   
55 
56 #redis-cli  
57 netstat -ntpl|grep redis
58 echo "Redis deployment is complete! " 
59  echo  "  " 
60  echo  " If the system is checking the firewall Centos 7 after installation, the following command to execute the release of the external communication redis. " 
61 is  echo  " Firewall-cmd = --zone public --add-Port = 6379 / TCP --permanent "     
62 is  echo  " Firewall-cmd --reload " 
63 is  echo  " Firewall-cmd = --zone public --query- = 6379 Port / TCP " 
64  
65  systemctl STOP redisd
 66 systemctl Start redisd

 

Guess you like

Origin www.cnblogs.com/dblock/p/11808661.html