centos7安装教程备份
一,centos 网络选择
ping www.baidu.com 如果无网络
---开启centos7网络
打开 /etc/sysconfig/network-scripts/ifcfg-enp0s3 文件,将 ONBOOT 改为 yes
重新启动网络:
systemctl start network.service / service network restart
ping www.baidu.com ok 说明网络ok
---查看ip地址
ip addr
ifconfig
yum search ifconfig
yum install net-tools.x86_64
二,虚拟机下CentOS7开启SSH连接
ps aux | grep sshd
1、yum list installed | grep openssh-server
此处显示已经安装 如果未安装 执行下面语句安装
yum install openssh-server
2、 找到了 /etc/ssh/ 目录下的sshd服务配置文件 sshd_config,用vi编辑器打开
打开端口
然后开启允许远程登录
开启使用用户名密码来作为连接验证
开启 sshd 服务,输入 sudo service sshd start
检查 sshd 服务是否已经开启,输入ps -e | grep sshd
或者输入netstat -an | grep 22 检查 22 号端口是否开启监听
为了免去每次开启 CentOS 时,都要手动开启 sshd 服务,可以将 sshd 服务添加至自启动列表中,输入systemctl enable sshd.service
可以通过输入systemctl list-unit-files | grep sshd,查看是否开启了sshd 服务自启动
三,防火墙
开启防火墙命令:
systemctl start firewalld.service
重启防火墙命令:
firewall-cmd --reload 或者 service firewalld restart
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
firewall-cmd --add-port=80/tcp --permanent
删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent
查看
firewall-cmd --zone=public --query-port=80/tcp
查看端口列表:
firewall-cmd --permanent --list-port
#3306/tcp 80/tcp
禁用防火墙
systemctl stop firewalld
设置开机启动
systemctl enable firewalld
停止并禁用开机启动
sytemctl disable firewalld
查看状态
systemctl status firewalld或者 firewall-cmd --state
-----------------------------------------------------------------------------------------------------------------------------------------------------
CentOS 7 开放防火墙端口 命令
最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用firewalld代替了原来的iptables。
使用方法如下:
>>> 关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
>>> 开启端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
命令含义:
--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效
>>> 重启防火墙
firewall-cmd --reload
常用命令介绍
firewall-cmd --state ##查看防火墙状态,是否是running
firewall-cmd --reload ##重新载入配置,比如添加规则之后,需要执行此命令
firewall-cmd --get-zones ##列出支持的zone
firewall-cmd --get-services ##列出支持的服务,在列表中的服务是放行的
firewall-cmd --query-service ftp ##查看ftp服务是否支持,返回yes或者no
firewall-cmd --add-service=ftp ##临时开放ftp服务
firewall-cmd --add-service=ftp --permanent ##永久开放ftp服务
firewall-cmd --remove-service=ftp --permanent ##永久移除ftp服务
firewall-cmd --add-port=80/tcp --permanent ##永久添加80端口
iptables -L -n ##查看规则,这个命令是和iptables的相同的
man firewall-cmd ##查看帮助
更多命令,使用 firewall-cmd --help 查看帮助文件
重新开启防火墙:Failed to start firewalld.service: Unit firewalld.service is masked 问题解决:
https://blog.csdn.net/Joe68227597/article/details/75207859
>>> CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下
1、直接关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、设置 iptables service
yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口3306
vi /etc/sysconfig/iptables
增加规则
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
最后重启系统使设置生效即可。
四,centos 安装 上传下载工具
自带scp
scp -i /Users/nealzhang/Desktop/hub.pem /Users/nealzhang/Desktop/vmz-ca/my自己生成/* [email protected]:/home/ec2-user
---lrzsz
yum install lrzsz -y
rpm -qa |grep lrzsz
上传文件的执行命令:
#rz
如果覆盖原文件,执行:
#rz -y
下载文件,执行:
#sz {文件}
五,查看端口
查询端口
netstat -tunlp | grep :3306
ps -ef | grep redis
kill -9 PID
kill -15 PID
进程号PID
ps aux
关闭进程号
kill -9 PID
六,测试端口
telnet 192.168.1.119 3306
七,后台运行jar
后台运行jar包方法:
1、nohup java -jar shareniu.jar &
nohup意为后台不挂断运行,与是否账号退出无关
2、nohup java -jar shareniu.jar >spring.log &
后台运行,并将相关日志输出到spring.log
&代表在后台运行。
nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行
运行:
nohup java -jar live-1.0.0.jar --spring.profiles.active=prod &
nohup java -jar vmz-innogy.jar --spring.profiles.active=prod > nohuplog.log 2>&1 &
---
上面的2 和 1 的意思如下:
0 标准输入(一般是键盘)
1 标准输出(一般是显示屏,是用户终端控制台)
2 标准错误(错误信息输出)
将运行的jar 错误日志信息输出到log.file文件中,然后(>&1)就是继续输出到标准输出(前面加的&,是为了让系统识别是标准输出),最后一个&,表示在后台运行。
结束后台!!!!!
ps -ef | grep live
通过ps aux命令查看进程号PID,然后执行 kill -9 PID
如果是前台进程的话,直接执行 Ctrl+c 就可以终止了
八,idea http请求实例
### 情报、前瞻支付
POST http://localhost:7771/content/pay
Content-Type: application/x-www-form-urlencoded
contentId=999
### 首页
POST http://localhost:7771/pc/banner/getBannerList
Content-Type: application/json
{
"type":"1",
"bannerType":"555"
}
###app比赛详情情报
GET http://localhost:7771/app/query/match/information?matchId=1111
###
GET http://localhost:7771/app/query/match/information/111
###
POST http://localhost:9092/userSessionStatView/visit/data
Content-Type: application/x-www-form-urlencoded
start='2019-03-19 00'
end='2019-03-19 23'
<> 2019-03-19T022151.200.json
### 测试ok 表单提交
POST http://localhost:9092/userSessionStatView/content/pay
Content-Type: application/x-www-form-urlencoded
userId: 10
contentId=123456&ttt=111
### 测试 传Date参数
POST http://localhost:9092/userSessionStatView/test
Content-Type: application/x-www-form-urlencoded
userId: 11
start=2019-03-22%2017
<> 2019-03-22T053542.200.json
###
九,idea 配置RunDashboard
如图以上方法还没有显示出来的话,则可以通过修改idea的workspace.xml的方式来快速打开Run Dashboard窗口
打开workspace.xml文件之后,找到component为 RunDashboard 的节点处,然后在component标签里添加
<option name="configurationTypes">
<set>
<option value="SpringBootApplicationConfigurationType" />
</set>
</option>
最后保存即可,保存完成之后立即自动弹出Run Dashboard窗口了
十,shell脚本批量单独启动,停止,重启java独立jar程序
touch service.sh
chmod 777 service.sh
#!/bin/bash
#####################################################Environment Setting#######################################################
#程序代码数组
APPS=(pushcode thirdpayment security redis commservice wechat point useraccount coupon interest experience dealaccount user send payment sms deal dispatch dealload recv innermsg reward finacial debt pushmsg esign crmda)
#程序名称数组
NAMES=(邀请码模块 第三方支付模块 安全模块 Redis模块 公共服务模块 微信服务模块 积分账户子系统 用户账户子系统 用户模块 队列消息发送模块 支付模块 短信系统 交易系统 消息队列模块 消息队列接收模块 站内信模块 奖励管理模块 结算系统 消息推送模块 电子签章 数据仓库)
#jar包数组
JARS=(pushcode-provider-0.0.1.jar comm-thirdpayment-provider-0.0.1.jar comm-security-provider.jar comm-redis-provider-0.0.1.jar comm-service-provider-0.0.1.jar action-provider-wechat-0.0.1.jar action-provider-point-0.0.1.jar action-provider-useraccount-0.0.1.jar action-provider-user-0.0.1.jar comm-message-send-provider-0.0.1.jar action-provider-payment-0.0.1.jar action-provider-sms-0.0.1.jar action-provider-deal-0.0.1.jar message-recv-dealload-0.0.1.jar comm-message-recv-provider-0.0.1.jar action-provider-innermsg-0.0.1.jar action-provider-reward-0.0.1.jar action-provider-finacial-0.0.1.jar message-pushmsg-0.0.1.jar provider-esign-0.0.1.jar provider-crmda-0.0.1.jar)
#jar包路径数组
PATHS=(/application/provider/pushcode /application/provider/thirdpayment /application/provider/security /application/provider/redis /application/provider/commservice /application/provider/wechat /application/provider/point /application/provider/useraccount /application/provider/user /application/provider/message/send /application/provider/payment /application/provider/sms /application/provider/deal /application/provider/message/dealload /application/provider/message/recv /application/provider/innermsg /application/provider/reward /application/provider/finacial /application/provider/pushmsg /application/provider/esign /application/provider/crmda)
start(){
local APPNAME=
local NAME=
local CLASSNAME=
local PROJECTDIR=
local command="sh service.sh start"
local cmd2="$1"
local cmd2ok=0
local cnt=0
local okcnt=0
#local C_PID="0"
#for i in `seq 0 22`
echo "---------------------------开始启动服务..."
for(( i=0;i<${#APPS[@]};i++))
do
APPNAME=${APPS[$i]}
NAME=${NAMES[$i]}
CLASSNAME=${JARS[$i]}
PROJECTDIR=${PATHS[$i]}
if [ "$cmd2" == "all" ] || [ "$cmd2" == "$APPNAME" ]; then
cmd2ok=1
C_PID="0"
cnt=0
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read pid
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
#do
#C_PID=$(ps --no-heading $pid | wc -l)
#if [ "$C_PID" == "1" ]; then
if [ -n "$PID" ]
then
echo "$APPNAME---$NAME:己经运行,PID=$PID"
#okcnt=$(($okcnt+1))
else
cd $PROJECTDIR
rm -f $PROJECTDIR/nohup.out
command="nohup java -jar $CLASSNAME --spring.profiles.active=prod &"
exec $command >> $PROJECTDIR/nohup.out &
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read pid
#do
# C_PID=$(ps --no-heading $pid | wc -l)
#done
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
cnt=0
#while (("$C_PID" == "0"))
while [ -z "$PID" ]
do
if (($cnt==30))
then
echo "$APPNAME---$NAME:$cnt秒内未启动,请检查!"
break
fi
cnt=$(($cnt+1))
sleep 1s
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read pid
#do
# C_PID=$(ps --no-heading $pid | wc -l)
#done
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
done
okcnt=$(($okcnt+1))
echo "$APPNAME---$NAME:己经成功启动,PID=$PID"
#出借模块和总装模块启动较慢
if [ "$APPNAME" == "deal" ] ;
then
echo "$APPNAME---$NAME:启动中..."
sleep 30s
fi
if [ "$APPNAME" == "dispatch" ] ;
then
echo "$APPNAME---$NAME:启动中..."
sleep 10s
fi
fi
#done
fi
done
if (($cmd2ok==0))
then
echo "command2: all|pushcode|thirdpayment|security|redis|commservice|wechat|point|useraccount|coupon|interest|experience|dealaccount|user|send|payment|sms|deal|dispatch|dealload|recv|innermsg|reward|finacial|debt"
else
echo "---------------------------本次启动:$okcnt个服务"
fi
}
stop(){
local APPNAME=
local CLASSNAME=
local PROJECTDIR=
local command="sh service.sh stop"
local cmd2="$1"
local cmd2ok=0
#local C_PID="0"
local okcnt=0
echo "---------------------------开始停止服务..."
for(( i=0;i<${#APPS[@]};i++))
do
APPNAME=${APPS[$i]}
NAME=${NAMES[$i]}
CLASSNAME=${JARS[$i]}
PROJECTDIR=${PATHS[$i]}
if [ "$cmd2" == "all" ] || [ "$cmd2" == "$APPNAME" ]; then
cmd2ok=1
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read PID
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
#do
#C_PID=$(ps --no-heading $PID | wc -l)
#if [ "$C_PID" == "1" ]; then
if [ -n "$PID" ]
then
echo "$NAME:PID=$PID准备结束"
kill $PID
#C_PID=$(ps --no-heading $PID | wc -l)
#while (("$C_PID" == "1"))
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
while [ -n "$PID" ]
do
sleep 1s
#C_PID=$(ps --no-heading $PID | wc -l)
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
done
echo "$NAME:成功结束"
okcnt=$(($okcnt+1))
else
echo "$NAME:未运行"
fi
#done
fi
done
if (($cmd2ok==0))
then
echo "command2: all|pushcode|thirdpayment|security|redis|commservice|wechat|point|useraccount|coupon|interest|experience|dealaccount|user|send|payment|sms|deal|dispatch|dealload|recv|innermsg|reward|finacial|debt"
else
echo "---------------------------本次共停止:$okcnt个服务"
fi
}
case "$1" in
start)
start "$2"
exit 1
;;
stop)
stop "$2"
;;
restart)
stop "$2"
start "$2"
;;
*)
echo "command1: start|stop|restart"
exit 1
;;
esac
linux命令用法:
1.启动所有jar程序:sh liveService.sh start all
2.停止所有jar程序:sh liveService.sh stop all
3.重启所有jar程序:sh liveService.sh restart all
4.单独启动、停止、重启某个jar程序:把最后面的all替换为某个jar程序的代码即可
---liveService.sh:
#程序代码数组
APPS=(草莓启动脚本)
#程序名称数组
NAMES=(草莓模块)
#jar包数组
JARS=(live-1.0.0.jar)
#jar包路径数组
PATHS=(/runxsports/)
start(){
local APPNAME=
local NAME=
local CLASSNAME=
local PROJECTDIR=
local command="sh service.sh start"
local cmd2="$1"
local cmd2ok=0
local cnt=0
local okcnt=0
#local C_PID="0"
#for i in `seq 0 22`
echo "---------------------------开始启动服务..."
for(( i=0;i<${#APPS[@]};i++))
do
APPNAME=${APPS[$i]}
NAME=${NAMES[$i]}
CLASSNAME=${JARS[$i]}
PROJECTDIR=${PATHS[$i]}
if [ "$cmd2" == "all" ] || [ "$cmd2" == "$APPNAME" ]; then
cmd2ok=1
C_PID="0"
cnt=0
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read pid
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
#do
#C_PID=$(ps --no-heading $pid | wc -l)
#if [ "$C_PID" == "1" ]; then
if [ -n "$PID" ]
then
echo "$APPNAME---$NAME:己经运行,PID=$PID"
#okcnt=$(($okcnt+1))
else
cd $PROJECTDIR
rm -f $PROJECTDIR/nohup.out
command="nohup java -jar $CLASSNAME --spring.profiles.active=prod &"
exec $command >> $PROJECTDIR/nohup.out &
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read pid
#do
# C_PID=$(ps --no-heading $pid | wc -l)
#done
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
cnt=0
#while (("$C_PID" == "0"))
while [ -z "$PID" ]
do
if (($cnt==30))
then
echo "$APPNAME---$NAME:$cnt秒内未启动,请检查!"
break
fi
cnt=$(($cnt+1))
sleep 1s
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read pid
#do
# C_PID=$(ps --no-heading $pid | wc -l)
#done
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
done
okcnt=$(($okcnt+1))
echo "$APPNAME---$NAME:己经成功启动,PID=$PID"
#出借模块和总装模块启动较慢
if [ "$APPNAME" == "deal" ] ;
then
echo "$APPNAME---$NAME:启动中..."
sleep 30s
fi
if [ "$APPNAME" == "dispatch" ] ;
then
echo "$APPNAME---$NAME:启动中..."
sleep 10s
fi
fi
#done
fi
done
if (($cmd2ok==0))
then
echo "command2: all|pushcode|thirdpayment|security|redis|commservice|wechat|point|useraccount|coupon|interest|experience|dealaccount|user|send|payment|sms|deal|dispatch|dealload|recv|innermsg|reward|finacial|debt"
else
echo "---------------------------本次启动:$okcnt个服务"
fi
}
stop(){
local APPNAME=
local CLASSNAME=
local PROJECTDIR=
local command="sh service.sh stop"
local cmd2="$1"
local cmd2ok=0
#local C_PID="0"
local okcnt=0
echo "---------------------------开始停止服务..."
for(( i=0;i<${#APPS[@]};i++))
do
APPNAME=${APPS[$i]}
NAME=${NAMES[$i]}
CLASSNAME=${JARS[$i]}
PROJECTDIR=${PATHS[$i]}
if [ "$cmd2" == "all" ] || [ "$cmd2" == "$APPNAME" ]; then
cmd2ok=1
#ps -ef | grep "$CLASSNAME" | awk '{print $2}' | while read PID
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
#do
#C_PID=$(ps --no-heading $PID | wc -l)
#if [ "$C_PID" == "1" ]; then
if [ -n "$PID" ]
then
echo "$NAME:PID=$PID准备结束"
kill $PID
#C_PID=$(ps --no-heading $PID | wc -l)
#while (("$C_PID" == "1"))
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
while [ -n "$PID" ]
do
sleep 1s
#C_PID=$(ps --no-heading $PID | wc -l)
PID=`ps -ef |grep $(echo $CLASSNAME |awk -F/ '{print $NF}') | grep -v grep | awk '{print $2}'`
done
echo "$NAME:成功结束"
okcnt=$(($okcnt+1))
else
echo "$NAME:未运行"
fi
#done
fi
done
if (($cmd2ok==0))
then
echo "command2: all|pushcode|thirdpayment|security|redis|commservice|wechat|point|useraccount|coupon|interest|experience|dealaccount|user|send|payment|sms|deal|dispatch|dealload|recv|innermsg|reward|finacial|debt"
else
echo "---------------------------本次共停止:$okcnt个服务"
fi
}
case "$1" in
start)
start "$2"
exit 1
;;
stop)
stop "$2"
;;
restart)
stop "$2"
start "$2"
;;
*)
echo "command1: start|stop|restart"
exit 1
;;
esac
---live.sh
#!/bin/bash
APP_NAME=live-1.0.0.jar
#使用说明,用来提示输入参数
usage() {
echo "Usage: sh 执行脚本.sh [start|stop|restart|status]"
exit 1
}
#检查程序是否在运行
is_exist(){
pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' `
#如果不存在返回1,存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#启动方法
start(){
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is already running. pid=${pid} ."
else
java -jar -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:logs/gc.log -XX:+PrintHeapAtGC -XX:+PrintReferenceGC -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintTenuringDistribution -XX:HeapDumpPath=./logs $APP_NAME --spring.profiles.active=prod &> /dev/null 2>&1 &
echo "${APP_NAME} is starting"
fi
}
#停止方法
stop(){
is_exist
if [ $? -eq "0" ]; then
kill -9 $pid
echo "${APP_NAME} is stopping"
else
echo "${APP_NAME} is not running"
fi
}
#输出运行状态
status(){
is_exist
if [ $? -eq "0" ]; then
echo "${APP_NAME} is running. Pid is ${pid}"
else
echo "${APP_NAME} is NOT running."
fi
}
#重启
restart(){
stop
start
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
esac
十一,问题:每次右键项目名-maven->update project 时候,项目jdk版本变了,变回1.5版本或者其他版本
问题:每次右键项目名-maven->update project 时候,项目jdk版本变了,变回1.5版本或者其他版本
解决方案一:修改maven的配置(解压目录的conf\setting.xml文件)
复制代码
<profile>
<id>jdk1.6</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.6</jdk>
</activation>
<properties>
<!-- want to use the Java 8 language features, Default 1.5 -->
<maven.compiler.source>1.6</maven.compiler.source>
<!-- want the compiled classes to be compatible with JVM 1.8, Default 1.5 -->
<maven.compiler.target>1.6</maven.compiler.target>
<!-- Version of the compiler to use, ex. "1.3", "1.5", if fork is set to true -->
<maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
</properties>
</profile>
复制代码
解决方案二:默认settigs.xml文件路径为:c:\users\xxx\.m2\settings.xml,只要把设置好的settings.xml文件复制到该目录下
解决方案三:修改项目中的pom.xml
复制代码
<plugins>
<!--
指定maven插件编译版本
1:maven:since2.0, 默认用jdk1.3来编译,maven 3.x 貌似是默认用jdk 1.5。
2:windows默认使用GBK编码,java项目经常编码为utf8,也需要在compiler插件中指出,否则中文乱码可能会出现编译错误。
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- since 2.0 -->
<version>3.7.0</version>
<configuration>
<!-- use the Java 8 language features -->
<source>1.8</source>
<!-- want the compiled classes to be compatible with JVM 1.8 -->
<target>1.8</target>
<!-- The -encoding argument for the Java compiler. -->
<encoding>UTF8</encoding>
</configuration>
</plugin>
</plugins>
十二,commons-codec是Apache开源组织提供的用于摘要运算、编码解码的包。常见的编码解码工具Base64、MD5、Hex、SHA1、DES等。
commons-codec是Apache开源组织提供的用于摘要运算、编码解码的包。常见的编码解码工具Base64、MD5、Hex、SHA1、DES等。
Base64编码
System.out.println("===============base64======================");
Base64 base64 = new Base64();
String s = base64.encodeToString("测试22222222222".getBytes());
System.out.println(s);
String s1 = new String(base64.decode(s));
System.out.println(s1);
1
2
3
4
5
6
运算结果:
===============base64======================
5rWL6K+VMjIyMjIyMjIyMjI=
测试22222222222
1
2
3
4
MD5摘要运算
System.out.println("===============MD5======================");
String result = DigestUtils.md5Hex("测试");
System.out.println(result);
1
2
3
远算结果:
===============MD5======================
db06c78d1e24cf708a14ce81c9b617ec
1
2
SHA运算和MD5是使用的同一个工具类。
- URLCodec
System.out.println("===============MD5======================");
URLCodec codec = new URLCodec();
String s = codec.encode("测试", "utf-8");
System.out.println(s);
String s1 = codec.decode(s, "utf-8");
System.out.println(s1);
1
2
3
4
5
6
7
运算结果:
===============MD5======================
%E6%B5%8B%E8%AF%95
测试
---------------------
十三,es kibana
//查询索引为 megacorp 的数据库
POST /megacorp/_search
{
"query": { "match_all": {} }
}
GET _cat/health?v
GET /_cat/nodes?v
GET /_cat/indices?v
PUT /custmer/external/1?pertty
十四,首先,如果我们git clone的下载代码的时候是连接的https://而不是[email protected] (ssh)的形式,当我们操作git pull/push到远程的时候,总是提示我们输入账号和密码才能操作成功,频繁的输入账号和密码会很麻烦,也特别烦恼。
解决办法:
git bash进入你的项目目录,输入:
git config --global credential.helper store
十五,nginx
ps -ef | grep nginx
启动nginx
/usr/sbin/nginx
nginx -s quit
stop — fast shutdown
quit — graceful shutdown
reload — reloading the configuration file
reopen — reopening the log files
linx进程发送到nginx信号
kill -s quit 1628
查看版本 及 文件路径
ngin -V
http://nginx.org/en/docs/beginners_guide.html#control