东方骄子


  • 首页

  • 关于

  • 归档

  • 站点地图

  • 公益404

  • 搜索

MySQL5.6主从复制的配置

发表于 2017-03-25 | 分类于 数据库 |

实验环境

  1. 主库机器IP: 10.10.10.248
  2. 从库机器IP: 10.10.10.166
  3. 数据库版本: Mysql 5.6
  4. 操作系统: Ubuntu 14.04
阅读全文 »

在ubuntu14.04下安装nginx服务器

发表于 2017-03-25 | 分类于 综合 |

下载安装

1
sudo apt-get install nginx

安装完成后打开浏览器输入http://localhost, 看到下图代表安装成功:

常用命令

  1. 启动: nginx -c /etc/nginx/nginx.conf
  2. 停止: nginx -s stop
  3. 重新加载(配置): nginx -s reload
  4. 重新打开日志文件: nginx -s reopen

动静分离反向代理配置

修改/etc/nginx/sites-available/default配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
proxy_pass http://localhost:8088;
}

# 设定访问静态文件直接读取不经过tomcat
location ^~ /static/ {
proxy_pass http://localhost:8088;
root /WEB-INF/static/;
}
}

Ubuntu14.04从命令行启动

发表于 2017-03-25 | 分类于 综合 |

修改配置 /etc/default/grub

  • 注释此行:#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
  • GRUB_CMDLINE_LINUX="" 改为 GRUB_CMDLINE_LINUX="text"
  • #GRUB_TERMINAL=console 的注释干掉

更新配置

1
update-grub

重启

不出意外会从命令行启动, 意外会发生在ubuntu16.04上

Ubuntu14.04盒盖不休眠

发表于 2017-03-25 | 分类于 综合 |

修改配置 /etc/systemd/logind.conf

然后将其中的:#HandleLidSwitch=suspend 改成: HandleLidSwitch=ignore

然后重启服务:

1
sudo restart systemd-logind

shiro集成redis实现session集群共享

发表于 2017-03-25 | 分类于 Java后台 |

好处

  1. session在tomcat集群中共享(单点登录)
  2. tomcat重启后会话不丢失

实现

覆写EnterpriseCacheSessionDAO

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.kangyonggan.blog.web.shiro;

import com.kangyonggan.api.common.service.RedisService;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;

/**
* @author kangyonggan
* @since 2016/12/31
*/
public class MyEnterpriseCacheSessionDAO extends EnterpriseCacheSessionDAO {

@Autowired
private RedisService redisService;

/**
* 创建session,保存到redis数据库
*
* @param session
* @return
*/
@Override
protected Serializable doCreate(Session session) {
Serializable sessionId = super.doCreate(session);
redisService.set(sessionId.toString(), session);

return sessionId;
}

/**
* 获取session
*
* @param sessionId
* @return
*/
@Override
protected Session doReadSession(Serializable sessionId) {
// 先从缓存中获取session,如果没有再去数据库中获取
Session session = super.doReadSession(sessionId);
if (session == null) {
session = (Session) redisService.get(sessionId.toString());
}
return session;
}

/**
* 更新session的最后一次访问时间
*
* @param session
*/
@Override
protected void doUpdate(Session session) {
super.doUpdate(session);
redisService.set(session.getId().toString(), session);
}

/**
* 删除session
*
* @param session
*/
@Override
protected void doDelete(Session session) {
super.doDelete(session);
redisService.delete(session.getId().toString());
}

}

但是一般还是别在集群中使用session。

1…232425…31
康永敢

康永敢

走路自带音响

151 日志
7 分类
20 标签
RSS
Github
© 2019 康永敢
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.4