dubbox2.8.4例子教程一
简介
Dubbo是一个来自阿里巴巴的开源分布式服务框架,当当根据自身的需求,为Dubbo实现了一些新的功能,包括REST风格远程调用、Kryo/FST序列化等等。并将其命名为Dubbox(即Dubbo eXtensions),教程一就写生产者,教程二就写消费者
一、生产者工程结构
二、Simple.java(测试普通dubbo功能)
package bhz.entity; import java.io.Serializable;
import java.util.Map; public class Simple implements Serializable
{
private static final long serialVersionUID = -4914434736682797743L;
private String name;
private int age;
private Map<String,Integer> map;
public Simple(){ }
public Simple(String name,int age,Map<String,Integer> map){
this.name = name;
this.age = age;
this.map = map;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public int getAge() {
return age;
} public void setAge(int age) {
this.age = age;
} public Map<String, Integer> getMap() {
return map;
} public void setMap(Map<String, Integer> map) {
this.map = map;
} }
2、User.java(测试dubbox特有的rest服务)
package bhz.entity; import java.io.Serializable; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement; import org.codehaus.jackson.annotate.JsonProperty; @XmlRootElement
public class User implements Serializable
{ /**
*
*/
private static final long serialVersionUID = 1L; @NotNull
private String id; @NotNull
@Size(min = 6, max = 50)
private String name; public User() {
} public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
} }
3、dubbo-provider.xml(生产者核心配置文件)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> <!-- 引入properties配置文件 -->
<util:properties id="zcparams" location="classpath:params.properties"></util:properties> <!-- 指定dubbox生产者名称 -->
<dubbo:application name="provider" owner="programmer" organization="dubbox"/> <!-- zookeeper注册中心 -->
<dubbo:registry address="zookeeper://192.168.0.4:2181?backup=192.168.0.5:2181,192.168.0.6:2181"/> <dubbo:annotation package="bhz.service" />
<!-- kryo实现序列化-->
<dubbo:protocol name="dubbo" serialization="kryo" optimizer="bhz.utils.SerializationOptimizerImpl" /> <!--指定 rest服务 -->
<dubbo:protocol name="rest" server="tomcat" port="8888" contextpath="provider" accepts="500" /> </beans>
4、SimpleService.java
package bhz.service; import bhz.entity.Simple;
/**
* 测试普通dubbo服务
* @author Administrator
*
*/
public interface SimpleService { public String sayHello(String name); public Simple getSimple();
}
5、UserService.java
package bhz.service; import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType; import bhz.entity.User;
/**
* 功能:本类测试dubbox的rest服务
* @author Administrator
*
*/
@Path("/userService")
@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML}) // @Consumes 注释代表的是一个资源可以接受的 MIME 类型
@Produces({ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8}) //@Produces 注释代表的是一个资源可以返回的 MIME 类型
public interface UserService {
@GET
@Path("/testget")
public void testget(); @GET
@Path("/getUser")
public User getUser(); @GET
@Path("/get/{id : \\d+}")
public User getUser(@PathParam(value = "id") Integer id); @GET
@Path("/get/{id : \\d+}/{name : [a-zA-Z][0-9]}")
public User getUser(@PathParam(value = "id") Integer id, @PathParam(value = "name") String name); @POST
@Path("/testpost")
public void testpost(); @POST
@Path("/postUser")
public User postUser(User user); @POST
@Path("/post/{id}")
public User postUser(@PathParam(value = "id") String id); }
6、SimpleServiceImpl.java
package bhz.service.impl; import java.util.HashMap;
import java.util.Map; import org.springframework.stereotype.Service; import bhz.entity.Simple;
import bhz.service.SimpleService;
//spring注解
//@Service("simpleService")
/*
* dubbo注解
* interfaceClass 指定服务接口
* protocol 指定协议
* retries 重试策略
*/
@com.alibaba.dubbo.config.annotation.Service(interfaceClass=bhz.service.SimpleService.class, protocol={"dubbo"}, retries=0)
public class SimpleServiceImpl implements SimpleService{ @Override
public String sayHello(String name) {
return "hello" + name;
} @Override
public Simple getSimple() {
Map<String,Integer> map = new HashMap<String, Integer>(2);
map.put("zhang0", 1);
map.put("zhang1", 2);
return new Simple("zhang3", 21, map);
} }
7、UserServiceImpl.java
package bhz.service.impl; import bhz.entity.User;
import bhz.service.UserService; //这个是dubbo的注解(同时提供dubbo本地,和rest方式)
@com.alibaba.dubbo.config.annotation.Service(interfaceClass=bhz.service.UserService.class, protocol = {"rest", "dubbo"}, retries=0)
public class UserServiceImpl implements UserService{ public void testget() {
//http://localhost:8888/provider/userService/getUser
System.out.println("测试...get");
} public User getUser() {
System.out.println("==========");
User user = new User();
user.setId("1001");
user.setName("张三");
return user;
} public User getUser(Integer id) {
System.out.println("测试传入int类型的id: " + id);
User user = new User();
user.setId("1001");
user.setName("张三");
return user;
} public User getUser(Integer id, String name) { System.out.println("测试俩个参数:");
System.out.println("id: " + id);
System.out.println("name: " + name);
User user = new User();
user.setId("1001");
user.setName("张三");
return user;
} public void testpost() {
System.out.println("测试...post");
} public User postUser(User user) {
System.out.println(user.getName());
System.out.println("测试...postUser");
User user1 = new User();
user1.setId("1001");
user1.setName("张三");
return user1;
} public User postUser(String id) {
System.out.println(id);
System.out.println("测试...post");
User user = new User();
user.setId("1001");
user.setName("张三");
return user;
} }
8、FastJsonConvert.java(fastJson转换工具类)
package bhz.utils; import java.util.List; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature; /**
* 功能:fastJson转换工具类
* @author jacky
*
*/
public class FastJsonConvert { private static final SerializerFeature[] featuresWithNullValue = { SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullBooleanAsFalse,
SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullStringAsEmpty }; /**
* JsonString 转换 Object
*
* @param <T>
* @param data
* @param clzss
* @return
*/
public static <T> T convertJSONToObject(String data, Class<T> clzss) {
try {
T t = JSON.parseObject(data, clzss);
return t;
} catch (Exception e) {
e.printStackTrace();
return null; }
}
/**
* JsonString 转换 List<Object>
*
* @param <T>
* @param data
* @param clzss
* @return
*/
public static <T> List<T> convertJSONToArray(String data, Class<T> clzss) {
try {
List<T> t = JSON.parseArray(data, clzss);
return t;
} catch (Exception e) {
e.printStackTrace();
return null; }
} /**
* 功能:把java对象序列化成json字符串
* @param obj java实体
* @return json字符串
*/
public static String convertObjectToJSON(Object obj) {
try {
String text = JSON.toJSONString(obj);
System.out.println(text);
return text;
} catch (Exception e) {
e.printStackTrace();
return null;
}
} /**
* Object to JsonString
*
* @param <T>
* @param data
* @param valueType
* @return
*/
public static String convertObjectToJSONWithNullValue(Object obj) {
try {
String text = JSON.toJSONString(obj, featuresWithNullValue);
return text;
} catch (Exception e) {
e.printStackTrace();
return null;
}
} public static void main(String[] args) {
System.err.println(System.getProperties());
}
}
9、HttpProxy.java(发送http请求,测试rest服务的工具类)
package bhz.utils; import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.EntityBuilder;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils; public class HttpProxy {
private static class SingletonHolder {
static final HttpProxy instance = new HttpProxy();
} public static HttpProxy getInstance() {
return SingletonHolder.instance;
} private static CloseableHttpClient httpClient; private static final String CONTENT_TYPE_JSON = "application/json"; static {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(HttpProxyConfig.MAX_TOTAL_CONNECTIONS);
cm.setDefaultMaxPerRoute(HttpProxyConfig.MAX_ROUTE_CONNECTIONS); RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(HttpProxyConfig.CONNECT_TIMEOUT)
.setConnectTimeout(HttpProxyConfig.CONNECT_TIMEOUT)
.build();
//缓存
/*
CacheConfig cacheConfig = CacheConfig.custom()
.setMaxCacheEntries(1000)
.setMaxObjectSize(8192)
.build();
*/
httpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(cm)
.build();
} public static HttpClient getHttpClient() {
return httpClient;
} /**
* <B>方法名称:</B>普通请求<BR>
* <B>概要说明:</B>普通请求<BR>
* @param requestUrl 请求路径
* @param requestContent 请求内容
* @return 返回响应结果
* @throws IOException
*/
public static String post(String requestUrl, String requestContent) throws IOException {
StringEntity requestEntity = new StringEntity(requestContent, Consts.UTF_8);
return execute(requestUrl,requestEntity);
} /**
* 功能:发送json请求
* @param requestUrl 请求路径url
* @param jsonContent json字符串
* @return 返回json字符串
* @throws IOException
*/
public static String postJson(String requestUrl, String jsonContent) throws IOException {
StringEntity requestEntity = new StringEntity(jsonContent, Consts.UTF_8);
requestEntity.setContentEncoding("UTF-8");
requestEntity.setContentType(CONTENT_TYPE_JSON);
return execute(requestUrl,requestEntity);
} /**
* <B>方法名称:</B>模拟表单上传<BR>
* <B>概要说明:</B>模拟表单上传<BR>
* @param requestUrl 请求路径
* @param params 属性参数
* @return 返回响应结果
* @throws IOException
*/
public static String post(String requestUrl, Map<String, String> params) throws IOException {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
if (params != null) {
for (Map.Entry<String, String> entry : params.entrySet()) {
nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
}
EntityBuilder builder = EntityBuilder.create();
builder.setParameters(nvps);
HttpEntity httpEntity = builder.build();
return execute(requestUrl,httpEntity);
} /**
* <B>方法名称:</B>上传文件<BR>
* <B>概要说明:</B>上传文件<BR>
* @param requestUrl 请求路径
* @param localFile 文件位置
* @param username 用户名
* @param password 密码
* @return 响应信息
* @throws IOException
*/
public static String upload(String requestUrl, String localFile, String username, String password) throws IOException {
HttpPost httpPost = new HttpPost(requestUrl);
// 把文件转换成流对象FileBody
FileBody fileBody = new FileBody(new File(localFile));
StringBody usernameInp = new StringBody(username, ContentType.create("text/plain", Consts.UTF_8));
StringBody passwordInp = new StringBody(password, ContentType.create("text/plain", Consts.UTF_8));
HttpEntity httpEntity = MultipartEntityBuilder.create()
// 相当于<input type="file" name="file"/>
.addPart("file", fileBody)
// 相当于<input type="text" name="userName" value=userName>
.addPart("username", usernameInp)
.addPart("password", passwordInp)
.build();
return execute(requestUrl,httpEntity);
} /**
* 功能:执行请求方法
* @param requestUrl 请求路径Url
* @param httpEntity 封装好的http实体
* @return json字符串
* @throws IOException
*/
private static String execute(String requestUrl, HttpEntity httpEntity) throws IOException {
String result = null;
HttpPost httpPost = new HttpPost(requestUrl);
httpPost.setEntity(httpEntity);
try {
CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
try {
HttpEntity entity = httpResponse.getEntity();
if (httpResponse.getStatusLine().getReasonPhrase().equals("OK") && httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
result = EntityUtils.toString(entity, "UTF-8");
}
//进行销毁
EntityUtils.consume(entity);
} finally {
if (null != httpResponse) {
httpResponse.close();
}
}
} finally {
if (null != httpPost) {
httpPost.releaseConnection();
}
}
return result;
}
/**
* 功能:发送http的get请求
* @param requestUrl 请求url
* @return 字符串
*/
public static String get(String requestUrl){
HttpGet httpGet = new HttpGet(requestUrl);
// 执行get请求.
CloseableHttpResponse response =null;
HttpEntity entity =null;
String result =null;
try {
response = httpClient.execute(httpGet);
entity = response.getEntity();
// 打印响应状态
System.out.println(response.getStatusLine());
if (entity != null) {
// 打印响应内容长度
System.out.println("Response content length: " + entity.getContentLength());
// 打印响应内容
result = EntityUtils.toString(entity);
System.out.println("Response content: " + result);
}
System.out.println("------------------------------------");
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
} }
10、HttpProxyConfig.java
package bhz.utils; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; /**
* <br>
* 类 名: HttpCallerConfig <br>
* 描 述: http属性配置参数 <br>
*/
@Component
public class HttpProxyConfig {
/**
* 最大连接数
*/
public static int MAX_TOTAL_CONNECTIONS = 800;
/**
* 每个路由最大连接数
*/
public static int MAX_ROUTE_CONNECTIONS = 400;
/**
* 连接超时时间
*/
public static int CONNECT_TIMEOUT = 10000;
/**
* 读取超时时间
*/
public static int READ_TIMEOUT = 10000; /**
* 设置 mAX_TOTAL_CONNECTIONS
*
* @param mAX_TOTAL_CONNECTIONS
*/
@Value("#{zcparams[max_total_connections]}")
private void setMAX_TOTAL_CONNECTIONS(int mAX_TOTAL_CONNECTIONS) {
MAX_TOTAL_CONNECTIONS = mAX_TOTAL_CONNECTIONS;
} /**
* 设置 mAX_ROUTE_CONNECTIONS
*
* @param mAX_ROUTE_CONNECTIONS
*/
@Value("#{zcparams[max_total_connections]}")
private void setMAX_ROUTE_CONNECTIONS(int mAX_ROUTE_CONNECTIONS) {
MAX_ROUTE_CONNECTIONS = mAX_ROUTE_CONNECTIONS;
} /**
* 设置 cONNECT_TIMEOUT
*
* @param cONNECT_TIMEOUT
*/
@Value("#{zcparams[connect_timeout]}")
private void setCONNECT_TIMEOUT(int cONNECT_TIMEOUT) {
CONNECT_TIMEOUT = cONNECT_TIMEOUT;
} /**
* 设置 rEAD_TIMEOUT
*
* @param rEAD_TIMEOUT
*/
@Value("#{zcparams[read_timeout]}")
private void setREAD_TIMEOUT(int rEAD_TIMEOUT) {
READ_TIMEOUT = rEAD_TIMEOUT;
} }
11、SerializationOptimizerImpl.java(自定义序列化实现类)
package bhz.utils; import java.util.Collection;
import java.util.LinkedList;
import java.util.List; import bhz.entity.Simple;
import bhz.entity.User; import com.alibaba.dubbo.common.serialize.support.SerializationOptimizer; public class SerializationOptimizerImpl implements SerializationOptimizer { public Collection<Class> getSerializableClasses() {
List<Class> classes = new LinkedList<Class>();
//这里可以把所有需要进行序列化的类进行添加
classes.add(User.class);
classes.add(Simple.class);
return classes;
}
}
12、log4j.properties
log4j.rootLogger=INFO, console, file log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %p [%c] - %m%n log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.file.File=D:/002_developer/workspace_001/zcmoni.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %p [%c] - %m%n log4j.logger.org.springframework=WARN
13、params.properties
#HttpCaller
max_total_connections = 1600
max_route_connections = 1200
connect_timeout = 30000
read_timeout = 30000
14、Provider.java(启动dubbo服务类)
package bhz.test; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Provider { public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "dubbo-provider.xml" });
context.start();
System.in.read(); // 为保证服务一直开着,利用输入流的阻塞来模拟
}
}
15、HttpTest1.java(测试dubbox的rest服务类)
package bhz.test; import bhz.entity.User;
import bhz.utils.FastJsonConvert;
import bhz.utils.HttpProxy; public class HttpTest1 { public static void main(String[] args) throws Exception{
User user = new User();
user.setId("1001");
user.setName("李四");
String responseStr1 = HttpProxy.postJson("http://localhost:8888/provider/userService/postUser",
FastJsonConvert.convertObjectToJSON(user));
System.out.println("post请求返回的结果"+responseStr1);
System.out.println("========================");
String string = HttpProxy.get("http://localhost:8888/provider/userService/getUser");
System.out.println("get请求返回的结果"+string); }
}
16、测试结果
========================
HTTP/1.1 200 OK
Response content length: -1
Response content: {"id":"1001","name":"张三"}
------------------------------------
get请求返回的结果{"id":"1001","name":"张三"}
参考资料地址
http://dangdangdotcom.github.io/dubbox/
http://www.open-open.com/lib/view/open1417426480618.html
dubbox2.8.4例子教程一的更多相关文章
- CRL快速开发框架系列教程一(Code First数据表不需再关心)
本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...
- NGUI系列教程一
NGUI是Unity的一个插件,使用它来制作你的游戏UI必定将事半功倍.为什么这么说呢?首先我们说说GUI与NGUI的区别,GUI是Unity自带的绘制界面工具,它的成像原理是基于表层的,所以执行效率 ...
- Quartz教程一:使用quartz
原文链接 | 译文链接 | 翻译:nkcoder | 校对:方腾飞 本系列教程由quartz-2.2.x官方文档翻译.整理而来,希望给同样对quartz感兴趣的朋友一些参考和帮助,有任何不当或错误之处 ...
- redis学习教程一《Redis的安装和配置》
redis学习教程一<Redis的安装和配置> Redis的优点 以下是Redis的一些优点. 异常快 - Redis非常快,每秒可执行大约110000次的设置(SET)操作,每秒大约可执 ...
- Cobalt Strike使用教程一
Cobalt Strike使用教程一 0x00 简介 Cobalt Strike是一款基于java的渗透测试神器,常被业界人称为CS神器.自3.0以后已经不在使用Metasploit框架而作为 ...
- MVC5 + EF6 入门完整教程一:从0开始
第0课 从0开始 ASP.NET MVC开发模式和传统的WebForm开发模式相比,增加了很多"约定". 直接讲这些 "约定" 会让人困惑,而且东西太多容易忘记 ...
- Webpack使用教程一
过去数年间,web开发已经从包含少量JavaScript代码的应用发展到到拥有复杂JavaScript代码和代码之间依赖关系树的应用.手动维护这些复杂的代码依赖关系是很麻烦的.Webpack能分析项目 ...
- Webpack教程一
比较 如果你熟悉原来一系列的构建工具,grunt或者gulp之类的,这里有一篇webpack和他们比较的文章可以读一读. Webpack Compared 安装 先装好node和npm,因为webpa ...
- 【Cocos2d入门教程一】Cocos2d-x环境搭建
在进行Cocos2d游戏开发前 我们先来配置一下环境,我们先来准备一下工具,我们所需要的工具分别为: 1.Cocos2d引擎 2.JDK 3.SDK 4.NDK 5.ANT 6.ADT 1.下载Coc ...
随机推荐
- apacheBench对网站进行压力测试
apacheBench对网站进行压力测试 分类: 学习 2014-02-19 10:35 4154人阅读 评论(1) 收藏 举报 apacheBench压力测试 Apache Benchmark下载 ...
- 微信小程序的零食商城
概述 这是一个微信小程序的商城应用,功能包括了首页.分类.购物车.个人中心.商品列表.商品详情.订单.地址管理等 详细 代码下载:http://www.demodashi.com/demo/10353 ...
- 流动的推荐系统——兴趣Feed技术架构与实现
流动的推荐系统 我们经常谈论的推荐系统(Recommender System),从形式上看是比较“静态”的推荐,通常位于网页主要信息的周边,比如电商网站的“看了又看”.“买了又买”.这种推荐系统在大多 ...
- JavaScript中的闭包(closure)
闭包的特性 1.函数嵌套函数 2.函数内部可以引用外部的参数和变量 3.参数和变量不会被垃圾回收机制回收 闭包的缺点就是常驻内存,会增大内存使用量,使用不当很容易造成内存泄露,主要用于私有的方法和变 ...
- PHP5.3新特性
1.首先对之前滥用的语法进行了规范 众所周知PHP在语言开发过程中有一个很好的容错性,导致在数组或全局变量中包含字符串不使用引号是可以不报错的,很多业余的开发者因为懒惰而产生的安全问题十分严重,之所以 ...
- C#异常小知识
C#中异常捕获相信大家都很熟悉,经常使用的异常捕获有: 1. try{.....} catch (Exception ex) {throw ex;} 2. try{.....} catch (Exce ...
- JMeter学习笔记--详解JMeter逻辑控制器
JMeter使用逻辑控制器来决定采样器的处理顺序 简单控制器(Simple Controller):存储设备(将某些采样器归组) 循环控制器(Loop Controller:设置循环次数 仅一次控制器 ...
- DevExpress导出Excel样式设置
/// <summary> /// 导出到Excel /// </summary> /// <param name="gridControl"> ...
- ubuntu常用的一些命令
1 添加root用户 其实ubuntu在安装时已经添加了root用户,只是屏蔽了.所以只需要激活即可.打开终端ctrl+alt+t,输入sudo passwd root,然后输入要添加给root的密码 ...
- InnoDB Master Thread I/O Rate详解
一.innodb 在刷盘时要面对的问题: 1.对于innodb 的master thread 这个线程来说,它会在后台执行许多的任务,这些任务大多数都是与IO操作相关的, 比如“刷新脏页到磁盘”.“合 ...