JAVA-and-J2EE
并发处理之幂等性(分布式锁机制)
星期五, 八月 18th, 2017 | JAVA-and-J2EE | 没有评论
什么是幂等性
幂等性就是指:一个幂等操作任其执行多次所产生的影响均与一次执行的影响相同。
用数学的概念表达是这样的: f(f(x)) = f(x).
就像 nx1 = n 一样, x1 就是一个幂等操作。无论是乘以多少次结果都一样。
常见的幂等性问题
幂等性问题经常会是由网络问题引起的,还有重复操作引起的。
› Continue reading
聊以纪念一起奋战的哥们
星期三, 八月 16th, 2017 | JAVA-and-J2EE | 没有评论
写下此行文字是很痛苦的,纪念一起奋战2年的哥们Leeyy同学,20170812,20170815悼.
let’s encrypt 遭遇升级错误的解决
星期四, 六月 8th, 2017 | JAVA-and-J2EE, linux | 没有评论
自动续期遭遇错误
使用的自动续期的指令是:
./letsencrypt-auto renew --email service@i5a6.com --agree-tos --force-renewal |
错误如下:
Upgrading certbot-auto 0.13.0 to 0.14.2…
Replacing certbot-auto…
Creating virtual environment…
Installing Python packages…
Installation succeeded.
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Failed to find executable apachectl in expanded PATH: /usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
Certbot doesn’t know how to automatically configure the web server on this system. However, it can still get a certificate for you. Please run “letsencrypt-auto certonly” to do so. You’ll need to manually configure your web server to use the resulting certificate.
问题分析及解决方法:
是升级到新的0.14的版本时候,有做自动重启apache 和nginx的配置,如果不指定讲默认按照 apache的配置
如果没有安装或者没有默认安装都是找不到的
解决之法 只需执行renew即可,不要再指定信息即可完成,然后再重新载入nginx即可 强制参数要带否则不会更新到远程刷新
./letsencrypt-auto renew -v --agree-tos --force-renewal |
更多的信息可以使用指令查看
./letsencrypt-auto --help |
nginx启用https的注意和妥协支持http2及IE8以下版本http
星期四, 六月 1st, 2017 | JAVA-and-J2EE, linux | 没有评论
站点启用https的支持后,IE8等低版本有一系列的问题(加载http等警告等),妥协是在IE8以下版本重定向到http去,
本文是基于nginx做的处理,支持http2协议,环境centos6.9
一: nginx-1.12.0 指定编译 openssl-1.0.2l.tar.gz及支持http2(openssl起1.0.2版本才支持)
二.重新编译nginx
1.核查版本 #sbin/nginx -V #查看版本 2.下载 #wget http://nginx.org/download/nginx-1.12.0.tar.gz #下载 #tar xzvf nginx-1.12.0.tar.gz #解压缩 #cd nginx-1.12.0 3.编译 ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-openssl=/usr/local/webserver/openssl --with-http_ssl_module --with-pcre=/ia/data/tgz/pcre-8.32 --with-http_realip_module --with-http_image_filter_module --with-http_v2_module #make #mv /usr/local/webserver/nginx/sbin/nginx /usr/local/webserver/nginx/sbin/nginx.old #移动旧版本 #cp objs/nginx /usr/local/webserver/nginx/sbin/ #复制新版本nginx过去 4.启动新的,关掉旧的 让nginx把nginx.pid改成nginx.pid.oldbin 跟着启动新的nginx # kill -USR2 `cat /usr/local/webserver/nginx/nginx.pid` 退出旧的nignx # kill -QUIT `cat /usr/local/webserver/nginx/nginx.pid.oldbin 5.升级完成。 # sbin/nginx -V |
三:(443端口)配置IE8以下版本重定向,(80端口)其他版本支持https
if ($http_user_agent !~* "MSIE [5-8].[0-9]") { rewrite (.*) https://www.iatodo.com$1 permanent; break; } if ($http_user_agent ~* "MSIE [5-8].[0-9]") { rewrite (.*) http://www.iatodo.com$1 permanent; break; } |
scrollTop doesn’t work on firefox and IE? 解决之法
星期四, 六月 1st, 2017 | html5, JAVA-and-J2EE | 没有评论
在使用jquery的 animate 的scrollTop 返回顶部的时,在chrome使用是好的,但是在IE下无效.
解决方法:
try using
$('body,html').animate({scrollTop:$(this).offset().top},800); |
instead of
$("body").animate({scrollTop:$(this).offset().top},800); |
使用certbot来进行Let’s Encrypt的ssl 配置
星期四, 五月 18th, 2017 | JAVA-and-J2EE, linux | 一条评论
之前let’s encrypt 的老版本可以参考这篇文章主要配置也都相同
//www.pomelolee.com/1562.html
基于nginx配置
安装方法
如果是CentOS 6,先执行:yum install epel-release
cd /root/
wget https://dl.eff.org/certbot-auto –no-check-certificate
chmod +x ./certbot-auto
./certbot-auto -n
接下来就会自动安装所需的依赖包。
配置nginx
1 2 3 4 5 6 7 8 | location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; root /usr/share/nginx/html; } location = /.well-known/acme-challenge/ { return 404; } |
生成证书
单域名生成证书:
1 | ./certbot-auto certonly --email username@domain --agree-tos --webroot -w /websiteroot -d domain |
多域名单目录生成单证书:
1 | ./certbot-auto certonly --email username@domain --agree-tos --webroot -w /websiteroot -d domain1 -d domain2 |
多域名多目录生成多个证书:
1 | ./certbot-auto certonly --email admin@vpser.net --agree-tos --webroot -w /websiteroot1 -d domain1 -d domain2 -w /websiteroot2 -d domain3 -d domain4 |
证书更新
› Continue reading
linux每天定时备份MySQL数据库并删除五天前的备份文件
星期五, 三月 17th, 2017 | Database, JAVA-and-J2EE | 没有评论
MYSQL定期备份常用脚本如下:
1. mkdir -p /bak/mysqlbak 2.vi bakmysql.sh 内容如下 #!/bin/bash # Name:bakmysql.sh # This is a ShellScript For Auto DB Backup and Delete old Backup # backupdir=/bak/mysqlbak time=` date +%Y%m%d%H ` /usr/local/webserver/mysql/bin/mysqldump -root-pxxx -S /tmp/mysql.sock xx| gzip > $backupdir/xx_$time.sql.gz # find $backupdir -name "xx_*.sql.gz" -type f -mtime +5 -exec rm {} \; > /dev/null 2>&1 |
git 取消修改,恢复版本常用命令
星期五, 三月 17th, 2017 | JAVA-and-J2EE, linux | 一条评论
一并说下 常用的简单指令
1. >git clone xxxx.git 2. >git status 3. >git add * 4. >git commit -m "comment" 5. >git push 6. >git pull 上述是正常情况下的使用,下面为修改等 #取消对文件的修改。还原到最近的版本,废弃本地做的修改。 git checkout -- <file> #取消已经暂存的文件。即,撤销先前"git add"的操作 git reset HEAD <file>... #修改最后一次提交。用于修改上一次的提交信息,或漏提交文件等情况。 git commit --amend #回退所有内容到上一个版本 git reset HEAD^ #回退a.c这个文件的版本到上一个版本 git reset HEAD^ a.c #向前回退到第3个版本 git reset –soft HEAD~3 #将本地的状态回退到和远程的一样 git reset –hard origin/master #回退到某个版本 git reset 089c #回退到上一次提交的状态,按照某一次的commit完全反向的进行一次commit.(代码回滚到上个版本,并提交git) git revert HEAD |
自动化git更新初步实践之crontab
星期一, 二月 20th, 2017 | JAVA-and-J2EE | 没有评论
启用crontab做自动化构建git代码步骤如下:
1. crontab -e 每5分钟执行一次输出执行结果到日志文件中
*/5 * * * * /home/wx.sh >> /home/wx.log 2>&1 |
2.踩坑wx.sh 的环境变量问题 一定要source /etc/profile 文件,其他指令也最好绝对地址
#!/bin/sh source /etc/profile cd /home/www/ /usr/local/git/bin/git pull chown -R www:www /home/www |
完毕
是时候放弃Velocity模板引擎了
星期日, 二月 5th, 2017 | JAVA-and-J2EE | 没有评论
自Spring 4.3废弃Velocity了也为我们做了技术的预测的选择条件之一.
强迫症的缘故用到过期的方法总想查看对应的原因和解决之法,发现是官方不准备支持了.
也许也是我们放弃Velocity的使用,启用其他新的模板的开端.
来自spring的描述
Velocity 1.7 dates back to 2010. Following up on the deprecation of our Velocity support in Spring 4.3, let’s not include it to begin with in the 5.0 generation.
https://jira.spring.io/browse/SPR-13795
可以选择的模板引擎:
1.使用FreeMarker(支持多类型)
2.Thymeleaf (支持HTML5之类)
3.也可以试试国产的 Beetl,oschina的对应项目链接https://www.oschina.net/p/beetl
更多优秀的模板欢迎补充.
目前的流行程度都是后端退化到只提供REST接口的JSON形式,后端模板引擎的重要性也变的低了很多.
聊以记录下,也期待Velocity2.0版本,也许不会再有……
Search
相关文章
热门文章
最新文章
文章分类
- ajax (10)
- algorithm-learn (3)
- Android (6)
- as (3)
- computer (86)
- Database (30)
- disucz (4)
- enterprise (1)
- erlang (2)
- flash (5)
- golang (3)
- html5 (18)
- ios (4)
- JAVA-and-J2EE (186)
- linux (144)
- mac (10)
- movie-music (11)
- pagemaker (36)
- php (50)
- spring-boot (2)
- Synology群晖 (2)
- Uncategorized (6)
- unity (1)
- webgame (15)
- wordpress (33)
- work-other (2)
- 低代码 (1)
- 体味生活 (40)
- 前端 (21)
- 大数据 (8)
- 游戏开发 (9)
- 爱上海 (19)
- 读书 (4)
- 软件 (3)