redis cluster

tar -zxvf redis-4.0.2.tar.gz
cd redis-4.0.2
make && make installhtml

vi redis.conf
修改 daemonize yesnode

cd /usr/local/
mkdir redis_cluster
mkdir 7000 7001 7002c++

cp /data/software/redis-4.0.2/redis.conf ./redis_cluster/7000/
//拷貝到7001目錄
cp /data/software/redis-4.0.2/redis.conf ./redis_cluster/7001/
//拷貝到7002目錄
cp /data/software/redis-4.0.2/redis.conf ./redis_cluster/7002/redis

分別修改3個配置文件
daemonize yes //redis後臺運行
pidfile /var/run/redis_7000.pid //pidfile文件對應7000,7002,7003
port 7000 //端口7000,7002,7003
cluster-enabled yes //開啓集羣 把註釋#去掉
cluster-config-file nodes_7000.conf //集羣的配置 配置文件首次啓動自動生成 7000,7001,7002
cluster-node-timeout 5000 //請求超時 設置5秒夠了
appendonly yesspring

啓動6個節點
cd /usr/local
redis-server redis_cluster/7000/redis.conf
redis-server redis_cluster/7001/redis.conf
redis-server redis_cluster/7002/redis.conf
redis-server redis_cluster/7003/redis.conf
redis-server redis_cluster/7004/redis.conf
redis-server redis_cluster/7005/redis.confvim

cd /data/software/redis-4.0.10/src/
建立集羣
yum -y install ruby ruby-devel rubygems rpm-build
gem install redis
(若是不能執行,則wget https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem 而後執行命令gem install -l ./redis-3.2.1.gem)ruby

./redis-trib.rb create --replicas 1 30.12.53.134:7000 30.12.53.134:7001 30.12.53.134:7002 30.12.53.140:7003 30.12.53.140:7004 30.12.53.140:7005服務器

進入redis
redis-cli -c -p 7000
cluster nodes架構

單機啓動
cd bin
./redis-server /data/software/redis-4.0.2/redis.conf
./redis-cliapp

 

 

 

 

 

 

 

 

 

 

 

 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

http://www.cnblogs.com/wangyhua/p/4050563.html
https://blog.csdn.net/w1054993544/article/details/78932614
https://blog.csdn.net/qq_35498405/article/details/78030814

https://www.cnblogs.com/zhangjianbin/p/7228628.html feign 超時

https://www.2cto.com/kf/201803/727053.html fastdfs

https://blog.csdn.net/zw521cx/article/details/80704026 基於fastdfs的高性能大文件,斷點續傳,秒傳,進度條,完整代碼

,SerializerFeature.WriteNullStringAsEmpty,SerializerFeature.WriteDateUseDateFormat,SerializerFeature.WriteNonStringValueAsString


https://www.cnblogs.com/yuxiaona/p/7160648.html redisjiqun lianjie

https://blog.csdn.net/Cs_hnu_scw/article/details/79059965?utm_source=blogxgwz2


1快捷鍵 ctrl shift f9 熱部署 idea debug模式

springcloud 踩坑日誌

2經過zuul 網關上傳文件 會出現中文亂碼,須要在uri網關前面加上zuul


3 feignclient調用 降級 異常日誌處理
@Component
static class ScheduleServiceHystrixClientFallbackFactory implements FallbackFactory<IScheduleServiceFeignClient> {
@Override
public IScheduleServiceFeignClient create(Throwable cause) {
//log不要寫在這裏 不然啓動的時候會報異常信息
return new IScheduleServiceFeignClient() {
@Override
public ServiceResultDTO saveSchedule(OpenScheduleDto openScheduleDto) {
logger.error("IScheduleServiceFeignClient 調用SERVICE-BASE服務失敗{}", cause); //不要寫在匿名內部內以前, 不然啓動的時候會報異常信息,可是不影響啓動
return ServiceResultDTO.build("ex", "調用服務進行待辦推送服務出錯!");

}
}

@EnableFeignClients(basePackages = {"com.qiye.ext.service","com.qiye.base.service"}) 這時候只掃描配置了包下@feigin註解上相關包的接口或類

47 root/qiye2018@# /data/server/business_app/log/

176 root/qiyey@2018 /data/server/business_app/log/

-------------------reids集羣搭建
yum install -y gcc g++ gcc-c++ make

https://www.2cto.com/database/201709/678259.html
http://www.redis.cn/topics/cluster-tutorial.html reids集羣搭建
https://my.oschina.net/gaoenwei/blog/1623214
https://my.oschina.net/gaoenwei/blog/1622588
https://blog.csdn.net/zsg88/article/details/73732845 集羣設置密碼
https://blog.csdn.net/ldy1016/article/details/80998687 須要配置pom文件 集羣設置密碼後 不能使用低版本的data-redis

https://www.cnblogs.com/yjmyzz/p/redis-cluster-turotial.html * 如下是安裝時出現的問題解決方案
https://blog.csdn.net/xiaoguaihu12/article/details/56845473
https://blog.csdn.net/reyleon/article/details/51454334 刪除主節點
https://www.cnblogs.com/zhoujie/p/redis3.html 可參考配置
-------------------reids集羣搭建


1 安裝 Gcc環境 yum install -y gcc g++ gcc-c++ make
解壓redis路徑 /data/software/redis-4.0.10/
集羣配置路徑 /usr/local/myRedis/redis-cluster

cp /data/software/redis-4.0.10/redis.conf /usr/local/myRedis/redis-cluster/7000
cp /data/software/redis-4.0.10/src/redis-server /usr/local/myRedis/redis-cluster/7000

vim redis.conf 每一個redis下面的redis.conf的配置(如下是個人):

port 7001 //端口7001,7002,7003
bind 本機ip //默認ip爲127.0.0.1 須要改成其餘節點機器可訪問的ip 不然建立集羣時沒法訪問對應的端口,沒法建立集羣,我直接註釋掉了
daemonize yes //redis後臺運行
pidfile /var/run/redis_7000.pid //pidfile文件對應7000,7001,7002
cluster-enabled yes //開啓集羣 把註釋#去掉
cluster-config-file nodes_7000.conf //集羣的配置 配置文件首次啓動自動生成 7001,7002,7003
cluster-node-timeout 15000 //請求超時 默認15秒,可自行設置
appendonly yes //aof日誌開啓 有須要就開啓,它會每次寫操做都記錄一條日誌
能夠查看 https://blog.csdn.net/xiaoguaihu12/article/details/56845473


7000目錄下到其兄弟目錄下(7001-7005)
cp * /usr/local/myRedis/redis-cluster/7001


啓動6個redis

//分配主從
./redis-trib.rb create --replicas 1 30.23.13.36:7000 30.23.13.36:7001 30.23.13.36:7002 30.23.13.36:7003 30.23.13.36:7004 30.23.13.36:7005

//鏈接集羣 某一個節點便可
redis-cli -c -h 30.23.13.36 -p 7003
redis-cli -c -h 30.23.8.8 -p 7000

//啓動
cd /usr/local/myRedis/redis-cluster/7000
./redis-server ./redis.conf
cd /usr/local/myRedis/redis-cluster/7001
./redis-server ./redis.conf
cd /usr/local/myRedis/redis-cluster/7002
./redis-server ./redis.conf
cd /usr/local/myRedis/redis-cluster/7003
./redis-server ./redis.conf
cd /usr/local/myRedis/redis-cluster/7004
./redis-server ./redis.conf
cd /usr/local/myRedis/redis-cluster/7005
./redis-server ./redis.conf

//關閉 或kill -9 進程Id 經過pkill -9 redis殺死reids 進程以後,從新啓動各個節點,集羣自動建立成功(殺死以前的集羣狀態)
注意:前提是不要清空nodes.conf文件

 

//gc
cd /usr/local/myRedis/redis-cluster/7000
rm -rf appendonly.aof dump.rdb nodes.conf
cd /usr/local/myRedis/redis-cluster/7001
rm -rf appendonly.aof dump.rdb nodes.conf
cd /usr/local/myRedis/redis-cluster/7002
rm -rf appendonly.aof dump.rdb nodes.conf
cd /usr/local/myRedis/redis-cluster/7003
rm -rf appendonly.aof dump.rdb nodes.conf
cd /usr/local/myRedis/redis-cluster/7004
rm -rf appendonly.aof dump.rdb nodes.conf
cd /usr/local/myRedis/redis-cluster/7005
rm -rf appendonly.aof dump.rdb nodes.conf

到src目錄下
./redis-trib.rb add-node 30.23.8.8:7001 30.23.8.8:7000
./redis-trib.rb add-node --slave 30.23.8.8:7001 30.23.8.8:7000
./redis-trib.rb reshard 30.23.8.8:7000

 

三主

config set masterauth redis@2018 ;
config set requirepass redis@2018;
config rewrite

https://www.cnblogs.com/coder-lzh/p/9006048.html rocktmq

https://blog.csdn.net/qq_23250633/article/details/81063762

https://blog.csdn.net/zhangweiwei2020?t=1


https://blog.csdn.net/u012394095/article/details/82180538
https://blog.csdn.net/east123321/article/details/82258366

 


https://blog.csdn.net/weixin_38823568/article/details/82023371 *****cloud 集羣
https://blog.csdn.net/w1054993544/article/list/1?t=1
http://www.itmuch.com/spring-cloud/zuul/zuul-ha/ //zuul架構


經測試 spring定時器@Scheduled(cron=) 在集羣模式下,運行代碼內容時間起點是不一致的,有微小差距,微妙級別,致使定時器重複執行,後面
又趨於正常(多是cpu是單核的吧,測試是在同一臺機器
開某個服務部署2個節點),因此可能存在定時器重複執行,建議在定時器裏處理業務代碼的時候,休眠0.5毫秒或1秒,若是業務邏輯處理很快
再加上服務器存在的時間差,致使定時器重複執行。
@PostConstruct
private void init() {
Config config = new Config();
try {
//集羣
if(clusterNodes!=null) {
String[] nodes = clusterNodes.split(",");
ClusterServersConfig clusterServersConfig = config.useClusterServers().addNodeAddress(nodes);
//redispassword
if(redisPasswd !=null){
clusterServersConfig.setPassword(redisPasswd);
}
}else { //單機
SingleServerConfig singleServerConfig = config.useSingleServer().setAddress(new StringBuilder().append(redisHost).append(":").append(redisPort).toString());
//redispassword
if(redisPasswd!=null) {
singleServerConfig.setPassword(redisPasswd);
}
}
redisson = (Redisson) Redisson.create(config);
logger.info("Redisson init success");
} catch (Exception e) {
logger.error("init Redisson error ",e);
}
}

2018-10-31 10:39:00.016 INFO [service-cache,66cb05f85f5e677f,66cb05f85f5e677f,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : ----------*******start port is 8301 current time is 2018-10-31 10:39:00,cuurent mills is 1540953540016
2018-10-31 10:39:00.049 INFO [service-cache,66cb05f85f5e677f,66cb05f85f5e677f,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : handle logic ing ....,the server port is 8301 ,current time is 2018-10-31 10:39:00 ,cuurent mills is 1540953540049
2018-10-31 10:39:00.065 INFO [service-cache,66cb05f85f5e677f,66cb05f85f5e677f,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : Redisson分佈式鎖釋放鎖:redislock,ThreadName :47 ,cuurent mills is 1540953540065
2018-10-31 10:39:30.003 INFO [service-cache,3b6fd465df8c1483,3b6fd465df8c1483,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : ----------*******start port is 8301 current time is 2018-10-31 10:39:30,cuurent mills is 1540953570003
2018-10-31 10:39:30.043 INFO [service-cache,3b6fd465df8c1483,3b6fd465df8c1483,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : handle logic ing ....,the server port is 8301 ,current time is 2018-10-31 10:39:30 ,cuurent mills is 1540953570043
2018-10-31 10:39:30.071 INFO [service-cache,3b6fd465df8c1483,3b6fd465df8c1483,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : Redisson分佈式鎖釋放鎖:redislock,ThreadName :47 ,cuurent mills is 1540953570071
2018-10-31 10:40:00.011 INFO [service-cache,dfa167b717d60e55,dfa167b717d60e55,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : ----------*******start port is 8301 current time is 2018-10-31 10:40:00,cuurent mills is 1540953600011
2018-10-31 10:40:00.027 INFO [service-cache,dfa167b717d60e55,dfa167b717d60e55,true] 11404 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : Redisson分佈式鎖沒有獲取到鎖:redislock,ThreadName :47 cuurent mills is 1540953600027


第二臺機器
2018-10-31 10:39:00.003 INFO [service-cache,2384387b0ca655f9,2384387b0ca655f9,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : ----------*******start port is 8303 current time is 2018-10-31 10:39:00,cuurent mills is 1540953540003
2018-10-31 10:39:00.028 INFO [service-cache,2384387b0ca655f9,2384387b0ca655f9,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : handle logic ing ....,the server port is 8303 ,current time is 2018-10-31 10:39:00 ,cuurent mills is 1540953540028
2018-10-31 10:39:00.049 INFO [service-cache,2384387b0ca655f9,2384387b0ca655f9,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : Redisson分佈式鎖釋放鎖:redislock,ThreadName :50 ,cuurent mills is 1540953540049
2018-10-31 10:39:30.004 INFO [service-cache,dd1ff0e96855fb48,dd1ff0e96855fb48,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : ----------*******start port is 8303 current time is 2018-10-31 10:39:30,cuurent mills is 1540953570004
2018-10-31 10:39:30.032 INFO [service-cache,dd1ff0e96855fb48,dd1ff0e96855fb48,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : Redisson分佈式鎖沒有獲取到鎖:redislock,ThreadName :50 cuurent mills is 1540953570031
2018-10-31 10:40:00.004 INFO [service-cache,e6d0fb93687c76a1,e6d0fb93687c76a1,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : ----------*******start port is 8303 current time is 2018-10-31 10:40:00,cuurent mills is 1540953600004
2018-10-31 10:40:00.020 INFO [service-cache,e6d0fb93687c76a1,e6d0fb93687c76a1,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : handle logic ing ....,the server port is 8303 ,current time is 2018-10-31 10:40:00 ,cuurent mills is 1540953600020
2018-10-31 10:40:00.035 INFO [service-cache,e6d0fb93687c76a1,e6d0fb93687c76a1,true] 7028 --- [pool-9-thread-1] c.q.c.service.lock.ScheduleAsyncTest : Redisson分佈式鎖釋放鎖:redislock,ThreadName :50 ,cuurent mills is 1540953600035

 

Ctrl+Alt+V,能夠引入變量。例如:new String(); 自動導入變量定義
Ctrl+Alt+T,能夠把代碼包在一個塊內,例如:try/catch
Ctrl+Enter,導入包,自動修正
Ctrl+Alt+L,格式化代碼

http://qiye.pingan.com.cn/group1/M00/00/2D/CglIiV04HwyEFkv4AAAAADRXu5E697.zip 1565232033七、jhc12345678 pase-sams-stg1.paic.com.cn

 

update idm_sys_menu set style = icon where enterpriseid = 1 and dr = 0 and sys_id = (select s.id from idm_sys_system s where s.enterpriseid = 1 and s.code = 'PASE-SAMS' and dr = 0)

相關文章
相關標籤/搜索