{"id":3663,"date":"2024-02-26T10:10:29","date_gmt":"2024-02-26T16:10:29","guid":{"rendered":"https:\/\/lab.rapternet.us\/?p=3663"},"modified":"2024-01-27T20:59:04","modified_gmt":"2024-01-28T02:59:04","slug":"upgrading-my-nextcloud-to-use-redis-and-fix-cron","status":"publish","type":"post","link":"https:\/\/lab.rapternet.us\/?p=3663","title":{"rendered":"Upgrading my NextCloud to use Redis and fix Cron"},"content":{"rendered":"\n<p>I&#8217;ve had NextCloud installed for a while now and part of my core infrastructure, however it hasn&#8217;t been running well. I&#8217;ve always had issues getting the cron jobs to run and occasional problems with file locking in it. Recently the file locking problems got worse and I finally decided to fix both issues in one hopefully straightforward action.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>My NextCloud is probably not the most common setup around, but these changes should be pretty easy to incorporate for anyone running it. My setup runs the official NextCloud container on Unraid with my mariadb instance running in a VM. I&#8217;ll be updating my NextCloud on Unraid to run a docker compose file to run a second NextCloud container for cron, and a redis container.<\/p>\n\n\n\n<p>The volume paths and ports were determined by my previous NextCloud container settings in Unraid, I just moved them into the compose file, then added the cron and redis services. The cron service uses the same volume mounts as NextCloud (so if you have different mounts for your container, just use those same ones for this new cron container), while the redis container is just a default redis setup with basic configuration.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">services:<br>  cron:<br>    image: nextcloud:apache<br>    container_name: nextcloud-cron<br>    restart: always<br>    volumes:<br>      - \/mnt\/user\/Settings\/NextCloud\/html\/:\/var\/www\/html:rw<br>      - \/mnt\/user\/Settings\/NextCloud\/db\/:\/var\/lib\/mysql:rw<br>    entrypoint: \/cron.sh<br>  nextcloud:<br>    container_name: nextcloud-prime<br>    image: nextcloud<br>    volumes:<br>      - \/mnt\/user\/Settings\/NextCloud\/html\/:\/var\/www\/html\/:rw<br>      - \/mnt\/user\/Settings\/NextCloud\/db\/:\/var\/lib\/mysql:rw<br>    ports:<br>      - 10001:80<br>  redis:<br>    container_name: nextcloud_redis<br>    image: redis<br>    restart: always<br><\/pre>\n\n\n\n<p>Once I had the docker compose file setup, I made the changes to the NextCloud configuration (config.php) to enable redis caching. I updated locking and distributed caching to use redis and left local caching to apcu (as suggested in the NextCloud guides. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  'memcache.local' =&gt; '\\\\OC\\\\Memcache\\\\APCu',<br>  'memcache.locking' =&gt; '\\\\OC\\\\Memcache\\\\Redis',<br>  'memcache.distributed' =&gt; '\\\\OC\\\\Memcache\\\\Redis',<br>  'redis' =&gt;<br>  array (<br>    'host' =&gt; 'redis',<br>    'port' =&gt; 6379,<br>  ),<\/pre>\n\n\n\n<p>After that, I started up the stack and checked everything out. There were a few hiccups at the start, my first login attempt failed but my second one succeeded and then everything started looking good. I even got my first sign that the cron container was working!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"199\" src=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2024\/01\/Capture-1024x199.png\" alt=\"\" class=\"wp-image-3683\" srcset=\"https:\/\/lab.rapternet.us\/wp-content\/uploads\/2024\/01\/Capture-1024x199.png 1024w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2024\/01\/Capture-300x58.png 300w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2024\/01\/Capture-768x149.png 768w, https:\/\/lab.rapternet.us\/wp-content\/uploads\/2024\/01\/Capture.png 1382w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption class=\"wp-element-caption\">Cron Jobs Running!<\/figcaption><\/figure>\n\n\n\n<p>We&#8217;ll see with time if this fixes some of the issues I&#8217;ve had with my nextcloud install or if it causes other problems, but for now I&#8217;ll consider it a resounding win.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve had NextCloud installed for a while now and part of my core infrastructure, however it hasn&#8217;t been running well. I&#8217;ve always had issues getting the cron jobs to run and occasional problems with file locking in it. Recently the file locking problems got worse and I finally decided to fix both issues in one &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/lab.rapternet.us\/?p=3663\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Upgrading my NextCloud to use Redis and fix Cron&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3683,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[11,22],"class_list":["post-3663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","tag-nextcloud","tag-services"],"_links":{"self":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/3663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3663"}],"version-history":[{"count":6,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/3663\/revisions"}],"predecessor-version":[{"id":3691,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/posts\/3663\/revisions\/3691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=\/wp\/v2\/media\/3683"}],"wp:attachment":[{"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab.rapternet.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}