<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by wano on Medium]]></title>
        <description><![CDATA[Stories by wano on Medium]]></description>
        <link>https://medium.com/@wano1010?source=rss-8c00138e40c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2SwWHKm47GBfzIBb.</url>
            <title>Stories by wano on Medium</title>
            <link>https://medium.com/@wano1010?source=rss-8c00138e40c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:55:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wano1010/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Design Patterns: Cache Aside]]></title>
            <link>https://medium.com/@wano1010/design-patterns-cache-aside-990e89328057?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/990e89328057</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[cache]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Sat, 28 Mar 2020 18:14:45 GMT</pubDate>
            <atom:updated>2020-03-28T18:33:43.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Cache Aside được áp dụng cho các application hoạt động phụ thuộc nhiều vào data store và có lượng data lớn. Sử dụng Cache Aside giúp tăng performance của application và dễ dàng hơn trong việc maintain persistency giữa lớp cache và data store.</p><p><strong>Mô Hình</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5BkC3fcxxaBT0JQ7vXFHcQ.png" /></figure><ul><li>Application đọc data từ cache, nếu data có trong cache thì application sẽ load data từ cache mà không hit vào Data store</li><li>Nếu data không có trong cache, Application sẽ hit vào Data Store để lấy data. Sau khi được load từ Data Store, data sẽ được save và Cache.</li></ul><p>Một số điểm cần lưu ý khi áp dụng mô hình Cache Aside</p><p><strong>1. LifeCycle của cached data</strong></p><ul><li>Nếu data được cache trong thời gian quá ngắn thì application sẽ vẫn thường xuyên hit vào data store để lấy data</li><li>Nếu data được cache trong thời gian quá dài, số lượng cached data sẽ lớn và tính up-to-date bị ảnh hưởng.</li></ul><p>Vì vậy, cần xác định thời gian expired cho cached data phù hợp.</p><p><strong>2. Local caching</strong></p><p>Data được cache sẽ được lưu trữ ở local hoặc in-memory, dễ gây ra vấn đề mất dữ liệu khi xảy ra vấn đề với server. Để tăng tính an toàn và tăng tấc độ truy xuất data, các distributed application không nên sử dụng mô hình này, nên sử dụng shared hoặc distributed caching.</p><p><strong>3. Vấn đề đảm bảo đồng bộ dữ liệu giữa cache layer và data store</strong></p><p><strong>4. Evicting data<br></strong>Caches thường không lớn như data store, nên khi cache bị đầy, một số data sẽ bị mất/không được cache. Vì vậy, cần config eviction policy phù hợp với data và cache system.</p><p><strong>5. Chỉ nên cache những data thường xuyên được truy xuất</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=990e89328057" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Redis] Redis Sentinel hoạt động như thế nào?]]></title>
            <link>https://medium.com/@wano1010/redis-redis-sentinel-ho%E1%BA%A1t-%C4%91%E1%BB%99ng-nh%C6%B0-th%E1%BA%BF-n%C3%A0o-6ec501312bd8?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ec501312bd8</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[sysadmin]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Mon, 06 May 2019 16:49:26 GMT</pubDate>
            <atom:updated>2020-04-14T04:55:50.922Z</atom:updated>
            <content:encoded><![CDATA[<p>Redis sentinel cung cấp một giải pháp HA cho cụm triển khai Redis. Nghĩa là, khi có một hoặc một số Redis instance down, thì cụm Redis của bạn vẫn hoạt động tốt.</p><p>Redis Sentinel được thiết kế để monitor và quản lý các Redis instances bằng cách thực hiện các task sau:</p><ul><li><strong>Monitoring</strong>: Sentinel check các master và slave nodes theo định kì để đảm bảo các node này luôn luôn hoạt động tốt.</li><li><strong>Notification</strong>: Sentinel có thể send các notification alert khi có một redis instance failure thông tqua một API</li><li><strong>Automatic failover:</strong> Nếu một Master bị fail, Sentinel sẽ khởi tạo một “<strong>Failover</strong>” process:</li></ul><p>- Pick một running slave và promote SLAVE này lên làm Master</p><p>- Reconfigured các slaves còn lại thành slave của Master mới</p><p>- Reconfigured tất cả các Sentinel monitor Master mới</p><ul><li><strong>Configuration provider</strong>: Sentinel hoạt động như một “<strong>source of authority for client’s service discovery</strong>”. Client connect tới Sentinel để hỏi về địa chỉ của Current Redis Master, nếu một failover xảy ra, Sentinel sẽ report về cho client address của latest Redis Master (mới nhất).</li></ul><blockquote>Sentinel is a <strong>robust distributed system</strong></blockquote><p>Các Sentinel liên lạc với nhau, và cùng nhau quyết định rằng một “Master node là unreachable”. Quyết định được đưa ra dựa vào <strong>quorum value</strong></p><p>Chú ý rằng, <strong>quorum value</strong> phải lớn hơn quá bán thì mới có ý nghĩa. Vì vậy, khi thiết kế, thường chọn số node cài sentinel là số lẻ: 3,5,7 …</p><blockquote>Quorum Value</blockquote><p>Là số lượng Sentinel đồng ý rằng Master node là unreachable. Giá trị này chỉ được dùng để detect failure.</p><h3>How Redis offers High Availability and Automatic Failover ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gszoEBW0lupbMDDGGgYOPA.png" /></figure><p>Khi Redis Master down, các Sentinel sẽ liên lạc với nhau và start một cuộc họp bàn:</p><ul><li>Nếu số lượng Sentinel đồng ý promote một Slave lên làm Master thì quá trình Failover sẽ được start, một Slave sẽ trở thành Master mới. Các redis instance còn laị sẽ được reconfigure thành các slave của master mới.</li><li>Nếu số lượng Sentinel đồng ý promote một Slave lên làm Master nhỏ hơn <strong>quá bán</strong> thì quá trình <strong>Failover</strong> sẽ không diễn ra, hệ thống redis sẽ ngừng hoạt động do không có master mới.</li></ul><h3>Mô hình Redis Sentinel 2 Instances → Đừng bao giờ làm điều này :)</h3><pre>+----+         +----+<br>| M1 |---------| R1 |<br>| S1 |         | S2 |<br>+----+         +----+<br><br>Configuration: quorum = 1</pre><ul><li>Instance1: Master M1 và sentinel S1</li><li>Instane2: Slave R1 và sentinel S2</li></ul><p><strong>Chuyện gì sẽ xảy ra:</strong></p><ul><li>Trong trường hợp Master M1 down, Sentinel S1 và Sentinel S2 Sẽ đồng ý và promote Slave R1 lên thành Master. Trong trường hợp này, số sentinel đồng ý là 2 (quá bán) nên quá trình failover sẽ được start.</li><li>Tuy nhiên, trong các trường hợp thông thường, khi instance 1 gặp sự cố, nghĩa là cả M1 và S1 đều down, khi ấy S2 không thể tương tác với S1, số lượng sentinel đồng ý promote R1 lên làm master là 1 =&gt; nhỏ hơn quá bán =&gt; quá trình failover không được start =&gt; hệ thống Redis sập (do không có slave nào được promote lên master thay thế).</li></ul><p>Vì vậy, Mô hình Sentinel nên được setup trên ÍT NHẤT 3 instances, và thường được chọn là số lẻ.</p><h3>Mô hình Redis Sentinel 3 instances</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*7AfXYNub6eC9j21-JZ-f-A.png" /><figcaption><strong>Mô hình Redis 3 Instances</strong></figcaption></figure><p><strong>Mô hình:</strong></p><pre>Master Node: 10.140.0.11</pre><pre>slave Node: 10.148.0.27</pre><pre>Slave Node: 10.140.0.10</pre><p>Trên mỗi node:</p><pre>sudo apt-get update <br>sudo apt-get install build-essential tcl<br>sudo apt-get install libjemalloc-dev (Optional)<br>curl -O <a href="http://download.redis.io/redis-stable.tar.gz">http://download.redis.io/redis-stable.tar.gz</a><br>tar xzvf redis-stable.tar.gz<br>cd redis-stable</pre><p>Config redis master node:</p><pre>protected-mode no<br>port 6379<br>daemonize yes<br>pidfile “/var/run/redis.pid”<br>loglevel notice<br>logfile “/var/log/redis/redis.log”<br>databases 16</pre><p>Config redis slave nodes:</p><pre>protected-mode no<br>port 6379<br>daemonize yes<br>pidfile “/var/run/redis.pid”<br>loglevel notice<br>logfile “/var/log/redis/redis.log”<br>databases 16</pre><pre><strong>slaveof </strong>10.140.0.11<strong> 6379</strong></pre><p>Start Redis-server process:</p><pre>./src/redis-server redis.conf</pre><p>khi đó, check trên master node:</p><pre>127.0.0.1:6379&gt; info replication</pre><pre># Replication</pre><pre><strong>role:master</strong></pre><pre><strong>connected_slaves:2</strong></pre><pre>slave0:ip=10.148.0.27,port=6379,state=online,offset=15851,lag=1</pre><pre>slave1:ip=10.140.0.10,port=6379,state=online,offset=15851,lag=1</pre><pre>master_replid:adcd85e20eebebd1369fab9543fa10ba9f65cab0</pre><pre>master_replid2:0000000000000000000000000000000000000000</pre><pre>master_repl_offset:15851</pre><pre>second_repl_offset:-1</pre><pre>repl_backlog_active:1</pre><pre>repl_backlog_size:1048576</pre><pre>repl_backlog_first_byte_offset:1</pre><pre>repl_backlog_histlen:15851</pre><p>Trên slave node:</p><pre>127.0.0.1:6379&gt; info replication</pre><pre># Replication</pre><pre><strong>role:slave</strong></pre><pre><strong>master_host:10.140.0.11</strong></pre><pre><strong>master_port:6379</strong></pre><pre>master_link_status:up</pre><pre>master_last_io_seconds_ago:1</pre><pre>master_sync_in_progress:0</pre><pre>slave_repl_offset:12084</pre><pre>slave_priority:100</pre><pre>slave_read_only:1</pre><pre>connected_slaves:0</pre><pre>master_replid:adcd85e20eebebd1369fab9543fa10ba9f65cab0</pre><pre>master_replid2:0000000000000000000000000000000000000000</pre><pre>master_repl_offset:12084</pre><pre>second_repl_offset:-1</pre><pre>repl_backlog_active:1</pre><pre>repl_backlog_size:1048576</pre><pre>repl_backlog_first_byte_offset:1</pre><pre>repl_backlog_histlen:12084</pre><p>Data được sync từ Master sang các Slave node</p><ul><li>Log trên Slave node:</li></ul><pre>root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.</pre><pre>24162:S 06 May 2019 08:07:49.355 * DB loaded from disk: 0.000 seconds</pre><pre>24162:S 06 May 2019 08:07:49.355 * Before turning into a replica, using my master parameters to synthesize a cached master: I may be able to synchronize with the new master with just a partial transfer.</pre><pre>24162:S 06 May 2019 08:07:49.355 * Ready to accept connections</pre><pre>24162:S 06 May 2019 08:07:49.356 * Connecting to MASTER 10.140.0.11:6379</pre><pre>24162:S 06 May 2019 08:07:49.356 * MASTER &lt;-&gt; REPLICA sync started</pre><pre>24162:S 06 May 2019 08:07:49.405 # Error condition on socket for SYNC: Connection refused</pre><pre>24162:S 06 May 2019 08:07:50.359 * Connecting to MASTER 10.140.0.11:6379</pre><pre>24162:S 06 May 2019 08:07:50.359 * MASTER &lt;-&gt; REPLICA sync started</pre><pre>24162:S 06 May 2019 08:07:50.408 # Error condition on socket for SYNC: Connection refused</pre><pre>24162:S 06 May 2019 08:07:51.362 * Connecting to MASTER 10.140.0.11:6379</pre><pre>24162:S 06 May 2019 08:07:51.363 * MASTER &lt;-&gt; REPLICA sync started</pre><pre>24162:S 06 May 2019 08:07:51.411 # Error condition on socket for SYNC: Connection refused</pre><pre>24162:S 06 May 2019 08:07:52.367 * Connecting to MASTER 10.140.0.11:6379</pre><pre>24162:S 06 May 2019 08:07:52.368 * MASTER &lt;-&gt; REPLICA sync started</pre><pre>24162:S 06 May 2019 08:07:52.416 * Non blocking connect for SYNC fired the event.</pre><pre>24162:S 06 May 2019 08:07:52.465 * Master replied to PING, replication can continue...</pre><pre>24162:S 06 May 2019 08:07:52.563 * Trying a partial resynchronization (request 9c3a5c583cb71c9a4fd59fab91edda0c8d3af61a:1).</pre><pre>24162:S 06 May 2019 08:07:52.613 * Full resync from master: adcd85e20eebebd1369fab9543fa10ba9f65cab0:0</pre><pre>24162:S 06 May 2019 08:07:52.614 * Discarding previously cached master state.</pre><pre>24162:S 06 May 2019 08:07:52.634 * MASTER &lt;-&gt; REPLICA sync: receiving 175 bytes from master</pre><pre>24162:S 06 May 2019 08:07:52.634 * MASTER &lt;-&gt; REPLICA sync: Flushing old data</pre><pre>24162:S 06 May 2019 08:07:52.634 * MASTER &lt;-&gt; REPLICA sync: Loading DB in memory</pre><pre>24162:S 06 May 2019 08:07:52.634 * MASTER &lt;-&gt; REPLICA sync: Finished with success</pre><ul><li>Log trên master Node:</li></ul><pre>26581:M 06 May 2019 08:07:51.504 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.</pre><pre>26581:M 06 May 2019 08:07:51.504 # Server initialized</pre><pre>26581:M 06 May 2019 08:07:51.504 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add &#39;vm.overcommit_memory = 1&#39; to /etc/sysctl.conf and then reboot or run the command &#39;sysctl vm.overcommit_memory=1&#39; for this to take effect.</pre><pre>26581:M 06 May 2019 08:07:51.505 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command &#39;echo never &gt; /sys/kernel/mm/transparent_hugepage/enabled&#39; as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.</pre><pre>26581:M 06 May 2019 08:07:51.505 * DB loaded from disk: 0.000 seconds</pre><pre>26581:M 06 May 2019 08:07:51.505 * Ready to accept connections</pre><pre>26581:M 06 May 2019 08:07:52.587 * Replica 10.148.0.27:6379 asks for synchronization</pre><pre>26581:M 06 May 2019 08:07:52.588 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for &#39;9c3a5c583cb71c9a4fd59fab91edda0c8d3af61a&#39;, my replication IDs are &#39;2981f35caad816d7bd89381f503a669f000926f1&#39; and &#39;0000000000000000000000000000000000000000&#39;)</pre><pre>26581:M 06 May 2019 08:07:52.588 * Starting BGSAVE for SYNC with target: disk</pre><pre>26581:M 06 May 2019 08:07:52.588 * Background saving started by pid 26597</pre><pre>26597:C 06 May 2019 08:07:52.592 * DB saved on disk</pre><pre>26597:C 06 May 2019 08:07:52.592 * RDB: 0 MB of memory used by copy-on-write</pre><pre>26581:M 06 May 2019 08:07:52.609 * Background saving terminated with success</pre><pre>26581:M 06 May 2019 08:07:52.609 * Synchronization with replica 10.148.0.27:6379 succeeded</pre><pre>26581:M 06 May 2019 08:08:02.559 * Replica 10.140.0.10:6379 asks for synchronization</pre><pre>26581:M 06 May 2019 08:08:02.560 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for &#39;8cef21c6102a924ff9f293c112b68dc363ce6bec&#39;, my replication IDs are &#39;adcd85e20eebebd1369fab9543fa10ba9f65cab0&#39; and &#39;0000000000000000000000000000000000000000&#39;)</pre><pre>26581:M 06 May 2019 08:08:02.560 * Starting BGSAVE for SYNC with target: disk</pre><pre>26581:M 06 May 2019 08:08:02.560 * Background saving started by pid 26766</pre><pre>26766:C 06 May 2019 08:08:02.564 * DB saved on disk</pre><pre>26766:C 06 May 2019 08:08:02.564 * RDB: 0 MB of memory used by copy-on-write</pre><pre>26581:M 06 May 2019 08:08:02.644 * Background saving terminated with success</pre><pre>26581:M 06 May 2019 08:08:02.644 * Synchronization with replica 10.140.0.10:6379 succeeded</pre><p>Log thông báo data đã được sync sang các slave thành công.</p><h3>Setup và configure Sentinel</h3><p>Sentinel được cài trên tất cả các node.</p><p><strong>Config cho Sentinel:</strong></p><pre>protected-mode no<br>port 26379<br>daemonize yes<br>pidfile &quot;/var/run/redis-sentinel.pid&quot;<br>logfile &quot;/var/log/redis/sentinel-01.log&quot;<br>dir .<br>sentinel deny-scripts-reconfig yes<br><strong>sentinel monitor mymaster 10.140.0.11 6379 2</strong><br>sentinel down-after-milliseconds mymaster 5000<br>sentinel failover-timeout mymaster 10000</pre><p>Config này là <strong>giống nhau</strong> cho tất cả các Sentinel node. Sentinel sẽ monitor tất cả các redis node. Thông tin master node tại:</p><pre>sentinel monitor mymaster 10.140.0.11 6379 <strong>2</strong></pre><p>Trong đó, 2 là Quorum value, nghiã là Master được gọi là down khi có ≥ sentinel đồng ý với quyết định này</p><p>Thông tin của các slave node sẽ được sentinels lấy ra từ Master node.</p><p>Trên các sentinel node start các Sentinel process:</p><pre>./src/redis-server sentinel.conf — sentinel &amp;</pre><p>Khi đó, tất cả các Sentinel đều connect thông tin của Master:</p><pre>3426:X 06 May 2019 08:07:47.016 # -sdown slave 10.140.0.10:6379 10.140.0.10 6379 @ mymaster 10.140.0.11 6379</pre><pre>3426:X 06 May 2019 08:07:49.586 * +reboot slave 10.148.0.27:6379 10.148.0.27 6379 @ mymaster 10.140.0.11 6379</pre><pre>3426:X 06 May 2019 08:07:49.588 # -sdown slave 10.148.0.27:6379 10.148.0.27 6379 @ mymaster 10.140.0.11 6379</pre><pre>3426:X 06 May 2019 08:07:52.138 * +reboot master mymaster 10.140.0.11 6379</pre><pre>3426:X 06 May 2019 08:07:52.238 # -sdown master mymaster 10.140.0.11 6379</pre><pre>3426:X 06 May 2019 08:07:52.238 # -odown master mymaster 10.140.0.11 6379</pre><h3>Redis Sentinel Automatic Failover</h3><p>Redis Sentinel monitor Master node, nếu Master down, quá trình Failover sẽ được start.</p><p>Thử Stop redis trên master node. Khi đó:</p><p>Sentinel log trên Slave node:</p><pre>14582:X 06 May 2019 08:07:52.461 # -odown master mymaster 10.140.0.11 6379</pre><pre>14582:X 06 May 2019 08:08:01.979 * +convert-to-slave slave 10.140.0.10:6379 10.140.0.10 6379 @ mymaster 10.140.0.11 6379</pre><pre>14582:X 06 May 2019 09:03:40.382 # +sdown master mymaster 10.140.0.11 6379</pre><pre>14582:X 06 May 2019 09:03:40.474 # +odown master mymaster 10.140.0.11 6379 #quorum 2/2</pre><pre>14582:X 06 May 2019 09:03:40.474 # +new-epoch 24</pre><pre>14582:X 06 May 2019 09:03:40.474 # +try-failover master mymaster 10.140.0.11 6379</pre><pre>14582:X 06 May 2019 09:03:40.478 # +vote-for-leader 6d636ad5286eb9b924675161bfebe9f213c4a20f 24</pre><pre>14582:X 06 May 2019 09:03:40.510 # fc858414cd54fc700a57c46f1e1cd04ab98a0be9 voted for 6d636ad5286eb9b924675161bfebe9f213c4a20f 24</pre><pre>14582:X 06 May 2019 09:03:40.529 # e4cdc92722de43fd5feedbb6490b307fbb440f2c voted for e4cdc92722de43fd5feedbb6490b307fbb440f2c 24</pre><pre>14582:X 06 May 2019 09:03:51.057 # -failover-abort-not-elected master mymaster 10.140.0.11 6379</pre><pre>14582:X 06 May 2019 09:03:51.135 # Next failover delay: I will not start a failover before Mon May  6 09:04:00 2019</pre><pre>14582:X 06 May 2019 09:04:00.679 # +new-epoch 25</pre><pre>14582:X 06 May 2019 09:04:00.682 # <strong>+vote-for-leader e4cdc92722de43fd5feedbb6490b307fbb440f2c 25</strong></pre><pre>14582:X 06 May 2019 09:04:00.690 # Next failover delay: I will not start a failover before Mon May  6 09:04:21 2019</pre><pre>14582:X 06 May 2019 09:04:01.045 # +config-update-from sentinel e4cdc92722de43fd5feedbb6490b307fbb440f2c 10.148.0.27 26379 @ mymaster 10.140.0.11 6379</pre><pre>14582:X 06 May 2019 09:04:01.046 # <strong>+switch-master mymaster 10.140.0.11 6379 10.140.0.10 6379</strong></pre><pre>14582:X 06 May 2019 09:04:01.046 * +slave slave 10.148.0.27:6379 10.148.0.27 6379 @ mymaster 10.140.0.10 6379</pre><pre>14582:X 06 May 2019 09:04:01.047 * +slave slave 10.140.0.11:6379 10.140.0.11 6379 @ mymaster 10.140.0.10 6379</pre><pre>14582:X 06 May 2019 09:04:06.096 # +sdown slave 10.140.0.11:6379 10.140.0.11 6379 @ mymaster 10.140.0.10 6379</pre><p>Khi đó, một Slave sẽ được vode lên role Master.</p><p>Và sentinel được update config:</p><pre>sentinel monitor mymaster <strong>10.140.0.11</strong> 6379 2</pre><p>Trở thành:</p><pre>sentinel monitor mymaster <strong>10.140.0.10</strong> 6379 2</pre><p>Đồng thời, config file của các node Slave còn lại cũng được update address của master mới:</p><p>Từ:</p><pre><strong>slaveof </strong>10.140.0.11<strong> 6379</strong></pre><p>Trở thành:</p><pre>slaveof <strong>10.140.0.10</strong> 6379</pre><p>Đó là lý do, Sentinel còn được gọi là <strong>configuration provider</strong>.</p><h3>Setup HA Proxy cho Redis HA.</h3><p>Câu hỏi đặt ra: Với một mô hình 3 node Redis như trên, vậy làm thế nào để client xác định được address của Redis Master?</p><p>HA proxy là một trong các solutions.</p><p>HA proxy (High Availability Proxy) là một open-source Load-balancer cho phép load balance TCP services. HA proxy sẽ check xem trong các redis node, node nào có vai trò là Master. Từ đó, các request qua HA proxy server sẽ được forward đến Redis Master node.</p><p><strong>Cài đặt:</strong></p><pre>apt-get install haproxy</pre><p>file config của HA proxy tại <strong>/etc/haproxy/haproxy.conf</strong></p><p>Thay đổi như sau:</p><pre># Specifies TCP timeout on connect for use by the frontend ft_redis</pre><pre># Set the max time to wait for a connection attempt to a server to succeed</pre><pre># The server and client side expected to acknowledge or send data.</pre><pre>defaults REDIS</pre><pre>mode tcp</pre><pre>timeout connect 3s</pre><pre>timeout server 6s</pre><pre>timeout client 6s</pre><pre># Specifies listening socket for accepting client connections using the default</pre><pre># REDIS TCP timeout and backend bk_redis TCP health check.</pre><pre>frontend ft_redis</pre><pre>bind 0.0.0.0:6378 name redis</pre><pre>default_backend bk_redis</pre><pre># Specifies the backend Redis proxy server TCP health settings</pre><pre># Ensure it only forward incoming connections to reach a master.</pre><pre>backend bk_redis</pre><pre>option tcp-check</pre><pre>tcp-check connect</pre><pre>tcp-check send PING\r\n</pre><pre>tcp-check expect string +PONG</pre><pre>tcp-check send info\ replication\r\n</pre><pre>tcp-check expect string role:master</pre><pre>tcp-check send QUIT\r\n</pre><pre>tcp-check expect string +OK</pre><pre>server redis_01 10.140.0.10:6379 check inter 1s</pre><pre>server redis_02 10.140.0.11:6379 check inter 1s</pre><pre>server redis_02 10.148.0.27:6379 check inter 1s</pre><p>Trong đó:</p><blockquote>bind 0.0.0.0:6378 name redis</blockquote><p>Là địa chỉ để client connect tới. Khi client connect tới ha-proxy IP + port 6378, request sẽ được forward tới Redis Master</p><blockquote>server redis_01 10.140.0.10:6379 check inter 1s</blockquote><blockquote>server redis_02 10.140.0.11:6379 check inter 1s</blockquote><blockquote>server redis_02 10.148.0.27:6379 check inter 1s</blockquote><p>Set các Redis node:</p><blockquote>tcp-check send info\ replication\r\n<br>tcp-check expect string role:master</blockquote><p>Gửi câu lệnh sang các redis nodes, lấy IP của node có role master. Khi đó, các request sẽ được forward đến master node</p><p>Thử connect đến redis master thông qua ha proxy server, port 6378:</p><ul><li>10.140.0.12: IP của HA proxy</li></ul><pre>~/redis-01/redis-stable# redis-cli -h <strong>10.140.0.12</strong> -p <strong>6378</strong></pre><pre>10.140.0.12:6378&gt; info replication</pre><pre># Replication</pre><pre>role:master</pre><pre>connected_slaves:1</pre><pre>slave0:ip=10.140.0.11,port=6379,state=online,offset=1145239,lag=1</pre><pre>master_replid:c5fdadbc6a77166d3cc4d845a7add532b66d9e65</pre><pre>master_replid2:6b93c5b5a3babfbdafe4c7f42dd8065960f7eb7b</pre><pre>master_repl_offset:1145239</pre><pre>second_repl_offset:823027</pre><pre>repl_backlog_active:1</pre><pre>repl_backlog_size:1048576</pre><pre>repl_backlog_first_byte_offset:96664</pre><pre>repl_backlog_histlen:1048576</pre><pre>10.140.0.12:6378&gt;</pre><p>Qua bài viết này, các bạn đã phần nào nắm được cách thức hoạt động cũng như cách setup một mô hình Redis Sentinel. Để bài viết dễ hiểu, các câú hình cho Redis và Sentinel được setup một cách đơn giản nhất.</p><p>Các bạn có thể tham khảo thêm một số link sau:</p><p><a href="https://redis.io/topics/sentinel">https://redis.io/topics/sentinel</a></p><p><a href="https://www.howtoforge.com/tutorial/ubuntu-load-balancer-haproxy/">https://www.howtoforge.com/tutorial/ubuntu-load-balancer-haproxy/</a></p><p><a href="https://medium.com/@amila922/redis-sentinel-high-availability-everything-you-need-to-know-from-dev-to-prod-complete-guide-deb198e70ea6">https://medium.com/@amila922/redis-sentinel-high-availability-everything-you-need-to-know-from-dev-to-prod-complete-guide-deb198e70ea6</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ec501312bd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenTracing]]></title>
            <link>https://medium.com/@wano1010/opentracing-6d93f575b8d2?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d93f575b8d2</guid>
            <category><![CDATA[opentracing]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Fri, 03 May 2019 06:01:27 GMT</pubDate>
            <atom:updated>2019-05-03T06:01:27.747Z</atom:updated>
            <content:encoded><![CDATA[<p>Opentracing là một tập hợp (set) của các tiêu chuẩn và công nghệ, cho phép bạn theo dõi và giám sát các ứng dụng, giúp xác định chính xác nơi xảy ra lỗi trong chương trình và nguyên nhân khiến ứng dụng hoạt động không hiệu quả (ví dụ dứng dụng có độ trễ latency cao …)</p><p>Opentracing không phải là một software. Để monitor các request, Opentracing cần được add vào trong code hoặc framework.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d93f575b8d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Medium tricks]]></title>
            <link>https://medium.com/@wano1010/medium-tricks-e0b0c94c9446?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0b0c94c9446</guid>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[tricks]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Sat, 27 Apr 2019 23:08:53 GMT</pubDate>
            <atom:updated>2019-04-27T23:08:53.069Z</atom:updated>
            <content:encoded><![CDATA[<p>Medium tricks</p><ol><li>Block code</li></ol><ul><li><strong>Windows</strong>: Control + Alt + 6</li><li><strong>Mac</strong>: Command + Option + 6</li><li><strong>Linux</strong>: Control + Alt + 6</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0b0c94c9446" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Redis] Phần 1. Redis là gì mà nó lại phổ biến và quan trọng như thế?]]></title>
            <link>https://medium.com/@wano1010/redis-ph%E1%BA%A7n-1-redis-l%C3%A0-g%C3%AC-m%C3%A0-n%C3%B3-l%E1%BA%A1i-ph%E1%BB%95-bi%E1%BA%BFn-v%C3%A0-quan-tr%E1%BB%8Dng-nh%C6%B0-th%E1%BA%BF-f6992fe4fa59?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6992fe4fa59</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[sysadmin]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Sat, 27 Apr 2019 22:51:47 GMT</pubDate>
            <atom:updated>2019-05-06T16:50:54.547Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Redis] Redis là gì mà nó lại phổ biến và quan trọng như thế?</h3><h3>Redis, Bạn là ai?</h3><p>Redis là một cơ sở dữ liệu giá trị quan trọng thường được xếp vào nhóm cơ sở dữ liệu NoSQL. Được phát hành bởi nhà phát triển Salvatore Sanfilippo vào ngày 10 tháng 4 năm 2009.</p><p>Redis là một cơ sở dữ liệu dạng key-value và được lưu trữ trong bộ nhớ trong (RAM) của máy chủ. Điều này làm cho việc đọc và truy xuất dữ liệu nhanh hơn vì không phải chờ cho ổ cứng truyền thống tìm kiếm và đọc ghi nhiều lần.</p><p>Là một NoSQL database (lưu trữ dữ liệu dạng key-value) , nên redis cho phép bạn tạo cấu trúc dữ liệu đơn giản và nhanh gọn. Bạn có thể sử dụng redis để tạo một bộ đếm lượng khách truy cập, hoặc để biết thêm thông tin, như lưu trữ thông tin người dùng …</p><p>Redis thực sự hữu dụng khi bạn muốn ghi/truy xuất dữ liệu cực nhanh. Redis có thể sử dụng trong một số trường hợp:</p><ul><li>Caching</li><li>Queuing</li><li>Pub/sub</li><li>Machine learning (Cái này thì mình chưa dùng bao giờ, chỉ nghe thiên hạ đồn =)) )</li></ul><h3>Các kiểu dữ liệu trong Redis</h3><p>Redis hỗ trợ một số loại dữ liệu:</p><ul><li>Strings</li><li>Lists</li><li>Sets</li><li>Hashes</li><li>Sorted Sets</li><li>Bitmaps</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*EJxJa0oQ30YinVHm.png" /><figcaption>6 kiểu dữ liệu trong Redis</figcaption></figure><p><strong>Ví dụ về sử dụng data type</strong></p><p>Redis có thể được goi và truy xuất dữ liệu nhiều lần. Để xác đinh kiểu dữ liệu nên dùng trong redis, cần làm rõ yêu cầu của các bài toán dữ liệu đầu vào.</p><p>Ta sét một ví dụ đơn giản trong trường hợp sau.</p><p>Nếu sử dụng MySQL, thì một hàng trong bảng người dùng đơn giản trông giống như sau:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/0*EPlo7EIhJxE-NsMY.png" /><figcaption>Một hàng trong bảng người dùng khi sử dụng MySQL</figcaption></figure><p>Lưu ý, trong trường hợp này, password đã được hash, nghĩà là không được lưu dưới dạng văn bản thuần tuý.</p><p>Và để làm điều này, trong redis, ta sử dụng dữ liệu dạng “hash”. Chúng ta sử dụng lệnh HMSET để thêm dữ liệu với cú pháp:</p><pre>HMSET [hash name] [key1] [value1] [key2] [value2]</pre><p>trong trường hợp này:</p><pre>HMSET user:1 id 1 username alexbraunton password a67b9b40f76 email alex@example.com verified Y</pre><p>Chúng ta có thể kiểm tra dữ liệu vừa được add sử dụng lệnh “keys *”:</p><pre>127.0.0.1:6379&gt; KEYS * <br>1) “firstkey” <br>2) “user:1”</pre><p>Giá trị đã được lưu vào Redis. Hãy kiểm tra các hash và xem các giá trị:</p><pre>127.0.0.1:6379&gt; HGETALL user:1<br> 1) &quot;id&quot;<br> 2) &quot;1&quot;<br> 3) &quot;username&quot;<br> 4) &quot;alexbraunton&quot;<br> 5) &quot;password&quot;<br> 6) &quot;a67b9b40f76&quot;<br> 7) &quot;email&quot;<br> 8) &quot;alex@example.com&quot;<br> 9) &quot;verified&quot;<br>10) &quot;Y&quot;</pre><p>Nếu bạn muốn chỉ xem các key của một hash, bạn dùng lệnh “HKEYS”:</p><pre>127.0.0.1:6379&gt; HKEYS user:1<br>1) &quot;password&quot;<br>2) &quot;email&quot;<br>3) &quot;username&quot;<br>4) &quot;id&quot;<br>5) &quot;verified&quot;</pre><p>Để có được một giá trị cụ thể, chúng ta có thể truy cập nó bằng khóa của nó bằng cách sử dụng lệnh “HGET”:</p><pre>127.0.0.1:6379&gt; HGET user:1 email<br>&quot;alex@example.com&quot;</pre><p>Đến đây chúng ta đã có một cái nhìn cơ bản về Redis. Chúc các bạn có một ngày vui vẻ :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6992fe4fa59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Redis] Phần 1. Redis là gì mà nó lại phổ biến và quan trọng như thế?]]></title>
            <link>https://medium.com/@wano1010/redis-ph%E1%BA%A7n-1-redis-l%C3%A0-g%C3%AC-m%C3%A0-n%C3%B3-l%E1%BA%A1i-ph%E1%BB%95-bi%E1%BA%BFn-v%C3%A0-quan-tr%E1%BB%8Dng-nh%C6%B0-th%E1%BA%BF-d0468a4a0d1e?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0468a4a0d1e</guid>
            <category><![CDATA[sy]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Sat, 27 Apr 2019 22:47:08 GMT</pubDate>
            <atom:updated>2019-04-27T22:47:08.649Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Redis, Bạn là ai?</strong></h3><p>Redis là một cơ sở dữ liệu giá trị quan trọng thường được xếp vào nhóm cơ sở dữ liệu NoSQL. Được phát hành bởi nhà phát triển Salvatore Sanfilippo vào ngày 10 tháng 4 năm 2009.</p><p>Redis là một cơ sở dữ liệu trong bộ nhớ, có nghĩa là dữ liệu được lưu trữ trên bộ nhớ trong (RAM) của máy chủ. Điều này làm cho việc đọc và truy xuất dữ liệu nhanh hơn vì không phải chờ cho ổ cứng truyền thống tìm kiếm và đọc ghi nhiều lần.</p><p>Là một NoSQL database (lưu trữ dữ liệu dạng key-value) , nên redis cho phép bạn tạo cấu trúc dữ liệu đơn giản và nhanh gọn. Bạn có thể sử dụng redis để tạo một bộ đếm lượng khách truy cập, hoặc để biết thêm thông tin, như lưu trữ thông tin người dùng …</p><p>Redis thực sự hữu dụng khi bạn muốn ghi/truy xuất dữ liệu cực nhanh. Redis có thể sử dụng trong một số trường hợp:</p><ul><li>Caching</li><li>Queuing</li><li>Pub/sub</li><li>Machine learning (Cái này thì mình chưa dùng bao giờ, chỉ nghe thiên hạ đồn =)) )</li></ul><h3><strong>Các kiểu dữ liệu trong Redis</strong></h3><p>Redis hỗ trợ một số loại dữ liệu:</p><ul><li>Strings</li><li>Lists</li><li>Sets</li><li>Hashes</li><li>Sorted Sets</li><li>Bitmaps</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*EJxJa0oQ30YinVHm.png" /><figcaption>6 kiểu dữ liệu trong Redis</figcaption></figure><p><strong>Ví dụ về sử dụng data type</strong></p><p>Redis có thể được goi và truy xuất dữ liệu nhiều lần. Để xác đinh kiểu dữ liệu nên dùng trong redis, cần làm rõ yêu cầu của các bài toán dữ liệu đầu vào.</p><p>Ta sét một ví dụ đơn giản trong trường hợp sau.</p><p>Nếu sử dụng MySQL, thì một hàng trong bảng người dùng đơn giản trông giống như sau:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/0*EPlo7EIhJxE-NsMY.png" /><figcaption>Một hàng trong bảng người dùng khi sử dụng MySQL</figcaption></figure><p>Lưu ý, trong trường hợp này, password đã được hash, nghĩà là không được lưu dưới dạng văn bản thuần tuý.</p><p>Và để làm điều này, trong redis, ta sử dụng dữ liệu dạng “hash&quot;. Chúng ta sử dụng lệnh HMSET để thêm dữ liệu với cú pháp:</p><pre>HMSET [hash name] [key1] [value1] [key2] [value2]</pre><p>trong trường hợp này:</p><pre>HMSET user:1 id 1 username alexbraunton password a67b9b40f76 email alex@example.com verified Y</pre><p>Chúng ta có thể kiểm tra dữ liệu vừa được add sử dụng lệnh “keys *”:</p><pre>127.0.0.1:6379&gt; KEYS * <br>1) “firstkey” <br>2) “user:1”</pre><p>Giá trị đã được lưu vào Redis. Hãy kiểm tra các hash và xem các giá trị:</p><pre>127.0.0.1:6379&gt; HGETALL user:1<br> 1) &quot;id&quot;<br> 2) &quot;1&quot;<br> 3) &quot;username&quot;<br> 4) &quot;alexbraunton&quot;<br> 5) &quot;password&quot;<br> 6) &quot;a67b9b40f76&quot;<br> 7) &quot;email&quot;<br> 8) &quot;alex@example.com&quot;<br> 9) &quot;verified&quot;<br>10) &quot;Y&quot;</pre><p>Nếu bạn muốn chỉ xem các key của một hash, bạn dùng lệnh “HKEYS”:</p><pre>127.0.0.1:6379&gt; HKEYS user:1<br>1) &quot;password&quot;<br>2) &quot;email&quot;<br>3) &quot;username&quot;<br>4) &quot;id&quot;<br>5) &quot;verified&quot;</pre><p>Để có được một giá trị cụ thể, chúng ta có thể truy cập nó bằng khóa của nó bằng cách sử dụng lệnh “HGET”:</p><pre>127.0.0.1:6379&gt; HGET user:1 email<br>&quot;alex@example.com&quot;</pre><p>Đến đây chúng ta đã có một cái nhìn cơ bản về Redis. Chúc các bạn có một ngày vui vẻ :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0468a4a0d1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Golang] Remove all accents in string]]></title>
            <link>https://medium.com/@wano1010/golang-remove-all-accents-in-string-319abf6a7f5b?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/319abf6a7f5b</guid>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Sun, 03 Mar 2019 09:20:38 GMT</pubDate>
            <atom:updated>2019-03-03T09:20:38.925Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://blog.golang.org/normalization">https://blog.golang.org/normalization</a></p><blockquote>package main</blockquote><blockquote>import (<br> “fmt”<br> “unicode”</blockquote><blockquote>“golang.org/x/text/transform”<br> “golang.org/x/text/unicode/norm”<br>)</blockquote><blockquote>func isMn(r rune) bool {<br> return unicode.Is(unicode.Mn, r) // Mn: nonspacing marks<br>}</blockquote><blockquote>func main() {<br> t := transform.Chain(norm.NFD, transform.RemoveFunc(isMn), norm.NFC)<br> result, _, _ := transform.String(t, “žůžo”)<br> fmt.Println(result)<br>}</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=319abf6a7f5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Django] Dump và Load database như thế nào?]]></title>
            <link>https://medium.com/@wano1010/django-dump-v%C3%A0-load-database-nh%C6%B0-th%E1%BA%BF-n%C3%A0o-f5c97e80e12b?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5c97e80e12b</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Fri, 02 Nov 2018 07:18:47 GMT</pubDate>
            <atom:updated>2018-11-02T07:18:47.875Z</atom:updated>
            <content:encoded><![CDATA[<p>Đôi khi bạn cần dump và restore db từ project này sang project kia hoặc từ môi trường này sang môi trường kia? và bạn đau đầu vì vấn đề đó?</p><p>Django cung cấp một tính năng cho phép dump db thành một file json và restore lại vô cùng đơn giản.</p><p>I. Dump db</p><blockquote>python manage.py dumpdata &gt; db.json</blockquote><p>Lệnh này sẽ dump toàn bộ các table của db ra thành file db.json<br>Trong môi trường mới, bạn chỉ việc vác file này sang và load vào db mới là xong.</p><p>Để exclude một số table, run command:</p><blockquote>python manage.py dumpdata — exclude table1 — exclude table2&gt; db.json</blockquote><p>II. Load DB</p><p>Để restore db mới từ file db.json:</p><blockquote>python manage.py loaddata db.json</blockquote><p>Đơn giản và gọn nhẹ.</p><p>Ưu điểm: Không cần quan tâm môi trường cũ bạn sử dụng MySQL/PostgreSQL, DB mới bạn sử dụng PostgreSQL/MySQL, Django sẽ tự convert cho bạn. Nhẹ đầu :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5c97e80e12b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[MySQL] Export table thành file csv từ một remote database]]></title>
            <link>https://medium.com/@wano1010/mysql-export-table-th%C3%A0nh-file-csv-t%E1%BB%AB-m%E1%BB%99t-remote-database-a98f02940be9?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a98f02940be9</guid>
            <category><![CDATA[mysql]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Thu, 01 Nov 2018 07:01:37 GMT</pubDate>
            <atom:updated>2018-11-01T07:01:37.333Z</atom:updated>
            <content:encoded><![CDATA[<p>Sử dụng lệnh sau:</p><blockquote>mysql -h remote_host -u username -p database_name -e “select * from table_name” | sed “s/’/\’/;s/\t/\”,\”/g;s/^/\”/;s/$/\”/;s/\n//g” &gt; table_name.csv</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a98f02940be9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can’t remove, purge, uninstall mongodb from debian]]></title>
            <link>https://medium.com/@wano1010/cant-remove-purge-unistall-mongodb-from-debian-27556874ccd3?source=rss-8c00138e40c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/27556874ccd3</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[ubunt]]></category>
            <dc:creator><![CDATA[wano]]></dc:creator>
            <pubDate>Fri, 14 Sep 2018 02:46:38 GMT</pubDate>
            <atom:updated>2018-09-14T02:48:45.171Z</atom:updated>
            <content:encoded><![CDATA[<p>Loay hoay với lỗi không thể uninstall hoặc install mongodb trên ubuntu 16.0</p><blockquote>$ sudo apt-get purge mongodb-org-server</blockquote><blockquote>Reading package lists… Done</blockquote><blockquote>Building dependency tree</blockquote><blockquote>Reading state information… Done</blockquote><blockquote>The following packages were automatically installed and are no longer required:</blockquote><blockquote>grub-pc-bin libcurl3</blockquote><blockquote>Use ‘sudo apt autoremove’ to remove them.</blockquote><blockquote>The following packages will be REMOVED:</blockquote><blockquote>mongodb-org-server*</blockquote><blockquote>0 upgraded, 0 newly installed, 1 to remove and 13 not upgraded.</blockquote><blockquote>1 not fully installed or removed.</blockquote><blockquote>After this operation, 62.0 MB disk space will be freed.</blockquote><blockquote>Do you want to continue? [Y/n] y</blockquote><blockquote>(Reading database … 89564 files and directories currently installed.)</blockquote><blockquote>Removing mongodb-org-server (4.0.2) …</blockquote><blockquote>invoke-rc.d: dangling symlink: /etc/rc5.d/S01mongod</blockquote><blockquote>dpkg: error processing package mongodb-org-server ( — purge):</blockquote><blockquote>subprocess installed pre-removal script returned error exit status 102</blockquote><blockquote>invoke-rc.d: dangling symlink: /etc/rc5.d/S01mongod</blockquote><blockquote>dpkg: error while cleaning up:</blockquote><blockquote>subprocess installed post-installation script returned error exit status 102</blockquote><blockquote>Errors were encountered while processing:</blockquote><blockquote>mongodb-org-server</blockquote><blockquote>E: Sub-process /usr/bin/dpkg returned an error code (1)</blockquote><p>Cách fix:</p><blockquote>cd /var/lib/dpkg/info/<br>ls | grep mongo<br>sudo rm -ff mongo*<br>sudo apt-get purge mongodb</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27556874ccd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>