页面“Redis5 cluster”与“Centos7自启动rc.local中的脚本不执行”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
 
 
第1行: 第1行:
=节点信息=
+
=原因解析=
 
<pre>
 
<pre>
角色                        主机名                                                            IP1              IP2     
+
在centos7,使用ls -l /etc/rc.loacl可以看到如下结果
 +
lrwxrwxrwx. 1 root root 13 7月  31 22:02 /etc/rc.local -> rc.d/rc.local
  
7000  7001              01                  192.168.10.211   
+
可以看到上面的执行结果是显示有执行权限的,
7002  7003              02                  192.168.10.212     
+
但是当使用ls -l /etc/rc.d/rc.loacl的时候却可以看到如下结果
7004  7005              03                  192.168.10.213     
+
-rw-r--r--. 1 root root 730 Sep 27 05:38 /etc/rc.d/rc.local
</pre>
+
/etc/rc.loacl所链接的文件是没有执行权限的,
 +
所以在启动的时候rc.local中写的命令得不到执行,
 +
因此需要手动添加执行权限给/etc/rc.d/rc.loacl</pre>
  
姐妹篇 [[Redis4 cluster]]
 
  
=防火墙设置=
+
=解决办法=
 
<pre>
 
<pre>
第一台:
+
Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
firewall-cmd --permanent --add-port=7000/tcp
+
# that this script will be executed during boot.
firewall-cmd --permanent --add-port=17000/tcp
+
打开 就有提示哦  请用心看 哈哈
firewall-cmd --permanent --add-port=7001/tcp
 
firewall-cmd --permanent --add-port=17001/tcp
 
firewall-cmd --reload
 
firewall-cmd --list-all-zones
 
第二台:
 
firewall-cmd --permanent --add-port=7002/tcp
 
firewall-cmd --permanent --add-port=17002/tcp
 
firewall-cmd --permanent --add-port=7003/tcp
 
firewall-cmd --permanent --add-port=17003/tcp
 
firewall-cmd --reload
 
firewall-cmd --list-all-zones
 
第三台:
 
firewall-cmd --permanent --add-port=7004/tcp
 
firewall-cmd --permanent --add-port=17004/tcp
 
firewall-cmd --permanent --add-port=7005/tcp
 
firewall-cmd --permanent --add-port=17005/tcp
 
firewall-cmd --reload
 
firewall-cmd --list-all-zones
 
</pre>
 
 
 
=系统参数设置=
 
<pre>#vi /etc/sysctl.conf
 
echo 'vm.overcommit_memory = 1
 
net.core.somaxconn = 1024' >>/etc/sysctl.conf
 
  
/sbin/sysctl -p /etc/sysctl.conf
+
chmod +x /etc/rc.d/rc.local</pre>
</pre>
 
  
=redis 5 安装=
+
=关于在rc.local文件中指定用户执行脚本命令=
 
<pre>
 
<pre>
#bash redisins.sh 2>&1 | tee redislog
+
使用su命令即可,命令格式:
  
wget -c http://download.redis.io/releases/redis-5.0.6.tar.gz
+
su - username -c “your-cammand” ,如:
#set var
 
redis_install_dir=/data/apps/redis
 
redis_ver=5.0.6
 
  
THREAD=4
+
注意:指定用户执行的脚本(程序)目录,该用户必须有管理该脚本(程序)目录(文件)的权限。
tar xzf redis-${redis_ver}.tar.gz
 
pushd redis-${redis_ver} > /dev/null
 
  
make  -j ${THREAD}
+
最好将该脚本(程序)目录的所有权给该用户:
  
make PREFIX=${redis_install_dir}
 
make distclean
 
#cd src && make install #这个才行 特别是cluster ? 2019年 8月16日 星期五 23时29分41秒 CST
 
make install  PREFIX=${redis_install_dir} 
 
echo "export PATH=${redis_install_dir}/bin/:$PATH" >> /etc/profile && source /etc/profile
 
  
####**********************下面是老的
 
wget -c http://download.redis.io/releases/redis-5.0.5.tar.gz
 
redis_install_dir=/home/apps/redis
 
redis_ver=5.0.5
 
  
THREAD=4
 
tar xzf redis-${redis_ver}.tar.gz
 
pushd redis-${redis_ver} > /dev/null
 
make  -j ${THREAD}
 
make PREFIX=/home/apps/redis #here
 
make distclean
 
#cd src && make install #这个才行 特别是cluster ? 2019年 8月16日 星期五 23时29分41秒 CST
 
make install  PREFIX=/home/apps/redis  # make install #这个有时没有创建出目录来呀
 
  
#这个我没做 根本没用 哈哈
+
tail  boot.log
#复制rb 或者放到安装的bin目录 然后再加path
+
[  OK  ] Started Network Time Service.
#cp /opt/redis-5.0.0/src/redis-trib.rb /usr/local/bin
+
[FAILED] Failed to start /etc/rc.d/rc.local Compatibility.
 +
See 'systemctl status rc-local.service' for details.
  
echo 'export PATH=/home/apps/redis/bin/:$PATH' >> /etc/profile && source /etc/profile
+
#启动rc-local 服务 on aliyun 不要不小心 不清空了 /etc/rc.d/rc.local
##**********************上面是老的
+
  systemctl enable rc-local.service
NOTE
 
redis5 用redis-cli创建整个redis集群(redis5以前的版本集群是依靠ruby脚本redis-trib.rb实现
 
</pre>
 
 
 
=创建节点 =
 
<pre>
 
#第一台:192.168.10.211 #here
 
redis_install_dir=/data/apps/redis
 
  mkdir -p ${redis_install_dir}
 
cd ${redis_install_dir}
 
mkdir -p redis_cluster
 
cd redis_cluster
 
mkdir data 7000 7001
 
 
 
#cp /root/src/redis-5.0.5/redis.conf ${redis_install_dir}/redis_cluster
 
#cd  /home/apps/redis/redis_cluster
 
#cp redis.conf 7000/redis_7000.conf
 
#mv redis.conf 7001/redis_7001.conf
 
 
 
 
 
#第2台:192.168.10.212
 
redis_install_dir=/data/apps/redis
 
mkdir -p ${redis_install_dir}
 
cd ${redis_install_dir}
 
mkdir -p redis_cluster
 
cd redis_cluster
 
mkdir data 7002 7003
 
 
 
#cp /root/src/redis-5.0.5/redis.conf  .
 
#cp redis.conf 7002/redis_7002.conf
 
#mv redis.conf  7003/redis_7003.conf
 
 
 
 
 
#第3台:192.168.10.213
 
redis_install_dir=/data/apps/redis
 
mkdir -p ${redis_install_dir}
 
cd ${redis_install_dir}
 
mkdir -p redis_cluster
 
cd redis_cluster
 
mkdir data 7004 7005
 
#cp /root/src/redis-5.0.5/redis.conf  .
 
#cp redis.conf 7004/redis_7004.conf
 
#mv redis.conf 7005/redis_7005.conf
 
 
 
 
 
</pre>
 
 
 
=修改配置文件(三台机器6个配置)=
 
<pre>
 
note  日志在系统那  因为我们配置文件没指定 /var/log/redis/
 
  
ls /home/apps/redis/redis_cluster/data/
 
appendonly-7000.aof  dump_7000.rdb  nodes_7000.conf
 
appendonly-7001.aof  dump_7001.rdb  nodes_7001.conf
 
# 生成在这里了  /home/apps/redis/redis_cluster/data/nodes_7000.conf  nodes_7001.conf
 
  
配置建议加上这个  下面这些配置还加上的
 
# appendfsync always
 
appendfsync everysec
 
# appendfsync no
 
  
第一台:
 
pushd /home/apps/redis/redis_cluster
 
mkdir -p /var/log/redis
 
: > 7000/redis_7000.conf
 
#vi 7000/redis_7000.conf
 
#非交互进行
 
echo 'port 7000
 
bind 192.168.10.211 127.0.0.1
 
cluster-enabled yes
 
appendfilename "appendonly-7000.aof"
 
cluster-config-file nodes_7000.conf
 
cluster-node-timeout 15000
 
appendonly yes
 
appendfsync everysec
 
daemonize yes
 
dbfilename dump_7000.rdb
 
dir /data/apps/redis/redis_cluster/data
 
logfile "/var/log/redis/7000.log"
 
protected-mode yes
 
pidfile /var/run/redis_7000.pid'>7000/redis_7000.conf
 
  
 +
Failed to start /etc/rc.d/rc.local Compatibility
  
:>7001/redis_7001.conf
+
#原内容哦 有时改了就不行 要原文件
echo 'port 7001
+
cat /etc/rc.d/rc.local
bind 192.168.10.211 127.0.0.1
+
#!/bin/bash
cluster-enabled yes
+
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
appendfilename "appendonly-7001.aof"
+
#
cluster-config-file nodes_7001.conf
+
# It is highly advisable to create own systemd services or udev rules
cluster-node-timeout 15000
+
# to run scripts during boot instead of using this file.
appendonly yes
+
#
appendfsync everysec
+
# In contrast to previous versions due to parallel execution during boot
daemonize yes
+
# this script will NOT be run after all other services.
dbfilename dump_7001.rdb
+
#
dir /home/apps/redis/redis_cluster/data
+
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
logfile "/var/log/redis/7001.log"
+
# that this script will be executed during boot.
protected-mode yes
 
pidfile /var/run/redis_7001.pid'>7001/redis_7001.conf
 
  
  
第二台
 
pushd /home/apps/redis/redis_cluster
 
mkdir -p /var/log/redis
 
:>7002/redis_7002.conf
 
echo 'port 7002
 
bind 192.168.10.212 127.0.0.1
 
cluster-enabled yes
 
appendfilename "appendonly-7002.aof"
 
cluster-config-file nodes_7002.conf
 
cluster-node-timeout 15000
 
appendonly yes
 
appendfsync everysec
 
daemonize yes
 
dbfilename dump_7002.rdb
 
dir /home/apps/redis/redis_cluster/data
 
logfile "/var/log/redis/7002.log"
 
protected-mode yes
 
pidfile /var/run/redis_7002.pid' >7002/redis_7002.conf
 
  
:>7003/redis_7003.conf
 
echo 'port 7003
 
bind 192.168.10.212 127.0.0.1
 
cluster-enabled yes
 
appendfilename "appendonly-7003.aof"
 
cluster-config-file nodes_7003.conf
 
cluster-node-timeout 15000
 
appendonly yes
 
appendfsync everysec
 
daemonize yes
 
dbfilename dump_7003.rdb
 
dir /home/apps/redis/redis_cluster/data
 
logfile "/var/log/redis/7003.log"
 
protected-mode yes
 
pidfile /var/run/redis_7003.pid'>7003/redis_7003.conf
 
  
  
第3台
 
pushd /home/apps/redis/redis_cluster
 
mkdir -p /var/log/redis
 
:>7004/redis_7004.conf
 
echo 'port 7004
 
bind 192.168.10.213 127.0.0.1
 
cluster-enabled yes
 
appendfilename "appendonly-7004.aof"
 
cluster-config-file nodes_7004.conf
 
cluster-node-timeout 15000
 
appendonly yes
 
appendfsync everysec
 
daemonize yes
 
dbfilename dump_7004.rdb
 
dir /home/apps/redis/redis_cluster/data
 
logfile "/var/log/redis/7004.log"
 
protected-mode yes
 
pidfile /var/run/redis_7004.pid ' > 7004/redis_7004.conf
 
  
:>7005/redis_7005.conf
 
echo 'port 7005
 
bind 192.168.10.213 127.0.0.1
 
cluster-enabled yes
 
appendfilename "appendonly-7005.aof"
 
cluster-config-file nodes_7005.conf
 
cluster-node-timeout 15000
 
appendonly yes
 
daemonize yes
 
dbfilename dump_7005.rdb
 
dir /home/apps/redis/redis_cluster/data
 
logfile "/var/log/redis/7005.log"
 
protected-mode yes
 
pidfile /var/run/redis_7005.pid' >7005/redis_7005.conf
 
  
 
</pre>
 
</pre>
  
=启动redis=
+
=see also=
<pre>
+
[http://blog.51cto.com/canonind/1865233 Centos 7关于rc.local脚本命令开机不执行及指定用户启动的解决方法]
#cd /usr/local/redis/etc/redis_cluster #on freebsd
 
第一台: #注意用 "" 不要'' 要替换变量的值
 
mkdir /var/log/redis
 
redis_install_dir=/data/apps/redis
 
echo  "redis_install_dir=/data/apps/redis
 
${redis_install_dir}/bin/redis-server ${redis_install_dir}/redis_cluster/7000/redis_7000.conf
 
${redis_install_dir}/bin/redis-server ${redis_install_dir}/redis_cluster/7001/redis_7001.conf">${redis_install_dir}/redis_cluster/run
 
 
 
chmod +x ${redis_install_dir}/redis_cluster/run && bash ${redis_install_dir}/redis_cluster/run
 
chmod  +x /etc/rc.d/rc.local
 
echo "${redis_install_dir}/redis_cluster/run" > >/etc/rc.d/rc.local #把变量替换为值,不建议用''
 
 
 
第二台
 
mkdir /var/log/redis
 
redis_install_dir=/data/apps/redis
 
echo "${redis_install_dir}/bin/redis-server ${redis_install_dir}/redis_cluster/7002/redis_7002.conf
 
${redis_install_dir}/bin/redis-server ${redis_install_dir}/redis_cluster/7003/redis_7003.conf">${redis_install_dir}/redis_cluster/run
 
 
 
chmod +x ${redis_install_dir}/redis_cluster/run && bash ${redis_install_dir}/redis_cluster/run
 
chmod  +x /etc/rc.d/rc.local
 
echo "${redis_install_dir}/redis_cluster/run" > >/etc/rc.d/rc.local #把变量替换为值
 
 
 
 
 
第三台:
 
mkdir /var/log/redis
 
redis_install_dir=/data/apps/redis
 
echo "${redis_install_dir}/bin/redis-server ${redis_install_dir}/redis_cluster/7004/redis_7004.conf
 
${redis_install_dir}/bin/redis-server ${redis_install_dir}/redis_cluster/7005/redis_7005.conf">${redis_install_dir}/redis_cluster/run
 
 
 
chmod +x ${redis_install_dir}/redis_cluster/run && bash ${redis_install_dir}/redis_cluster/run
 
chmod  +x /etc/rc.d/rc.local
 
echo "${redis_install_dir}/redis_cluster/run"  >>/etc/rc.d/rc.local #把变量替换为值
 
 
 
</pre>
 
 
 
=登陆redis=
 
<pre>
 
/home/apps/redis/bin/redis-cli  -c -h  192.168.10.211 -p 7000
 
redis-cli -h 10.3.10.141 -p 7001
 
 
 
redis-cli -h 10.3.10.142 -p 7002
 
redis-cli -h 10.3.10.142 -p 7003
 
 
 
redis-cli -h 10.3.10.143 -p 7004
 
redis-cli -h 10.3.10.143 -p 7005
 
</pre>
 
=创建集群=
 
<pre>注意:在任意一台上运行 不要在每台机器上都运行,一台就够了
 
#要开通端口  firewalld
 
#在geany 有: 格式可能有点不对 要注意
 
redis-cli --cluster create --cluster-replicas 1 192.168.10.211:7000 192.168.10.211:7001 192.168.10.212:7002 192.168.10.212:7003 192.168.10.213:7004  192.168.10.213:7005
 
#--replicas  1  表示 自动为每一个master节点分配一个slave节点    上面有6个节点,程序会按照一定规则生成 3个master(主)3个slave(从)
 
</pre>
 
==执行详情==
 
<pre>
 
[root@dev-hello-1 redis_cluster]# redis-cli --cluster create --cluster-replicas 1 192.168.10.201:7000 192.168.10.201:7001 192.168.10.202:7002 192.168.10.202:7003 192.168.10.203:7004  192.168.10.203:7005
 
>>> Performing hash slots allocation on 6 nodes...
 
Master[0] -> Slots 0 - 5460
 
Master[1] -> Slots 5461 - 10922
 
Master[2] -> Slots 10923 - 16383
 
Adding replica 192.168.10.202:7003 to 192.168.10.201:7000
 
Adding replica 192.168.10.203:7005 to 192.168.10.202:7002
 
Adding replica 192.168.10.201:7001 to 192.168.10.203:7004
 
M: caf3a2c83f4f34498d9152161d3d62ca499094eb 192.168.10.201:7000
 
  slots:[0-5460] (5461 slots) master
 
S: ecbc0c648ff15c4ff2c176563afa580c7c8b7f3b 192.168.10.201:7001
 
  replicates 3792aae886d957e1a0272bcd198a06798f05c26d
 
M: 9c2f0b7827180d93371b493e8ca59b6eea776b0c 192.168.10.202:7002
 
  slots:[5461-10922] (5462 slots) master
 
S: b66f09b38e321ce3f8ee000b7cb40fe804f3a450 192.168.10.202:7003
 
  replicates caf3a2c83f4f34498d9152161d3d62ca499094eb
 
M: 3792aae886d957e1a0272bcd198a06798f05c26d 192.168.10.203:7004
 
  slots:[10923-16383] (5461 slots) master
 
S: a027592b56eb7477fe039786490318efdda8a0d6 192.168.10.203:7005
 
  replicates 9c2f0b7827180d93371b493e8ca59b6eea776b0c
 
Can I set the above configuration? (type 'yes' to accept): yes
 
>>> Nodes configuration updated
 
>>> Assign a different config epoch to each node
 
>>> Sending CLUSTER MEET messages to join the cluster
 
Waiting for the cluster to join
 
....
 
>>> Performing Cluster Check (using node 192.168.10.201:7000)
 
M: caf3a2c83f4f34498d9152161d3d62ca499094eb 192.168.10.201:7000
 
  slots:[0-5460] (5461 slots) master
 
  1 additional replica(s)
 
S: a027592b56eb7477fe039786490318efdda8a0d6 192.168.10.203:7005
 
  slots: (0 slots) slave
 
  replicates 9c2f0b7827180d93371b493e8ca59b6eea776b0c
 
M: 3792aae886d957e1a0272bcd198a06798f05c26d 192.168.10.203:7004
 
  slots:[10923-16383] (5461 slots) master
 
  1 additional replica(s)
 
M: 9c2f0b7827180d93371b493e8ca59b6eea776b0c 192.168.10.202:7002
 
  slots:[5461-10922] (5462 slots) master
 
  1 additional replica(s)
 
S: ecbc0c648ff15c4ff2c176563afa580c7c8b7f3b 192.168.10.201:7001
 
  slots: (0 slots) slave
 
  replicates 3792aae886d957e1a0272bcd198a06798f05c26d
 
S: b66f09b38e321ce3f8ee000b7cb40fe804f3a450 192.168.10.202:7003
 
  slots: (0 slots) slave
 
  replicates caf3a2c83f4f34498d9152161d3d62ca499094eb
 
[OK] All nodes agree about slots configuration.
 
>>> Check for open slots...
 
>>> Check slots coverage...
 
[OK] All 16384 slots covered.
 
</pre>
 
 
 
=查看redis集群情况=
 
<pre>
 
redis-cli -h 192.168.10.211 -p 7000 cluster nodes
 
 
 
a027592b56eb7477fe039786490318efdda8a0d6 192.168.10.203:7005@17005 slave 9c2f0b7827180d93371b493e8ca59b6eea776b0c 0 1567502665000 6 connected
 
3792aae886d957e1a0272bcd198a06798f05c26d 192.168.10.203:7004@17004 master - 0 1567502666171 5 connected 10923-16383
 
9c2f0b7827180d93371b493e8ca59b6eea776b0c 192.168.10.202:7002@17002 master - 0 1567502664166 3 connected 5461-10922
 
ecbc0c648ff15c4ff2c176563afa580c7c8b7f3b 192.168.10.201:7001@17001 slave 3792aae886d957e1a0272bcd198a06798f05c26d 0 1567502664000 5 connected
 
caf3a2c83f4f34498d9152161d3d62ca499094eb 192.168.10.201:7000@17000 myself,master - 0 1567502663000 1 connected 0-5460
 
b66f09b38e321ce3f8ee000b7cb40fe804f3a450 192.168.10.202:7003@17003 slave caf3a2c83f4f34498d9152161d3d62ca499094eb 0 1567502665169 4 connected
 
 
 
</pre>
 
==cluster 完整性检查==
 
<pre>
 
 
 
redis-trib.rb check 10.3.10.140:7000
 
redis-trib.rb check 10.3.10.140:7001
 
redis-trib.rb check 10.3.10.140:7002
 
redis-trib.rb check 10.3.10.140:7003
 
redis-trib.rb check 10.3.10.140:7004
 
redis-trib.rb check 10.3.10.140:7005
 
 
 
结果如下  16384个槽都分配到了 节点
 
 
 
[OK] All nodes agree about slots configuration.
 
>>> Check for open slots...
 
>>> Check slots coverage...
 
[OK] All 16384 slots covered.
 
</pre>
 
 
 
==测试 ==
 
<pre>
 
 
 
redis-cli -c -h  192.168.10.201 -p 7000
 
 
 
[root@dev-hello-1 redis_cluster]# redis-cli -c -h  192.168.10.201 -p 7000
 
192.168.10.201:7000> set evan 36
 
-> Redirected to slot [14924] located at 192.168.10.203:7004
 
OK
 
192.168.10.203:7004>
 
 
 
[root@dev-hello-2 redis_cluster]# redis-cli -c -h  192.168.10.202 -p 7002
 
192.168.10.202:7002> get evan
 
-> Redirected to slot [14924] located at 192.168.10.203:7004
 
"36"
 
192.168.10.203:7004>
 
 
 
dev-hello-3 redis_cluster]#  redis-cli -c -h  192.168.10.203  -p 7005
 
192.168.10.203:7005> get evan
 
-> Redirected to slot [14924] located at 192.168.10.203:7004
 
"36"
 
192.168.10.203:7004>
 
 
 
测试通过了
 
</pre>
 
 
 
=添加redis集群密码=
 
==方式一:修改所有Redis集群中的redis.conf文件加入==
 
<pre>
 
# NOTE  还是这个办法好  不然可能有些 没加载到配置文件去呢
 
masterauth passwd123
 
requirepass passwd123
 
说明:这种方式需要重新启动各节点
 
</pre>
 
 
 
==方式二:进入各个实例进行设置  就是所有节点:==
 
<pre>
 
redis-cli -c -h 10.3.10.141 -p 7001
 
#好像不能一起执行
 
config set masterauth 36DbRGvv
 
config set requirepass 36DbRGvv
 
auth  36DbRGvv
 
config rewrite
 
 
 
添加redis集群密码 一开始忘记加-c 导致 143 两个都加不上了  redis本身的密码这样就有了
 
 
 
-a 后 再执行命令就再 auth , 而如果是进入后 auth password 要每次 都再验证一下密码 麻烦
 
 
 
</pre>
 
 
 
 
 
=开机自己启动=
 
<pre>
 
vi /apps/redis/redis_cluster/run
 
 
 
/apps/redis/bin/redis-server /home/apps/redis/redis_cluster/7004/redis_7004.conf
 
/apps/redis/bin/redis-server /home/apps/redis/redis_cluster/7005/redis_7005.conf
 
 
 
chmod  +x  /apps/redis/redis_cluster/run
 
chmod +x /etc/rc.d/rc.local
 
 
 
vi  /etc/rc.d/rc.local
 
/apps/redis/redis_cluster/run
 
 
 
 
 
</pre>
 
=开启关闭=
 
<pre>
 
redis-cli -a xxx -c -h 192.168.0.60 -p 8001 shutdown  #集群cluster_state变成了fail状态?
 
 
 
 
 
 
 
</pre>
 
 
 
=troubleshooting=
 
<pre>
 
ISCONF Errors writing to the AOF file: No space left on device; nested exception is redis.clients.jedis.exceptions.JedisDataException: MISCONF Errors writing to the AOF file: No space left on device
 
 
 
org.springframework.dao.InvalidDataAccessApiUsageException: MISCONF Errors writing to the AOF file: No space left on device; nested exception is redis.clients.jedis.exceptions.JedisDataException: MISCONF Errors writing to the AOF file: No space left on device
 
 
 
原因 有一个台redis的机器 空间100%
 
 
 
 
 
 
 
tail  boot.log
 
[  OK  ] Started Network Time Service.
 
[FAILED] Failed to start /etc/rc.d/rc.local Compatibility.
 
See 'systemctl status rc-local.service' for details.
 
 
 
#启动rc-local 服务  on aliyun 不要不小心 不清空了  /etc/rc.d/rc.local
 
systemctl enable  rc-local.service
 
</pre>
 
  
=see also=
 
[https://blog.51cto.com/kerry/2316700 redis-5.0 cluster带认证及客户端连接]
 
  
[https://www.jianshu.com/p/8045b92fafb2 Redis 5 之后版本的高可用集群搭建]
+
[[category:ops]]
[[category:ops]] [[category:redis]]
 

2019年11月13日 (三) 06:08的最新版本

原因解析

在centos7,使用ls -l /etc/rc.loacl可以看到如下结果
lrwxrwxrwx. 1 root root 13 7月  31 22:02 /etc/rc.local -> rc.d/rc.local

可以看到上面的执行结果是显示有执行权限的,
但是当使用ls -l /etc/rc.d/rc.loacl的时候却可以看到如下结果
-rw-r--r--. 1 root root 730 Sep 27 05:38 /etc/rc.d/rc.local
/etc/rc.loacl所链接的文件是没有执行权限的,
所以在启动的时候rc.local中写的命令得不到执行,
因此需要手动添加执行权限给/etc/rc.d/rc.loacl


解决办法

Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
打开 就有提示哦  请用心看 哈哈 

chmod +x /etc/rc.d/rc.local

关于在rc.local文件中指定用户执行脚本命令

使用su命令即可,命令格式:

su - username -c “your-cammand” ,如:

注意:指定用户执行的脚本(程序)目录,该用户必须有管理该脚本(程序)目录(文件)的权限。

最好将该脚本(程序)目录的所有权给该用户:




tail  boot.log
[  OK  ] Started Network Time Service.
[FAILED] Failed to start /etc/rc.d/rc.local Compatibility.
See 'systemctl status rc-local.service' for details.

#启动rc-local 服务  on aliyun 不要不小心 不清空了  /etc/rc.d/rc.local
 systemctl enable  rc-local.service




Failed to start /etc/rc.d/rc.local Compatibility

#原内容哦 有时改了就不行 要原文件 
cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.







see also

Centos 7关于rc.local脚本命令开机不执行及指定用户启动的解决方法