-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
426 lines (313 loc) · 37.4 KB
/
index.html
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>DayDayUp</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description">
<meta property="og:type" content="website">
<meta property="og:title" content="DayDayUp">
<meta property="og:url" content="http://li24361.github.io/index.html">
<meta property="og:site_name" content="DayDayUp">
<meta property="og:description">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="DayDayUp">
<meta name="twitter:description">
<link rel="icon" href="/favicon.png">
<!-- <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600' rel='stylesheet' type='text/css'> -->
<!-- <link href="//fonts.googleapis.com/css?family=Source+Code+Pro:400,700" rel="stylesheet" type="text/css"> -->
<link href="//fonts.useso.com/css?family=Source+Code+Pro:400,700" rel="stylesheet" type="text/css">
<link href='//fonts.useso.com/css?family=Open+Sans:300,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/style.css" type="text/css">
</head>
<body>
<div id="container">
<div id="wrap">
<header id="header">
<div id="header-outer" class="outer">
<a href="/" class="logo">DayDayUp</a>
<div id="header-inner" class="inner">
<nav id="main-nav">
<a id="main-nav-toggle" class="nav-icon"></a>
<a class="main-nav-link" href="/">Home</a>
<a class="main-nav-link" href="/archives">Archives</a>
<a class="main-nav-link" href="/about/index.html">About</a>
</nav>
<nav id="sub-nav">
<div id="search-form-wrap">
<form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"></button><input type="hidden" name="q" value="site:http://li24361.github.io"></form>
</div>
<a id="nav-search-btn" class="nav-icon" title="Search"></a>
<a id="nav-github-link" class="nav-icon" href="https://github.com/ppoffice/hexo-theme-alex" title="Fork me on GitHub"></a>
</nav>
</div>
</div>
</header>
<nav id="mobile-nav" class="off">
<a href="/" class="mobile-nav-link">Home</a>
<a href="/archives" class="mobile-nav-link">Archives</a>
<a href="/about/index.html" class="mobile-nav-link">About</a>
<div id="search-form-wrap-mobile">
<form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"></button><input type="hidden" name="q" value="site:http://li24361.github.io"></form>
</div>
</nav>
<div class="outer">
<aside id="sidebar">
<div class="widget-wrap">
<h3 class="widget-title">Archives</h3>
<div class="widget">
<ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">October 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">August 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a><span class="archive-list-count">1</span></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Recents</h3>
<div class="widget">
<ul>
<li>
<a href="/2016/10/11/MySQL-ERROR-1045-28000-Access-denied-for-user-dev-localhost-using-password-YES/">MySQL ERROR 1045 (28000): Access denied for user 'dev'@'localhost' (using password: YES)</a>
</li>
<li>
<a href="/2016/08/11/tair-install-tutorial/">Tair 安装指南</a>
</li>
<li>
<a href="/2015/03/29/hello-world/">Hello World</a>
</li>
</ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Tags</h3>
<div class="widget">
<ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/debug-mysql/">debug mysql</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/”教程“/">”教程“</a><span class="tag-list-count">1</span></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Tag Cloud</h3>
<div class="widget tagcloud">
<a href="/tags/debug-mysql/" style="font-size: NaNpx;">debug mysql</a><a href="/tags/”教程“/" style="font-size: NaNpx;">”教程“</a>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">links</h3>
<div class="widget">
<ul>
<li>
<a href="http://hexo.io">Hexo</a>
</li>
</ul>
</div>
</div>
</aside>
<section id="main">
<article id="post-MySQL-ERROR-1045-28000-Access-denied-for-user-dev-localhost-using-password-YES" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2016/10/11/MySQL-ERROR-1045-28000-Access-denied-for-user-dev-localhost-using-password-YES/" class="article-date">
<time datetime="2016-10-11T14:00:30.000Z" itemprop="datePublished">2016-10-11</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2016/10/11/MySQL-ERROR-1045-28000-Access-denied-for-user-dev-localhost-using-password-YES/">MySQL ERROR 1045 (28000): Access denied for user 'dev'@'localhost' (using password: YES)</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>新安装mysql,本机用mysql -udev -p -P3306 -h127.0.0.1登陆时,会报错<br>MySQL ERROR 1045 (28000): Access denied for user ‘dev’@’localhost’ (using password: YES)</p>
<h5 id="原因如下:">原因如下:</h5><p>因为存在匿名而且host为localhost的用户,本机登陆时,没有指定/S socket的情况下,会使用tcp连接,mysql匹配规则会先匹配排序过的host和username<br>在host都是localhost的情况下,匿名用户会”遮盖”你的任意用户,比如“[any_username]’@’%”<br>“‘dev’@’localhost’会先匹配,“’’@’%’”而不是”‘dev’@’%’</p>
<h5 id="解决方式:">解决方式:</h5><ol>
<li>使用socket方式连接,如 mysql -udev -p123 -P3306 -S/tmp/socket1.mysql</li>
<li>删除匿名用户 ,例如 “’’@’%’”</li>
</ol>
<p>以下引用自stackoverflow</p>
<p>You probably have an anonymous user ‘’@’localhost’ or ‘’@’127.0.0.1’.</p>
<p>As per the manual:</p>
<blockquote>
<p>When multiple matches are possible, the server must determine which of them to use.<br>It resolves this issue as follows: (…) When a client<br>attempts to connect, the server looks through the rows [of table<br>mysql.user] in sorted order. The server uses the first row that<br>matches the client host name and user name. (…) The server uses<br>sorting rules that order rows with the most-specific Host values<br>first. Literal host names [such as ‘localhost’] and IP addresses are<br>the most specific. Hence, such an anonymous user would “mask” any<br>other user like ‘[any_username]’@’%’ when connecting from localhost.</p>
</blockquote>
<p>‘bill’@’localhost’ does match ‘bill’@’%’, but would match (e.g.)<br>‘’@’localhost’ beforehands.</p>
<p>The recommended solution is to drop this anonymous user (this is<br>usually a good thing to do anyways).</p>
<p>Below edits are mostly irrelevant to the main question. These are only<br>meant to answer some questions raised in other comments within this<br>thread.</p>
<p>Edit 1</p>
<p>Authenticating as ‘bill’@’%’ through a socket.</p>
<pre><code>root@myhost:/home/mysql-5.5.16-linux2.6-x86<span class="emphasis">_64# ./mysql -ubill -ppass --socket=/tmp/mysql-5.5.sock
Welcome to the MySQL monitor (...)
</span><span class="header">mysql> SELECT user, host FROM mysql.user;
+------+-----------+</span>
<span class="header">| user | host |
+------+-----------+</span>
| bill | % |
| root | 127.0.0.1 |
| root | ::1 |
<span class="header">| root | localhost |
+------+-----------+</span>
4 rows in set (0.00 sec)
<span class="header">mysql> SELECT USER(), CURRENT_USER();
+----------------+----------------+</span>
<span class="header">| USER() | CURRENT_USER() |
+----------------+----------------+</span>
<span class="header">| bill@localhost | bill@% |
+----------------+----------------+</span>
1 row in set (0.02 sec)
<span class="header">mysql> SHOW VARIABLES LIKE 'skip_networking';
+-----------------+-------+</span>
<span class="header">| Variable_name | Value |
+-----------------+-------+</span>
<span class="header">| skip_networking | ON |
+-----------------+-------+</span>
1 row in set (0.00 sec)
</code></pre><p>Edit 2</p>
<p>Exact same setup, except I re-activated networking, and I now create<br>an anonymous user ‘’@’localhost’.</p>
<pre><code>root<span class="variable">@myhost</span><span class="symbol">:/home/mysql-</span><span class="number">5.5</span>.<span class="number">16</span>-linux2.<span class="number">6</span>-x86_64<span class="comment"># ./mysql</span>
<span class="constant">Welcome </span>to the <span class="constant">MySQL </span>monitor (...)
mysql> <span class="constant">CREATE USER </span><span class="string">''</span>@<span class="string">'localhost'</span> <span class="constant">IDENTIFIED BY </span><span class="string">'anotherpass'</span>;
<span class="constant">Query OK,</span> <span class="number">0</span> rows affected (<span class="number">0</span>.<span class="number">00</span> sec)
mysql> <span class="constant">Bye</span>
root<span class="variable">@myhost</span><span class="symbol">:/home/mysql-</span><span class="number">5.5</span>.<span class="number">16</span>-linux2.<span class="number">6</span>-x86_64<span class="comment"># ./mysql -ubill -ppass \</span>
--socket=<span class="regexp">/tmp/mysql</span>-<span class="number">5.5</span>.sock
<span class="constant">ERROR </span><span class="number">1045</span> (<span class="number">28000</span>)<span class="symbol">:</span> <span class="constant">Access </span>denied <span class="keyword">for</span> user <span class="string">'bill'</span>@<span class="string">'localhost'</span> (using <span class="symbol">password:</span> <span class="constant">YES)</span>
root<span class="variable">@myhost</span><span class="symbol">:/home/mysql-</span><span class="number">5.5</span>.<span class="number">16</span>-linux2.<span class="number">6</span>-x86_64<span class="comment"># ./mysql -ubill -ppass \</span>
-h127.<span class="number">0</span>.<span class="number">0</span>.<span class="number">1</span> --protocol=<span class="constant">TCP</span>
<span class="constant">ERROR </span><span class="number">1045</span> (<span class="number">28000</span>)<span class="symbol">:</span> <span class="constant">Access </span>denied <span class="keyword">for</span> user <span class="string">'bill'</span>@<span class="string">'localhost'</span> (using <span class="symbol">password:</span> <span class="constant">YES)</span>
root<span class="variable">@myhost</span><span class="symbol">:/home/mysql-</span><span class="number">5.5</span>.<span class="number">16</span>-linux2.<span class="number">6</span>-x86_64<span class="comment"># ./mysql -ubill -ppass \</span>
-hlocalhost --protocol=<span class="constant">TCP</span>
<span class="constant">ERROR </span><span class="number">1045</span> (<span class="number">28000</span>)<span class="symbol">:</span> <span class="constant">Access </span>denied <span class="keyword">for</span> user <span class="string">'bill'</span>@<span class="string">'localhost'</span> (using <span class="symbol">password:</span> <span class="constant">YES)</span>
</code></pre><p>Edit 3</p>
<p>Same situation as in edit 2, now providing the anonymous user’s<br>password.</p>
<pre><code>root@myhost:/home/mysql-5.5.16-linux2.6-x86<span class="emphasis">_64# ./mysql -ubill -panotherpass -hlocalhost
Welcome to the MySQL monitor (...)
</span><span class="header">mysql> SELECT USER(), CURRENT_USER();
+----------------+----------------+</span>
<span class="header">| USER() | CURRENT_USER() |
+----------------+----------------+</span>
<span class="header">| bill@localhost | @localhost |
+----------------+----------------+</span>
1 row in set (0.01 sec)
</code></pre><p>Conclusion 1, from edit 1: One can authenticate as ‘bill’@’%’through a<br>socket.</p>
<p>Conclusion 2, from edit 2: Whether one connects through TCP or through<br>a socket has no impact on the authentication process (except one<br>cannot connect as anyone else but ‘something’@’localhost’ through a<br>socket, obviously).</p>
<p>Conclusion 3, from edit 3: Although I specified -ubill, I have been<br>granted access as an anonymous user. This is because of the “sorting<br>rules” advised above. Notice that in most default installations, a<br>no-password, anonymous user exists (and should be secured/removed).</p>
</div>
<footer class="article-footer">
<a data-url="http://li24361.github.io/2016/10/11/MySQL-ERROR-1045-28000-Access-denied-for-user-dev-localhost-using-password-YES/" data-id="ciu5k6ri90000wsuf5jnx4d9g" class="article-share-link">Share</a>
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/debug-mysql/">debug mysql</a></li></ul>
</footer>
</div>
</article>
<article id="post-tair-install-tutorial" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2016/08/11/tair-install-tutorial/" class="article-date">
<time datetime="2016-08-11T13:41:01.000Z" itemprop="datePublished">2016-08-11</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2016/08/11/tair-install-tutorial/">Tair 安装指南</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h3 id="准备工作">准备工作</h3><ol>
<li>先配置 yum 源,这里直接用阿里云的 yum 源即可。配置文档见:<a href="http://mirrors.aliyun.com/help/centos" target="_blank" rel="external">http://mirrors.aliyun.com/help/centos</a> ,另外这个 minimal 版本是没有 wget 的,可以 yum 装下,我干脆直接把相关文件配置贴过去了(首次用 yum 从官方源下载一次列表文件够慢的)。<br>配置好之后可以执行yum update再重启让新内核生效(非必要,建议更新到最新版本)。</li>
<li><p>接下来是 Tair 的安装和配置,先用 yum 安装依赖包和构件工具,直接执行:</p>
<figure class="highlight brainfuck"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">yum</span> <span class="comment">install</span> <span class="literal">-</span><span class="comment">y</span> <span class="comment">svn</span> <span class="comment">automake</span> <span class="comment">autoconf</span> <span class="comment">libtool</span> <span class="comment">vim</span> <span class="comment">gcc</span> <span class="comment">gcc</span><span class="literal">-</span><span class="comment">c</span><span class="literal">+</span><span class="literal">+</span> <span class="comment">gdb</span> <span class="comment">zlib</span><span class="literal">-</span><span class="comment">devel</span> <span class="comment">boost</span><span class="literal">-</span><span class="comment">devel</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>检出tb-common-utils代码 </p>
<figure class="highlight elixir"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">svn co -r <span class="number">18</span> <span class="symbol">http:</span>/<span class="regexp">/code.taobao.org/svn</span><span class="regexp">/tb-common-utils/trunk</span> tb-common-utils</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p><strong>注意: 这里不要checkout最新版本,version18以后的修改导致部分接口不能前向兼容。</strong></p>
<ol>
<li>检出tair<figure class="highlight elixir"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">svn checkout <span class="symbol">http:</span>/<span class="regexp">/code.taobao.org/svn</span><span class="regexp">/tair/trunk</span><span class="regexp">/ tair</span></span><br></pre></td></tr></table></figure>
</li>
</ol>
<hr>
<h4 id="安装工作">安装工作</h4><ol>
<li><p>设置库文件的安装目录 (我直接加到 ~/.bashrc 了,别忘了执行 source ~/.bashrc)<br>路径按照实际安装的路径进行修改</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">export</span> TBLIB_ROOT=<span class="string">"/root/lib"</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>编译安装 tb-common-utils</p>
<figure class="highlight stata"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cd</span> ~/tb-common-utils</span><br><span class="line">./build.<span class="keyword">sh</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>编译安装 Tair </p>
<figure class="highlight vim"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cd</span> ~/tair</span><br><span class="line">./bootstrap.<span class="keyword">sh</span></span><br><span class="line">./configure --with-release=yes</span><br><span class="line"><span class="keyword">make</span></span><br><span class="line"><span class="keyword">make</span> install</span><br></pre></td></tr></table></figure>
</li>
<li><p>复制配置文件</p>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">cd ~/tair_bin</span><br><span class="line">cp etc/configserver<span class="class">.conf</span><span class="class">.default</span> etc/configserver<span class="class">.conf</span></span><br><span class="line">cp etc/group<span class="class">.conf</span><span class="class">.default</span> etc/group<span class="class">.conf</span></span><br><span class="line">cp etc/dataserver<span class="class">.conf</span><span class="class">.default</span> etc/dataserver.conf</span><br></pre></td></tr></table></figure>
</li>
<li><p>查看本机ip和网卡,如下图,</p>
<figure class="highlight groovy"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">>[admin<span class="annotation">@hry</span>_server4 ~]$ ip a</span><br><span class="line"> ……中间省略……</span><br><span class="line"><span class="number">6</span>: <span class="string">bond0:</span> <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu <span class="number">1500</span> qdisc noqueue state UP </span><br><span class="line"> link/ether <span class="string">c8:</span><span class="number">1</span><span class="string">f:</span><span class="number">66</span>:<span class="string">e5:</span><span class="number">6</span><span class="string">c:</span><span class="number">25</span> brd <span class="string">ff:</span><span class="string">ff:</span><span class="string">ff:</span><span class="string">ff:</span><span class="string">ff:</span>ff</span><br><span class="line"> inet <span class="number">10.135</span><span class="number">.111</span><span class="number">.22</span>/<span class="number">24</span> brd <span class="number">10.135</span><span class="number">.111</span><span class="number">.255</span> scope global bond0</span><br><span class="line"> inet6 <span class="string">fe80:</span>:<span class="string">ca1f:</span><span class="number">66</span><span class="string">ff:</span><span class="string">fee5:</span><span class="number">6</span>c25/<span class="number">64</span> scope link </span><br><span class="line"> valid_lft forever preferred_lft forever</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>可知 <strong>本机ip:10.135.111.22 网卡bond0</strong></p>
<ol>
<li>修改配置文件<h4 id="configserver-conf">configserver.conf</h4><figure class="highlight nix"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[public]</span><br><span class="line"><span class="variable">config_server=</span><span class="number">10.135</span>.<span class="number">111.22</span>:<span class="number">5198</span> <span class="comment">#设置为本机ip</span></span><br><span class="line"><span class="comment">#config_server=192.168.1.2:5198 #单机需要注释第二个</span></span><br><span class="line">[configserver]</span><br><span class="line"><span class="variable">port=</span><span class="number">5198</span></span><br><span class="line"><span class="variable">log_file=</span>logs/config.log</span><br><span class="line"><span class="variable">pid_file=</span>logs/config.pid</span><br><span class="line"><span class="variable">log_level=</span>warn</span><br><span class="line"><span class="variable">group_file=</span>etc/group.conf</span><br><span class="line"><span class="variable">data_dir=</span>data/data</span><br><span class="line"><span class="variable">dev_name=</span>bond0 <span class="comment">#这里改成上面查到的网卡</span></span><br></pre></td></tr></table></figure>
</li>
</ol>
<h4 id="group-conf">group.conf</h4><figure class="highlight vala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">~</span><br><span class="line">[admin@hry_server4 etc]$ vi group.conf</span><br><span class="line"></span><br><span class="line"><span class="preprocessor">#group name</span></span><br><span class="line">[group_1]</span><br><span class="line"><span class="preprocessor"># data move is 1 means when some data serve down, the migrating will be start.</span></span><br><span class="line"><span class="preprocessor"># default value is 0</span></span><br><span class="line">_data_move=<span class="number">0</span></span><br><span class="line"><span class="preprocessor">#_min_data_server_count: when data servers left in a group less than this value, config server will stop serve for this group</span></span><br><span class="line"><span class="preprocessor">#default value is copy count.</span></span><br><span class="line">_min_data_server_count=<span class="number">1</span></span><br><span class="line"><span class="preprocessor">#_plugIns_list=libStaticPlugIn.so</span></span><br><span class="line">_build_strategy=<span class="number">1</span> #<span class="number">1</span> normal <span class="number">2</span> rack</span><br><span class="line">_build_diff_ratio=<span class="number">0.6</span> #how much difference is allowd between different rack</span><br><span class="line"><span class="preprocessor"># diff_ratio = |data_sever_count_in_rack1 - data_server_count_in_rack2| / max (data_sever_count_in_rack1, data_server_count_in_rack2)</span></span><br><span class="line"><span class="preprocessor"># diff_ration must less than _build_diff_ratio</span></span><br><span class="line">_pos_mask=<span class="number">65535</span> # <span class="number">65535</span> is <span class="number">0xffff</span> <span class="keyword">this</span> will be used to gernerate rack info. <span class="number">64</span> bit serverId & _pos_mask is the rack info,</span><br><span class="line">_copy_count=<span class="number">1</span></span><br><span class="line">_bucket_number=<span class="number">1023</span></span><br><span class="line"><span class="preprocessor"># accept ds strategy. 1 means accept ds automatically</span></span><br><span class="line">_accept_strategy=<span class="number">1</span></span><br><span class="line"></span><br><span class="line"><span class="preprocessor"># data center A</span></span><br><span class="line">_server_list=<span class="number">10.135</span><span class="number">.111</span><span class="number">.22</span>:<span class="number">5191</span> #修改为本机ip,其余地址注释掉</span><br><span class="line"><span class="preprocessor">#_server_list=192.168.1.2:5191</span></span><br><span class="line"><span class="preprocessor">#_server_list=192.168.1.3:5191</span></span><br><span class="line"><span class="preprocessor">#_server_list=192.168.1.4:5191</span></span><br><span class="line"></span><br><span class="line"><span class="preprocessor"># data center B</span></span><br><span class="line"><span class="preprocessor">#_server_list=192.168.2.1:5191</span></span><br><span class="line"><span class="preprocessor">#_server_list=192.168.2.2:5191</span></span><br><span class="line"><span class="preprocessor">#_server_list=192.168.2.3:5191</span></span><br><span class="line"><span class="preprocessor">#_server_list=192.168.2.4:5191</span></span><br><span class="line"></span><br><span class="line"><span class="preprocessor">#quota info</span></span><br><span class="line"><span class="preprocessor">#这里将0这个namespace(area)的配额稍微改大了一点,之后的客户端使用namespace 0进行读写访问就行</span></span><br><span class="line">_areaCapacity_list=<span class="number">0</span>,<span class="number">1124000</span>;</span><br></pre></td></tr></table></figure>
<h4 id="dataserver-conf">dataserver.conf</h4><figure class="highlight vala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">[<span class="keyword">public</span>]</span><br><span class="line">config_server=<span class="number">10.135</span><span class="number">.111</span><span class="number">.22</span>:<span class="number">5198</span></span><br><span class="line"><span class="preprocessor">#config_server=192.168.1.2:5198</span></span><br><span class="line">……</span><br><span class="line"><span class="preprocessor">#</span></span><br><span class="line"><span class="preprocessor">#mdb size in MB</span></span><br><span class="line"><span class="preprocessor">#建议设置2^n倍数大,但是最小512MB</span></span><br><span class="line">slab_mem_size=<span class="number">1024</span> </span><br><span class="line">……</span><br><span class="line">dev_name=bond0#这里一定要修改为本机网卡,否则否则会在put的时候,报 put: server can not work</span><br></pre></td></tr></table></figure>
<ol>
<li>最后是启动步骤,如果报错,则为配置有问题<figure class="highlight vala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="preprocessor"># 设置 tmpfs 运行大小</span></span><br><span class="line">./set_shm.sh</span><br><span class="line"><span class="preprocessor"># 启动 DataServer</span></span><br><span class="line">./tair.sh start_ds</span><br><span class="line"><span class="preprocessor"># 启动 ConfigServer</span></span><br><span class="line">./tair.sh start_cs</span><br><span class="line"><span class="preprocessor"># 检查下进程在否</span></span><br><span class="line">pgrep -lf tair</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>结果如下,大功告成:<br><img src="http://obq9fd5ou.bkt.clouddn.com/16-8-11/96152199.jpg" alt=""></p>
<ol>
<li>连接测试<br><img src="http://obq9fd5ou.bkt.clouddn.com/16-8-11/88089514.jpg" alt=""><br>java端使用:<figure class="highlight processing"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"> <span class="keyword">public</span> TairOperatorImpl(<span class="keyword">String</span> masterConfigServer,</span><br><span class="line"> <span class="keyword">String</span> slaveConfigServer,</span><br><span class="line"> <span class="keyword">String</span> groupName,</span><br><span class="line"> <span class="built_in">int</span> namespace) {</span><br><span class="line"> System.out.<span class="built_in">println</span>(<span class="string">"init tair manager"</span>);</span><br><span class="line"> <span class="keyword">this</span>.namespace = namespace;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 创建config server列表</span></span><br><span class="line"> List<<span class="keyword">String</span>> confServers = <span class="keyword">new</span> ArrayList<<span class="keyword">String</span>>();</span><br><span class="line"> confServers.<span class="built_in">add</span>(masterConfigServer);</span><br><span class="line"><span class="comment">// confServers.add(slaveConfigServer); // 可选</span></span><br><span class="line"></span><br><span class="line"> <span class="comment">// 创建客户端实例</span></span><br><span class="line"> tairManager = <span class="keyword">new</span> DefaultTairManager();</span><br><span class="line"> tairManager.setConfigServerList(confServers);</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 设置组名</span></span><br><span class="line"> tairManager.setGroupName(groupName);</span><br><span class="line"> <span class="comment">// 初始化客户端</span></span><br><span class="line"> tairManager.init();</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> <span class="comment">//调用</span></span><br><span class="line"> TairOperatorImpl tairOperator = <span class="keyword">new</span> TairOperatorImpl(<span class="string">"10.135.111.22:5198"</span>, <span class="string">"10.135.111.22:5198"</span>,<span class="string">"group_1"</span>,<span class="string">"0"</span>);</span><br></pre></td></tr></table></figure>
</li>
</ol>
<blockquote>
<p>参考资料:<a href="https://bbs.aliyun.com/read/279531.html?spm=5176.bbsl254.0.0.9lyObN" target="_blank" rel="external">https://bbs.aliyun.com/read/279531.html?spm=5176.bbsl254.0.0.9lyObN</a></p>
</blockquote>
</div>
<footer class="article-footer">
<a data-url="http://li24361.github.io/2016/08/11/tair-install-tutorial/" data-id="ciu5k6rio0003wsufpxlqalzh" class="article-share-link">Share</a>
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/”教程“/">”教程“</a></li></ul>
</footer>
</div>
</article>
<article id="post-hello-world" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-meta">
<a href="/2015/03/29/hello-world/" class="article-date">
<time datetime="2015-03-29T10:16:23.823Z" itemprop="datePublished">2015-03-29</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2015/03/29/hello-world/">Hello World</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>Welcome to <a href="http://hexo.io/" target="_blank" rel="external">Hexo</a>! This is your very first post. Check <a href="http://hexo.io/docs/" target="_blank" rel="external">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="http://hexo.io/docs/troubleshooting.html" target="_blank" rel="external">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="external">GitHub</a>.</p>
<h2 id="Quick_Start">Quick Start</h2><h3 id="Create_a_new_post">Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/writing.html" target="_blank" rel="external">Writing</a></p>
<h3 id="Run_server">Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/server.html" target="_blank" rel="external">Server</a></p>
<h3 id="Generate_static_files">Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/generating.html" target="_blank" rel="external">Generating</a></p>
<h3 id="Deploy_to_remote_sites">Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="http://hexo.io/docs/deployment.html" target="_blank" rel="external">Deployment</a></p>
</div>
<footer class="article-footer">
<a data-url="http://li24361.github.io/2015/03/29/hello-world/" data-id="ciu5k6rir0006wsuf2vrewlz4" class="article-share-link">Share</a>
</footer>
</div>
</article>
</section>
</div>
<footer id="footer">
<div class="outer">
<div id="footer-info" class="inner">
<a href="/" class="logo">DayDayUp</a>
© 2016 Beck Li<br>
Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
</div>
</div>
</footer>
</div>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/jquery.scrollLoading.js" type="text/javascript"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js" type="text/javascript"></script>
<script src="/js/script.js" type="text/javascript"></script>
</div>
</body>
</html>