日志
node
NPM 常用命令
除了本章介绍的部分外,NPM还提供了很多功能,package.json里也有很多其它有用的字段。
除了可以在npmjs.org/doc/查看官方文档外,这里再介绍一些NPM常用命令。
NPM提供了很多命令,例如install和publish,使用npm help可查看所有命令。
NPM提供了很多命令,例如install和publish,使用npm help可查看所有命令。
使用npm help <command>可查看某条命令的详细帮助,例如npm help install。
在package.json所在目录下使用npm install . -g可先在本地安装当前命令行程序,可用于发布前的本地测试。
使用npm update <package>可以把当前目录下node_modules子目录里边的对应模块更新至最新版本。
使用npm update <package> -g可以把全局安装的对应命令行程序更新至最新版。
使用npm cache clear可以清空NPM本地缓存,用于对付使用相同版本号发布新版本代码的人。
使用npm unpublish <package>@<version>可以撤销发布自己发布过的某个版本代码。
使用淘宝 NPM 镜像
由于国内直接使用 npm 的官方镜像是非常慢的,这里推荐使用淘宝 NPM 镜像。
淘宝 NPM 镜像是一个完整 npmjs.org 镜像,你可以用此代替官方版本(只读),同步频率目前为 10分钟 一次以保证尽量与官方服务同步。
你可以使用淘宝定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:
$ npm install -g cnpm --registry=https://registry.npmmirror.com
这样就可以使用 cnpm 命令来安装模块了:
$ cnpm install [name]
更多信息可以查阅:https://npmmirror.com/。
如果你遇到了使用 npm 安 装node_modules 总是提示报错:报错: npm resource busy or locked.....。
可以先删除以前安装的 node_modules :
npm cache clean
npm install
node镜像
npm config set registry https://registry.npm.taobao.org
npm config set registry https://registry.npmjs.org
token
LongloginTime=System.currentTimeMillis();
Stringtoken=DigestUtils.md5Hex(platformId+loginTime+ServerConfig.login_token_ext);
token=loginTime+";"+token;
zip
win10 下载环境 http://stahlworks.com/dev/index.php?tool=zipunzip
del .\client.zip
#排除目录
zip -r client.zip D:\demo\client -x *test3*
zip -r client.zip D:\demo\client -x D:\demo\client\test1*
D:\demo>zip -r client.zip D:\demo\client -x D:\demo\client\test1* D:\demo\client\test2*
updating: demo/client/ (260 bytes security) (stored 0%)
updating: demo/client/client.js (172 bytes security) (deflated 35%)
updating: demo/client/test3/ (260 bytes security) (stored 0%)
updating: demo/client/test3/test4.txt (172 bytes security) (stored 0%)
adding: demo/client/test3/test1.txt (172 bytes security) (stored 0%)
adding: demo/client/test3/test2.txt (172 bytes security) (stored 0%)
@echo off
D:
cd D:\javaproject\g20_server\g20
echo-----------------install-----------------------
call npm install --production
echo------------------ci---------------------------
call npm run ci
del g20.zip
echo-------------------------zip-------------------
zip -rq g20.zip .\* -x D:\javaproject\g20_server\g20\logs* D:\javaproject\g20_server\g20\run* D:\javaproject\g20_server\g20\test* D:\javaproject\g20_server\g20\tools*
echo----------------clean-------------------------
call npm run clean
echo-----------------install-----------------------
call npm install
pause
proto
message CustomerServiceLoginResp { repeated CustomerServiceChatRoomInfoProto chatInfos = 1;}
数据分析:
充值项目:
RoleRechargeInforoleRechargeInfo=rechargeRepo.getRoleRechargeInfo(roleId);
rechargeVos=roleRechargeInfo.getRechargeVos();
reChargevo.getJsonId();
reChargevo.getTotalRechargeNum();
签到:
@Autowired
privateActiveRepoactiveRepo;
//注册签到
RoleCheckInInforoleCheckInInfo=activeRepo.getRoleCheckInInfo(gamePlayer.getRoleId());
roleCheckInInfo.getCheckInDay();//签到天数(1~7 day)
RoleActiveCheckInInforoleActiveCheckInInfo=activeRepo.getRoleActiveCheckInInfo(roleId);
roleActiveCheckInInfo.getCheckInDay();//活动签到天数(1~7 day)
15
查询用户信息:
账户查询:
accountRepo{//放系统roleId下面吧
privatestaticfinalStringACCOUNT_INFO_KEY_STR="account info key str, do not change it";
privatebyte[] accountInfoKey=null;
privatebyte[] getAccountInfoKey(){
if(accountInfoKey==null) accountInfoKey=RedisKeyUtil.getByteArray(ACCOUNT_INFO_KEY_STR,StorageKey.account_info_key);
returnaccountInfoKey;
}
publicbyte[] getAccountIdKey(StringaccountId){
byte[]
return
}
publicvoidsaveAcc...(){
byte[] key=getAccountInfoKey();
this.baseRepo.save(key,Info..);
}
publicinfo.. getAccoun...(Stringacc..Id ){
getKey();
this.baseRepo.getValue(key);
}
}
accountInfoimplements ProtobufSerializable{
privateStringaccountId;
privateStringaccountName;
privatelongroleId;//long 默认值 0
}
Role {
privateStringaccountId=null;//初始化为null表示未绑定账户
}
DigestUtils.md5Hex():加密解密
<!-- https://mvnrepository.com/artifact/org.apache.directory.studio/org.apache.commons.codec -->
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.codec</artifactId>
<version>1.8</version>
</dependency>
DigestUtils.md5Hex(behaviorInterestStr.getBytes());
importorg.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
privatestaticStringgetSign(Map<String, String>params, StringappKey, StringappSecret) throwsUnsupportedEncodingException {
TreeMap<String, String>paramsSorted=newTreeMap<>(params);
Stringdata="";
paramsSorted.put("appkey", appKey);
for (Stringkey : paramsSorted.keySet()) {
if (data!="")
data+="&";
data+=key+"="+urlEncode(paramsSorted.get(key));
}
if (appSecret==null)
returndata;
returndata+"&sign="+DigestUtils.md5Hex(data+appSecret);
}
importorg.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* 签名字符串
*
* @param text 需要签名的字符串
* @param sign 签名结果
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
publicstaticbooleanverify(Stringtext, Stringsign, Stringkey, Stringinput_charset) {
text=text+key;
Stringmysign=DigestUtils.md5Hex(getContentBytes(text, input_charset));
if (mysign.equals(sign)) {
returntrue;
} else {
returnfalse;
}
}
9月14
banAccount.jsp//封号功能
banSuccess.jsp
白名单:目前除了添加和删除白名单用户,只能将登陆验证用户是否为白名单返回给前端
->只能将白名单返回到前端
查看白名单
添加白名单 IP
添加白名单 玩家ID
删除白名单IP
删除白名单(玩家ID)
列表1 | 列表2 |
| 列表1|列表2| | * + [ ] = 打勾 |
登陆:
lethttpStr=`${headStr}://${loginIp}:${loginPort}/g09-web/update/signServer.jsp?user_id=${loginSdkRespData.userId}&token=${loginSdkRespData.token}&account=${loginSdkRespData.account}&channelId=${GameContext.getChannelId()}&sdkType=${loginSdkRespData.sdkType}&pwd=${loginSdkRespData.password}&game=${loginSdkRespData.game}&channelNo=${loginSdkRespData.channelNo}`
signServer.jsp -> login.LoginService(loginInfo)
String token = DigestUtils.md5Hex(platformId + loginTime + ServerConfig.login_token_ext);
token = loginTime + ";" + token;
whiteListData -> this.ipMap.containsKey(ip);
or ->platformIdMap.containsKey(platformId);
signServer.jsp -> if(isWhitelist){ map.put("isWhiteList", "1"); }else{ map.put("isWhiteList", "2"); }
@Slf4j
log.info("longzhu reward reset day!!! longzhuIssueNum:{}", longzhuIssueNum);
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
http://172.18.1.53/g09_server.git
node.js下载
https://nodejs.org/download/release/v12.22.12/
linux解压命令
tar -zxvf xxx.tar.gz -C /xxx/
publicList<Long>findBackRoleId(StringplatformId, intareaId) {
longconcurrentMaxIdNumber=globalRepo.newRoleId();
List<Long>findedRoleIds=newArrayList<>();
for (longroleId=33244; roleId<concurrentMaxIdNumber; ++roleId) {
byte[] key=getRoleKey(roleId);
byte[] value=this.baseRepo.getValue(key);
if (value!=null) {
Rolerole=newRole(value);
if (role.getPlatformId().equals(platformId) &&role.getAreaId() ==areaId) {
findedRoleIds.add(roleId);
}
}
}
returnfindedRoleIds;
}
jsp
找回
searchRoleId.jsp
searchRoleIdSuccess.jsp
jsp
居中
<divstyle="display: grid; place-items: center;">
</div>
<divstyle="text-align:center;vertical-align:middle;">
<inputtype="text">
</div>
StringBuilder
StringBuilderstringBuilder=newStringBuilder();
for (inti=0 ;i<produceNum; i++) {
longseed1=newRandom().nextInt();
longseed=Math.abs(seed1);
logger.info("i:"+i+"seed:"+seed);
SingleGameCalsingleGameCal=newSingleGameCal(this.type, seed,this.data);
intodd=singleGameCal.cal();
stringBuilder.append(odd).append(",").append(seed).append(System.getProperty("line.separator"));//.append("\r\n");
时间格式转换
<%@ page import="java.text.SimpleDateFormat" %><%@ page import="java.util.Date" %>
<%@ page import="java.util.concurrent.TimeUnit" %>
long time = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(day) + TimeUnit.HOURS.toMillis(hour);
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.format(role.getCreateTime())
SimpleDateFormat utcSdf = TimeUtil.getSimpleDateFormatUTC();
SimpleDateFormat utcSdf = TimeUtil.getSimpleDateFormatUTC(); long regBeginTime = utcSdf.parse("2022-06-06 00:00:00").getTime(); long regEndTime = utcSdf.parse("2022-06-07 00:00:00").getTime();
全局自增范围
long beginRoleId = GlobalRepo.getRoleId_start_val(); long endRoleId = globalRepo.getRoleIdIndex();
long endRoleId = globalRepo.getRoleIdIndex();
linux 检索 查询 部署 日志
重设时间
ntpdate -u ntp.api.bz
date -s"20230111 23:57:00"
修改linux的系统时间的方法:
1、利用date命令设定系统的日期与时间,语法“date -s “年月日 时:分秒””;
2、执行“hwclock --systohc”命令保存设置,关机重启。
打包压缩
zip xxx.zip xxx.txt
tar -zxfv xxx.tar.gz //解压
tar -cvf xxx.tar.gz xxx.txt //压缩
结合:
find -name 'xxx*' -exec tar ...
停止Tomcate
ps -ef|grep -v grep|grep /usr/local/apache-tomcat-7.0.100
启动 /bin/startup.sh
ID=`ps -ef | grep java | grep apache-tomcat-6.0.35|awk '{print $2}'`
echo $ID
echo"---------------"
for id in $ID
do
kill -9 $id
echo "killed$id"
done
echo"---------------"
————————————————
版权声明:本文为优快云博主「青年vs阳光」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/u010029821/article/details/115479067
查看磁盘空间使用情况
df -h //查看磁盘使用情况
du -sh ./* //查看当前目录
定时任务
10 0 */3 * * /bin/sh /root/logs/g20/crontabCleanTask.sh
#!/bin/bash
logs_path="/usr/local/apache-tomcat-7.0.100/logs"
d=`date +%Y-%m-%d`
cp $logs_path/catalina.out $logs_path/catalina.${d}.out
>$logs_path/catalina.out;
find $logs_path -mtime +30 -name "catalina.*.out" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "localhost.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "localhost_access_log.*.txt" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "catalina.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "manager.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "host-manager.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "fileservice.log.*" -exec rm -rf {} \;
====================================================
time=$(date "+%Y%m%d:%H-%M-%S")
echo "${time}"
echo "--我要开始清理日志啦-----"
echo '' > /root/logs/g20/g20-web.log
echo "---已经清理完毕---"
==========================================
定时任务清理日志
cd ./var/spool/mail
root
grep "roleId:100036645" catalina.2022-09-08.out -n
-n是显示行号
-i 忽略大小写
find /home/wanggcc/wanggccgcflkf113/tomcat/logs/ -name "catalina.2022-09-0*" | xargs grep -F 'roleId:100036645'
grep "roleId:100036645" -l catalina.2022-09-08.out catalina.2022-09-07.out catalina.2022-09-06.out
grep "roleId:100036645" -l catalina.2022-09-08.out catalina.2022-09-07.out catalina.2022-09-06.out |xargs grep -F 'roleId:100036645'
find /home/wanggcc/wanggccgcflkf113/tomcat/logs/ -name "catalina.2022-09-0*" | xargs grep -Fl 'roleId:100036645'
find /home/wanggcc/wanggccgcflkf113/tomcat/logs/ -name "catalina.2022-09-0*" | xargs grep 'roleId:100036645' -lF
grep -E "正则" filePath
上下一百行
sed -n "852186,852386p" catalina.2022-10-09.out
]$ sed -n "855033,855333p" catalina.2022-10-09.out
tail date.log 输出文件末尾的内容,默认10行
tail -20 date.log 输出最后20行的内容
tail -n -20 date.log 输出倒数第20行到文件末尾的内容
tail -n +20 date.log 输出第20行到文件末尾的内容
tail -f date.log 实时监控文件内容增加,默认10行。
head date.log 输出文件开头的内容,默认10行
head -15 date.log 输出开头15行的内容
head -n +15 date.log 输出开头到第15行的内容
head -n -15 date.log 输出开头到倒数第15行的内容
sed -n "开始行,结束行p" 文件名
sed -n '70,75p' date.log 输出第70行到第75行的内容
sed -n '6p;260,400p; ' 文件名 输出第6行 和 260到400行
sed -n 5p 文件名 输出第5行
浅谈linux中/dev/vda1文件满了解决方法
df -h
cd /du -sh *
查看目录大文件
jmap
jmap -histo:live pid
1913622
jmap -F -dump:live,format=b,file=heap4.hprof pid
jmap -heap 1995679 //显示Java堆信息
使用方法 jmap -histo pid。如果连用SHELL jmap -histo pid>a.log可以将其保存到文本中去,在一段时间后,使用文本对比工具,可以对比出GC回收了哪些对象。jmap -dump:format=b,file=outfile 3024可以将3024进程的内存heap输出出来到outfile文件里,再配合MAT(内存分析工具(Memory Analysis Tool),使用参见:http://blog.youkuaiyun.com/fenglibing/archive/2011/04/02/6298326.aspx)或与jhat (Java Heap Analysis Tool)一起使用,能够以图像的形式直观的展示当前内存是否有问题。
————————————————
版权声明:本文为优快云博主「冯立彬」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/fenglibing/article/details/6411953
logs_paths[0]="xxxx_tomcat8_9001";
logs_paths[1]="xxxx_tomcat8_9002";
for logs_path in ${logs_paths[@]}
do
echo "执行GC回收 $logs_path"
tomcatid=$(ps -ef|grep tomcat/$logs_path |grep -v grep|cut -c 9-15)
if [ "$tomcatid" != "" ];
then
jcmd $tomcatid GC.run
fi
done
地址端口
172.18.0.159:7456 本地 g20 毛
g20部署
获取修改数据库记录redis密码,服务器内外ip8.134.109.132172.17.24.71
修改ipJava部分 添加 g20-web src main resources onlinetestxx
修改g20-server全局配置package com.wind.g20.base.global; ServiceInitor 和paltformType
修改g20-web 的pom文件<profiles><profile><id>onlinetest01</id><activation><property><name>env</name><value>onlinetest01</value></property><activeByDefault>false</activeByDefault></activation><properties><dir.name>onlinetest01</dir.name></properties></profile></profiles>
修改ts部分g20 config config.prod.ts 的mysql
ts打包先构建生产环境 npm install --production注释掉 tsconfig.json中的 "outDir": "dist"整个文件夹压缩,上传到服务器解压即可。 已部署过一次,只把代码上传到服务器即可打包脚本 g20_server\g20\dist压缩放在服务器 /data/g20/ 里执行deploy-g20-dist.sh tail -100f /root/logs/g20/g20-web.log/root/logsmaster-stdout.log TvS3xdWSWoM4zDIRn8Jwf_
TvS3xdWSWoM4zDIRn8Jwf_
java部分g20-service src main java shell更新proto get-and-exec-protoc打war包放在 /data/ 里面
cd /usr/local/ 执行里面的sh文件/usr/local/deploy-g20-01.sh
/data/g20/deploy-g20-dist.sh
更新javaproject g20 commit/pullD:\javaproject\g20_server\g20\tools copy_ts_file_from_front 更新 D:\javaproject\g20_server\g20\tools\excel 更表 get_and_produceD:\javaproject\g20_server\g20\dist pack - prod 打包压缩后上传服务器
========================
win10 检索查询
findstr /?
/S 在当前目录和所有子目录中搜索匹配文件。
/N 在匹配的每行前打印行数。
FINDSTR /s /n "talkConfig" D:\javaproject\g09_server\g09-server\src\tools\xml2\execel\*
找d盘aaa月录下包含abc的所有文件
findstr /s /n "abc" d\aaa\*
查询文件名
for /r D:\javaproject\g09_server\g09-server\src\tools\xml2\execel %i in (*文件名*) do @echo %i
eclipse
查询方法被调用: 左键选中 Ctrl+Shift+G
/usr/local/apache-tomcat-7.0.100/webapps/g09-web/WEB-INF/xml/com/wind/g09/xml
/usr/local/apache-tomcat-7.0.100/webapps/g09-web/tools
/home/wanggcc_yanfa
linux命令操作记录
xmlUpdata
/usr/local/apache-tomcat-7.0.100/webapps/g09-web/WEB-INF/xml/com/wind/g09/xml
/usr/local/apache-tomcat-7.0.100/webapps/g09-web/tools
/home/wanggcc_yanfa
/data/apache-tomcat-7.0.100/webapps/g09-web/WEB-INF/xml/com/wind/g09/xml
find
Linux find 命令 | 菜鸟教程 (runoob.com)
find . -name "*.sh"
talkConfigs
0通用_政务和npc和宝箱配置
java.util.Collections.unmodifiableMap();
java 时间
email:
DateTime thirtyDaysBefore = DateTime.now().minusDays(EmailVo.SYSTEM_EMAIL_CONTINUE_DAYS);
DateTime regDateTime = new DateTime(roleRegTimeTime);
DateTime minCreateTime = null;
chat:
long time30 = TimeUtil.getUTC();
DateTime thirtyDaysBefore = new DateTime(time30).minusDays(ChatVo.SYSTEM_CHART_CONTINUE_DAYS);
比较:
new DateTime(chatVo.getCreateTime()).isBefore(thirtyDaysBefore)
java Util
byte 转 long
/**
* 直接读取byte数组进行计算
* @param bytes
* @return
*/
public static long bytesToLong(byte[] bytes) {
if(bytes.length == 1){
return bytes[0];
}else if(bytes.length == 2){
return bytes[0] * 256 + byte2Int(bytes[1]);
}else if(bytes.length == 3){
return bytes[0] * 65536 + byte2Int(bytes[1]) * 256 + byte2Int(bytes[2]);
}else if(bytes.length == 4){
return bytes[0] * 16777216 + byte2Int(bytes[1]) * 65536 + byte2Int(bytes[2]) * 256 + byte2Int(bytes[3]);
}else if(bytes.length == 5){
return bytes[0] * 4294967296l + byte2Int(bytes[1]) * 16777216 + byte2Int(bytes[2]) * 65536 + byte2Int(bytes[3]) * 256 + byte2Int(bytes[4]);
}else if(bytes.length == 6){
return bytes[0] * 1099511627776l + byte2Int(bytes[1]) * 4294967296l + byte2Int(bytes[2]) * 16777216 + byte2Int(bytes[3]) * 65536 + byte2Int(bytes[4]) * 256 + byte2Int(bytes[5]);
}else if(bytes.length == 7){
return bytes[0] * 281474976710656l + byte2Int(bytes[1]) * 1099511627776l + byte2Int(bytes[2]) * 4294967296l + byte2Int(bytes[3]) * 16777216 + byte2Int(bytes[4]) * 65536 + byte2Int(bytes[5]) * 256 + byte2Int(bytes[6]);
}
return 0l;
}
public static int byte2Int(byte b){
return (int)(b & 0xff);
}
/**
* 通过位移方式进行计算
* @param bs
* @return
*/
static long bytes2long(byte[] bs) {
int bytes = bs.length;
switch(bytes) {
case 0:
return 0;
case 1:
return (long)((bs[0] & 0xff));
case 2:
return (long)((bs[0] & 0xff) <<8 | (bs[1] & 0xff));
case 3:
return (long)((bs[0] & 0xff) <<16 | (bs[1] & 0xff) <<8 | (bs[2] & 0xff));
case 4:
return (long)((bs[0] & 0xffL) <<24 | (bs[1] & 0xffL) << 16 | (bs[2] & 0xffL) <<8 | (bs[3] & 0xffL));
case 5:
return (long)((bs[0] & 0xffL) <<32 | (bs[1] & 0xffL) <<24 | (bs[2] & 0xffL) << 16 | (bs[3] & 0xffL) <<8 | (bs[4] & 0xffL));
case 6:
return (long)((bs[0] & 0xffL) <<40 | (bs[1] & 0xffL) <<32 | (bs[2] & 0xffL) <<24 | (bs[3] & 0xffL) << 16 | (bs[4] & 0xffL) <<8 | (bs[5] & 0xffL));
case 7:
return (long)((bs[0] & 0xffL) <<48 | (bs[1] & 0xffL) <<40 | (bs[2] & 0xffL) <<32 | (bs[3] & 0xffL) <<24 | (bs[4] & 0xffL) << 16 | (bs[5] & 0xffL) <<8 | (bs[6] & 0xffL));
case 8:
return (long)((bs[0] & 0xffL) <<56 | (bs[1] & 0xffL) << 48 | (bs[2] & 0xffL) <<40 | (bs[3] & 0xffL)<<32 |
(bs[4] & 0xffL) <<24 | (bs[5] & 0xffL) << 16 | (bs[6] & 0xffL) <<8 | (bs[7] & 0xffL));
default:
return 0;
}
}
————————————————
版权声明:本文为优快云博主「beijiaoguzai」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/beijiaoguzai/article/details/124667298
生成key
/**获取key*/
public static byte[] getByteArray2(long roleId, short keyFlag,long objectId) {
if(keyFlag < 0)
throw new IllegalArgumentException("The key flag must over zero");
int keyFlagLen = keyFlag >= 256 ? 2 : 1;
byte[] bytes = new byte[keyFlagLen + 12];
int userId = (int) roleId;
bytes[0] = (byte) (objectId & 0XFF);
bytes[1] = (byte) ((objectId >> 8) & 0XFF);
bytes[2] = (byte) ((objectId >> 16) & 0XFF);
bytes[3] = (byte) ((objectId >> 24) & 0XFF);
bytes[4] = (byte) ((objectId >> 32) & 0XFF);
bytes[5] = (byte) ((objectId >> 40) & 0XFF);
bytes[6] = (byte) ((objectId >> 48) & 0XFF);
bytes[7] = (byte) ((objectId >> 56) & 0XFF);
bytes[8] = (byte) ((userId >> 32) & 0XFF);
bytes[9] = (byte) ((userId >> 40) & 0XFF);
bytes[10] = (byte) ((userId >> 48) & 0XFF);
bytes[11] = (byte) ((userId >> 56) & 0XFF);
bytes[12] = (byte) (keyFlag & 0XFF);
if (keyFlagLen == 2) {
bytes[13] = (byte) ((keyFlag >> 8) & 0XFF);
}
return bytes;
}
node.js学习搭建
win 10 搭建:https://blog.youkuaiyun.com/m0_67514201/article/details/126171526
## 设置淘宝源 镜像
npm config set registry https://registry.npm.taobao.org/
## 查看源,可以看到设置过的所有的源
npm config get registry
Egg官网:
https://www.eggjs.org/zh-CN/core/unittest
菜鸟
https://www.runoob.com/nodejs/nodejs-http-server.html
redis
重启
#总结 最佳办法直接kill
如果是用apt-get或者yum install安装的redis,可以直接通过下面的命令停止/启动/重启redis
1、/etc/init.d/redis-server stop
2、/etc/init.d/redis-server start
3、/etc/init.d/redis-server restart
如果是通过源码安装的redis,则可以通过redis的客户端程序redis-cli的shutdown命令来重启redis
1、启动redis: redis-server redis-conf
2、关闭redis: redis-cli shutdown
3、当设置密码后,上面的关闭命令无效:带密码输入: redis-cli -a [password] 回车后输入:shutdown
即可关闭redis,输入exit 退出
4、查看redis密码;可查看 redis 安装根目录下的配置文件:redis-conf 中SECURITY下面的 requirepass 后面的内容
如果上述方式都没有成功停止redis,则可以使用终极武器 kill -9
————————————————
版权声明:本文为优快云博主「Thanos_cme」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/CMEguagua/article/details/103314797
telnet 139.159.227.171 6378
#连接客户端
redis-cli -h host -p port -a password
redis-cli.exe -h 111.67.201.208 -p 6378 -a zfz20190605
zfz20190605
#远程了连接
将bind 127.0.0.1 注释
将protected-mode修改为no
这边建议设置一下密码:requirepass xxx
开启一下redis
service redis start
、开启端口
命令如下:
firewall-cmd --zone=public --add-port=6379/tcp --permanent
我这里是直接把防火墙给关了:
systemctl stop firewalld.service
安装
make失败解决办法
make MALLOC=libc
redis数据库迁移
echo never > /sys/kernel/mm/transparent_hugepage/enabled#一次性
永久解决方法:
将其写入/etc/rc.local文件中:
iftest -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
fi
sysctl vm.overcommit_memory=1 #一次性
修改 /etc/sysctl.conf 文件,新增一行
vm.overcommit_memory = 1
使用 sysctl -p 是配置立即生效。
$ sysctl -p
cat /proc/sys/vm/overcommit_memory #查看
1.旧服务器
进入redis命令模式,查看数据备份存放的目录:
[root@localhost ~]# redis-cli
如果设置过密码,使用密码连接,命令:./redis-cli -h 127.0.0.1 -p 6378 -a zfz20190605
127.0.0.1:6379> config get dir
1) "dir"
2) "/usr/local/redis-4.0.9/src" //这就是redis数据文件地址
127.0.0.1:6379> quit #退出
查看该目录下有一个dump.rdb文件,该文件就是redis数据备份文件;
2、新服务器
需要先关闭redis服务,netstat -ntlp 查看redis PID
执行 kill PID
3、重启新服务器redis服务,完成
[root@localhost redis]# nohup ./redis-server ../redis.conf &
#使用这个启动
#cd /usr/local/redis-stable/src
#./redis-server /etc/redis/redis-6378.conf
#redis-server /etc/redis/redis-6378.conf
linux redis 三种启动方式
https://www.cnblogs.com/zkwarrior/p/16034341.html
将该文件复制到新服务器 (一定要先将新服务器的redis服务关闭,否则复制过去的文件数据会丢失)
scp /usr/local/redis-4.0.9/src/dump.rdb
root@47.118.49.19:/usr/local/redis-4.0.9/src/
如果存在该文件会询问你是否需要覆盖?输入 y;
redis版本升级
#安装 wget
yum install -y wget
#下载 redis
wget http://download.redis.io/releases/redis-4.0.9.tar.gz
#解压源码包
tar -zxvf redis-4.0.9.tar.gz
#停止旧版的redis
ps -ef|grep redis
kill -9 进程id
#查看gcc 版本
gcc -v
#如果是4.* 的就要升级,因为redis6.2 以上需要gcc 9.*的版本,不然make 编译redis时会报错。
#安装gcc
yum -y install gcc
#升级gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
#切换到升级的gcc 版本
#临时)
scl enable devtoolset-9 bash
#永久)
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
#查看版本是否切换成功:
gcc -v #如果gcc版本为9.*以上则成功,4.*反之
cd redis-4.0.9
#编译安装
make && make install
#将旧版的配置文件和备份数据文件复制到新版redis 中
cp -p /usr/local/redis-stable/redis.conf ./redis-4.0.9/
cp -p /usr/local/redis-stable/src/dump.rdb ./redis-4.0.9/src/
./redis-server /etc/redis/redis-6378.conf #启动
redis设置开机自启动
https://blog.youkuaiyun.com/weixin_42575720/article/details/126180798
vi /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /usr/local/redis-4.0.9/redis-6378.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
:wq
systemctl daemon-reload
#启动Redis
systemctl start redis
#查看Redis状态
systemctl status redis
#开机自启动
systemctl enable redis
MySQL安装
!错误 :
https://www.jb51.net/article/264496.htm
修改密码
https://blog.youkuaiyun.com/Lie_Jiu/article/details/123111472
servcie mysql restart
ansible部署
管理端:192.168.223.10
被管理端:192.168.223.20
被管理端:192.168.223.30
1、关闭防火墙
此代码由Java架构师必看网-架构君整理
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
2、安装相关软件
[root@localhost ~]# yum -y install epel-release.noarch
[root@localhost ~]# yum install -y ansible
[root@localhost ~]# yum install -y tree
[root@localhost ~]# tree /etc/ansible/
3、修改主机清单
此代码由Java架构师必看网-架构君整理
[root@localhost ~]# vim /etc/ansible/hosts
#配置主机清单#以下内容为添加内容,不是修改内容
[webservers]
192.168.223.20
#被监控端1的IP
[mysql]
192.168.223.30
#被监控端2的IP
4、创建密钥对,进行远程连接
#生成密钥对[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): #回车
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): #输入密码788788
Enter same passphrase again: #确认密码788788
Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:SHA256:WKpIMqbJgc2JyTz2C351d7bzbDJ83wUsyf1oKXaq82c root@localhost.localdomainThe key's randomart image is:+---[RSA 2048]----+| || || . ||+= . + . + ||*B= o S + + ||==+. o . . o . = ||oo..o . . + + = o||. ... .B.BE o|| ... .+X=...|+----[SHA256]-----+[root@localhost ~]# ls -aldrwx------. 2 root root 57 4月 8 10:31 .ssh[root@localhost ~]# cd .ssh/[root@localhost .ssh]# lsid_rsa id_rsa.pub #id_rsa:私钥;id_rsa.pub:公钥
5、将公钥上传到被监控端
ssh -o StrictHostKeyChecking=no root@8.219.186.72 //连不上 bug解决
[root@localhost .ssh]# ssh-copy-id root@8.219.1.52
[root@localhost .ssh]# ssh-copy-id root@8.219.186.72
#在监控端登录被监控端查看日期[root@ansible ~]
# ansible 192.168.223.20 -m command -a 'date'
Enter passphrase for key '/root/.ssh/id_rsa':
#输入之前设置的密码:788788192.168.223.20 | CHANGED | rc=0 >>2021年 04月 08日 星期四 12:12:19 CST
[root@ansible ~]# ansible mysql -m command -a 'date'
#当然也可以用别名进程查看Enter passphrase for key '/root/.ssh/id_rsa':192.168.223.30 | CHANGED | rc=0 >>2021年 04月 08日 星期四 12:14:22 CST-m:指定模块-a:指定参数
6、设置ssh免交互登录
[root@ansible ~]# ssh-agent bash
[root@ansible ~]# ssh-add
Enter passphrase for /root/.ssh/id_rsa:
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
java环境变量
JAVA_HOME=/usr/local/jdk1.8.0_131
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME
vim /etc/profile #编辑文件
export JAVA_HOME=/usr/local/jdk1.8 #移动到最后一行,添加
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
————————————————
版权声明:本文为优快云博主「南国以南i」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/springhub/article/details/120276534