虚拟化容器,大数据,DBA,中间件,监控。

Shell Redis单机版本部署

21 12月
作者:admin|分类:脚本编程

Reids编译安装出错


make PREFIX=/usr/local/redis install

[root@mmjredis redis-6.0.1]# make PREFIX=/usr/local/redis install

出现错误如下:

             serverLog(LL_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket);
                                                                                              ^
server.c:5103:19: error: ‘struct redisServer’ has no member named ‘supervised_mode’
         if (server.supervised_mode == SUPERVISED_SYSTEMD) {
                   ^
server.c:5104:24: error: ‘struct redisServer’ has no member named ‘masterhost’
             if (!server.masterhost) {
                        ^
server.c:5117:15: error: ‘struct redisServer’ has no member named ‘maxmemory’
     if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
               ^
server.c:5117:39: error: ‘struct redisServer’ has no member named ‘maxmemory’
     if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
                                       ^
server.c:5118:176: error: ‘struct redisServer’ has no member named ‘maxmemory’
         serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory);
                                                                                                                                                                                ^
server.c: In function ‘hasActiveChildProcess’:
server.c:1476:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
server.c: In function ‘allPersistenceDisabled’:
server.c:1482:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
server.c: In function ‘writeCommandsDeniedByDiskError’:
server.c:3747:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
server.c: In function ‘iAmMaster’:
server.c:4914:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make[1]: *** [server.o] Error 1
make[1]: Leaving directory `/usr/src/redis-6.0.1/src'
make: *** [install] Error 2

 解决办法:

# 查看gcc版本是否在5.3以上,centos7.6默认安装4.8.5
gcc -v
# 升级gcc到5.3及以上,如下:
升级到gcc 9.3:
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。
如果要长期使用gcc 9.3的话:
 
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
这样退出shell重新打开就是新版的gcc了
以下其他版本同理,修改devtoolset版本号即可。

 

 Reids安装脚本


要使用redis安装脚本安装redis先要手动将gcc升级,因为执行scl enable devtoolset-9 bash升级会跳出shell脚本,所以先要手动升级,这一点比较麻烦!
gcc -v
yum install  centos-release-scl  devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils  -y
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
scl enable devtoolset-9 bash



[root@localhost ~]# cat redis_install.sh 
#!/bin/bash
need_packages="wget gcc gcc-c++ tcl"
redis_ver="stable"
redis_install_dir="/usr/local/redis"
yum install $need_packages -y
cd /usr/src/

if [ ! -f redis-${redis_ver}.tar.gz ];then
echo -e "\033[32mDownloading redis please wait................................\033[0m"
wget -c  http://download.redis.io/redis-${redis_ver}.tar.gz
fi


tar xf redis-${redis_ver}.tar.gz
cd redis-${redis_ver}

echo -e "\033[32mStart to install redis please wait.........\033[0m"
make PREFIX=$redis_install_dir install

if [ $? -ne 0 ];then
	echo -e "\033[32mInstall redis-${redis_ver} failed please check!!!\033[0m"
	exit 1
else
	echo -e "\033[32mInstall redis-${redis_ver} succeded.\033[0m"
fi


cat >>/etc/profile<<EOF
export REDIS_HOME=/usr/local/redis
export PATH=$PATH:$REDIS_HOME/bin
EOF
source /etc/profile

\cp redis.conf /usr/local/redis/ 
sed -i "s#^daemonize no#daemonize yes#g"  /usr/local/redis/redis.conf
/usr/local/redis/bin/redis-server  /usr/local/redis/redis.conf

if [ $? -eq 0 ];then
	echo  -e "\033[32mSucceded start redis..........\033[0m"
else
       echo -e "\033[32mFaile start redis please check exit!!!!\033[0m"
fi

echo never > /sys/kernel/mm/transparent_hugepage/enabled

ps -ef | grep redis | grep -v grep


[root@localhost ~]# cat redis_check.sh 
#!/bin/bash
#/bin/bash
echo -e "\033[32m-------------------------------------redis log info---------------------------------\033[0m"
tail -n 20 /usr/local/redis/redis_6379.log

echo -e "\033[32m-------------------------------------redis RDB AOF info------------------------------\033[0m"
echo $(grep  appendonly /usr/local/redis/6379.conf | head -n 1)
echo $(du -sh  /usr/local/redis/6379/*)
echo latest_fork_usec values nu/s:$(/usr/local/redis/bin/redis-cli info | grep latest_fork_usec) 
echo rdbcompression values:$(/usr/local/redis/bin/redis-cli info | grep rdbcompression) 






echo -e "\033[32m-------------------------------------redis repliaction info---------------------------------\033[0m"
 /usr/local/redis/bin/redis-cli info replication
echo -e "\033[32m------------------------------------------------redis replication agrs value --------------------------\033[0m"
echo  repl-disabletcp-nodelay values: $(grep repl-disabletcp-nodelay /usr/local/redis/6379.conf)
echo  repl-timeout values:$(grep repl-timeout /usr/local/redis/6379.conf)

 

 

 

 

浏览387 评论0
返回
目录
返回
首页
Oracle RMAN-全备份 Shell 四剑客sed之 生产环境上,最常用的一套“Sed“技巧