#author("2018-11-28T10:15:56+09:00","default:kuji","kuji")
#author("2018-11-29T10:45:01+09:00","default:kuji","kuji")
CONTENTS
#contents
----
Lastmodified &lastmod;
----
*Nextcloud [#ta2c5edf]

  # portinstall www/nextcloud
  # portinstall graphics/ImageMagick-nox11

と、ports でインストール出来るが、VersionUPに不具合があるようで、あれこれ苦労するので、サイトから直接zipをダウンロードして展開・配置するほうがトラブルが少ないょ。


*HDD追加・容量拡張 [#y8660750]
【参考】http://web.cc.yamaguchi-u.ac.jp/~hiroshi/FreeBSD/%E3%83%8F%E3%83%BC%E3%83%89%E3%83%87%E3%82%A3%E3%82%B9%E3%82%AF%E3%81%AE%E8%BF%BD%E5%8A%A0.html

『ストレージがほぼ一杯です』を通り過ぎると、サーバのディレクトリが開けなくなるエラーがでて、同期しなくなる。ということで、

HDDを追加して認識状態を確認

 ada1 at ata1 bus 0 scbus1 target 0 lun 0
 ada1: <WDC WD60EZRX-00MVLB1 80.00A80> ACS-2 ATA SATA 3.x device
 ada1: Serial Number WD-WX31D944CFJ7
 ada1: 600.000MB/s transfers (SATA 3.x, UDMA5, PIO 8192bytes)
 ada1: 5723166MB (11721045168 512 byte sectors: 16H 63S/T 16383C)
 ada1: quirks=0x1<4K>
 ada1: Previously was known as ad2

gpart で確認
 > gpart show ada1
   gpart: No such geom: ada1.

GPT形式 (-s GPT) のパーテーションを作成 create する。
 # gpart create -s GPT ada1
   ada1 created

確認
 # gpart show ada1
   => 34 11721045101 ada1 GPT (5.5T)
 
 34 11721045101 - free - (5.5T)

HDD丸ごとBSDパーテーションとする。

 オプションの説明
 必須 -t タイプ(ここでは freebsd なので -t freebsd-ufs )
 任意 -b 値1 (パーティションの始まりとなる論理的ブロック)
 任意 -s 値2 (パーティションのサイズ)
 任意 -a 値3 (開始位置(値1)及びサイズ(値2)を値3の倍数に揃える)

ここでは 4kセクタのアライメントを揃える為に -a 4k

任意 -i 値4 (インデックスを指定)

 # gpart add -a 4k -t freebsd-ufs ada1
   ada1p1 added

確認する

 # gpart show ada1
   => 34 11721045101 ada1 GPT (5.5T)
 34 6 - free - (3.0K)
 40 11721045088 1 freebsd-ufs (5.5T)
 11721045128 7 - free - (3.5K)

さらに device ファイルができているか確認

 # ls /dev/ada1*
   /dev/ada1 /dev/ada1p1

となりOK

ファイルシステムの作成
 # newfs -U /dev/ada1p1

少々お時間がかかります.(1分弱)

その後は /usr/home というマウント先ディレクトリを作り、

 # mount /dev/ada1p1 /usr/home    この名前は適宜

でマウント出来るか試してから/etc/fstab を編集
 # Device	Mountpoint	FStype	Options	Dump	Pass#
 /dev/ada0s1a	/		ufs	rw	1	1
 /dev/ada0s1b	none		swap	sw	0	0
 /dev/ada1p1    /usr/home       ufs	rw	1	2 ←追加行

** データ移行 [#n035820c]
/usr/local/www/nextcloud/config/config.php
  'maintenance' => true,
メインテナンスモードにして、ローカルHDD同士だが、使い慣れたrsyncで移行

Nextcloud_migration.sh
 #!/bin/sh
 /usr/local/bin/rsync -av --inplace --exclude '*.core' /usr/local/www/nextcloud/data /usr/home/Nextcloud/

/usr/home/Nextcloud/dataへ移行出来たら、

/usr/local/www/nextcloud/config/config.php は、
 'datadirectory' => '/usr/home/Nextcloud/data',
というエントリーとし、メンテナンスモード解除。

*nextcloud.log も [#vd04228e]

/usr/local/etc/newsyslog.conf.d/nextcloud.conf

 # configuration file for newsyslog for necxtcloud 
 # logfilename          [owner:group]    mode count size when  flags [/pid_file] [sig_num]
 #/usr/local/www/nextcloud/data/nextcloud.log		644  12    *    @T05 Z
 /usr/home/Nextcloud/data/nextcloud.log		644  12    *    @T05 Z

と変更。


注)  

ここでfstab の書き方を間違えたことに気づかず再起動させたら / 以下が読み取り専用でマウントされて起動してしまった. これでは fstab を修正しようとしても出来ない. このようなときは
 # mount -u /  
を実行すると / 以下が読み込み・書き込み可能な状態でマウントしなおしてくれる. それからee などでfstab を編集し, 再起動.


*www/nextcloud を portupgrade 対象から外す [#p29fd212]

/usr/local/etc/pkgtools.conf

  HOLD_PKGS = [
    'bsdpan-*',
    'www/nextcloud*',
  ]

とすると、こうなる。

 Ports tree is already up to date.
 [Reading data from pkg(8) ... - 441 packages found - done]
 glib-2.56.1_1,1             <  needs updating (port has 2.56.1_2,1)
 gobject-introspection-1.50.0_1,1  <  needs updating (port has 1.56.1,1)
 help2man-1.47.7             <  needs updating (port has 1.47.8)
 nextcloud-php70-14.0.1      <  [held] needs updating (port has 14.0.3)  ←こうなる
 pkg-1.10.5_4                <  needs updating (port has 1.10.5_5)
 pkgconf-1.5.3,1             <  needs updating (port has 1.5.4,1)
 postgresql95-client-9.5.14  <  needs updating (port has 9.5.14_1)
 py27-openssl-17.5.0_1       <  needs updating (port has 18.0.0)



*SSL [#h0b3e968]

 # cd  /usr/local/etc/apache24/
 # openssl genrsa -out server.key 2048
 # openssl req -new -key server.key -out server.csr
 # openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
 # chmod 0400 /usr/local/etc/apache24/server.*

** edit usr/local/etc/apache24/httpd.conf [#z28c0383]

 # 以下の行のコメントを外す
 LoadModule socache_shmcb_module libexec/apache24/mod_socache_shmcb.so
 LoadModule ssl_module libexec/apache24/mod_ssl.so
 Include etc/apache24/extra/httpd-ssl.conf
 

** edit httpd-ssl.conf [#e75900cb]

 <VirtualHost _default_:443>
 
 #   General setup for the virtual host
 DocumentRoot "/usr/local/www/apache24/data"
 ServerName xxxx.smb.net:443
 ServerAdmin xxxx@smb.net
 ErrorLog "/var/log/httpd-error.log"
 TransferLog "/var/log/httpd-access.log"


 # apachectl restart


*post install settings [#s87c3949]

config.sample.php

 /**
  * Where user files are stored. The SQLite database is also stored here, when
  * you use SQLite.
  *
  * Default to ``data/`` in the Nextcloud directory.
  */
 'datadirectory' => '/usr/local/www/nextcloudnextcloud/data',

** G7 [#baf5524a]

 # cp -rp /usr/local/www/nextcloud/data /usr/home/Nextcloud/
 # chown -R www:www /usr/home/Nextcloud/data

 'datadirectory' => '/usr/home/Nextcloud/data',


/usr/local/etc/php.ini
 opcache.enable=1
 opcache.enable_cli=1
 opcache.interned_strings_buffer=8
 opcache.max_accelerated_files=10000
 opcache.memory_consumption=128
 opcache.save_comments=1
 opcache.revalidate_freq=1


/usr/local/etc/apache24/Includes/nextcloud.conf

 Alias /nextcloud /usr/local/www/nextcloud
 AcceptPathInfo On
 <Directory /usr/local/www/nextcloud>
     AllowOverride All
     Require all granted
     Header set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
 </Directory>


*  NEXTCLOUD VERSION UPGRADE [#sf6540c9]
 ***********************************************************************
 *                       NEXTCLOUD VERSION UPGRADE                     *
 ***********************************************************************
 
 After a version migration you should upgrade your nextcloud instance
 using command line:
 
 * cd /usr/local/www/nextcloud
 * su -m www -c "php ./occ upgrade"

 # su -m www -c "php /usr/local/www/nextcloud/occ upgrade"


 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
                     /!\ NEXTCLOUD 13.0.1 UPDATE /!\
 
 The nextcloud 13.0.1 package changes the location of the bundled apps.
 After updating to 13.0.1 you MUST adapt your configuration. You MUST
 add an additional entry to the "apps-paths" array in config/config.php
 
     1 =>
     array (
       'path' => '/usr/local/www/nextcloud/apps-pkg',
       'url' => '/apps-pkg',
       'writable' => false,
     ),
 
 For the default installation, the fix can be applied with:
 
   cd /usr/local/www/nextcloud
   su -m www -c "php ./occ config:import < /usr/local/share/nextcloud/fix-apps_paths.json"
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


** * su -m www -c "php ./occ upgrade" [#k30822f3]

 # su -m www -c "php ./occ upgrade"
 
 Nextcloud or one of the apps require upgrade - only a limited number of commands are available
 You may use your browser or the occ upgrade command to do the upgrade
 Set log level to debug
 Updating database schema
 Updated database
 Checking for update of app activity in appstore
 Checked for update of app "activity" in appstore
 Checking for update of app comments in appstore
 Checked for update of app "comments" in appstore
 Checking for update of app dav in appstore
 Checked for update of app "dav" in appstore
 Checking for update of app federatedfilesharing in appstore
 Checked for update of app "federatedfilesharing" in appstore
 Checking for update of app federation in appstore
 Checked for update of app "federation" in appstore
 Checking for update of app files in appstore
 Checked for update of app "files" in appstore
 Checking for update of app files_pdfviewer in appstore
 Checked for update of app "files_pdfviewer" in appstore
 Checking for update of app files_sharing in appstore
 Checked for update of app "files_sharing" in appstore
 Checking for update of app files_texteditor in appstore
 Checked for update of app "files_texteditor" in appstore
 Checking for update of app files_trashbin in appstore
 Checked for update of app "files_trashbin" in appstore
 Checking for update of app files_versions in appstore
 Checked for update of app "files_versions" in appstore
 Checking for update of app files_videoplayer in appstore
 Checked for update of app "files_videoplayer" in appstore
 Checking for update of app firstrunwizard in appstore
 Checked for update of app "firstrunwizard" in appstore
 Checking for update of app gallery in appstore
 Checked for update of app "gallery" in appstore
 Checking for update of app logreader in appstore
 Checked for update of app "logreader" in appstore
 Checking for update of app lookup_server_connector in appstore
 Checked for update of app "lookup_server_connector" in appstore
 Checking for update of app nextcloud_announcements in appstore
 Checked for update of app "nextcloud_announcements" in appstore
 Checking for update of app notifications in appstore
 Checked for update of app "notifications" in appstore
 Checking for update of app oauth2 in appstore
 Checked for update of app "oauth2" in appstore
 Checking for update of app password_policy in appstore
 Checked for update of app "password_policy" in appstore
 Checking for update of app provisioning_api in appstore
 Checked for update of app "provisioning_api" in appstore
 Checking for update of app serverinfo in appstore
 Checked for update of app "serverinfo" in appstore
 Checking for update of app sharebymail in appstore
 Checked for update of app "sharebymail" in appstore
 Checking for update of app survey_client in appstore
 Checked for update of app "survey_client" in appstore
 Checking for update of app systemtags in appstore
 Checked for update of app "systemtags" in appstore
 Checking for update of app theming in appstore
 Checked for update of app "theming" in appstore
 Checking for update of app twofactor_backupcodes in appstore
 Checked for update of app "twofactor_backupcodes" in appstore
 Checking for update of app updatenotification in appstore
 Checked for update of app "updatenotification" in appstore
 Checking for update of app workflowengine in appstore
 Checked for update of app "workflowengine" in appstore
 Starting code integrity check...
 Finished code integrity check
 Update successful
 Maintenance mode is kept active
 Reset log level

** 最後にNextcloudのメンテナンスモードを解除します。 [#w8a79633]
 cd /usr/local/www/nextcloud/config/config.php
 
   'maintenance' => false,


** Memorycache [#be104aa0]

https://docs.nextcloud.com/server/12/admin_manual/configuration_server/caching_configuration.html

 # portinstall databases/memcached
 
 # portinstall databases/pecl-memcache
 [Reading data from pkg(8) ... - 317 packages found - done]
 ** Port marked as IGNORE: databases/pecl-memcache:
         does not work with PHP versions 70 71 72 73 and 71 is installed.  ←2018年11月18日現在


 memcached_enable="YES"


 # portinstall devel/pecl-APCu
 [Reading data from pkg(8) ... - 405 packages found - done]
 ** Port marked as IGNORE: devel/pecl-APCu:
         cannot be installed: doesn't work with lang/php56 port (doesn't support PHP 5.6)
 ** Listing the failed packages (-:ignored / *:skipped / !:failed)
         - devel/pecl-APCu

 # portinstall devel/pecl-APCu4


/usr/local/www/nextcloud/config/config.php

 'memcache.local' => '\OC\Memcache\APCu',

「すべてのチェックに合格しました。」とでるが、サーバDBでは、エラーの嵐状態となる。



//'memcache.local' => '\OC\Memcache\APCu',

// 'memcache.local' => '\OC\Memcache\APCu',




** File locking [#pebe294c]

https://docs.nextcloud.com/server/12/admin_manual/configuration_files/files_locking_transactional.html?highlight=lock

トランザクションファイルロックを使用してMemcacheを使用するには、Redisサーバーとそれに対応するPHPモジュールをインストールする必要があります。

 # portinstall databases/redis

 redis_enable="YES"

 # portinstall databases/pecl-redis


 'redis' => array(
      'host' => 'localhost',
      'port' => 6379,
      'timeout' => 0.0,
      'password' => '', // Optional, if not defined no password will be used.
       ),



* 最大アップロードサイズ [#r84912bb]

Web設定 ⇒ 管理 ⇒ 基本設定 ⇒ ファイル操作 ⇒ 最大アップロードサイズ   511MB を変更するには、

/usr/local/www/nextcloud/.htaccess

 <IfModule mod_php5.c>
   php_value upload_max_filesize 1024M  ← 511M
   php_value post_max_size 1024M        ← 511M
   php_value memory_limit 512M
   php_value mbstring.func_overload 0
   php_value always_populate_raw_post_data -1
   php_value default_charset 'UTF-8'
   php_value output_buffering 0
   <IfModule mod_env.c>
     SetEnv htaccessWorking true
   </IfModule>
 </IfModule>
 <IfModule mod_php7.c>
   php_value upload_max_filesize 1024M   ← 511M
   php_value post_max_size 1024M          ← 511M
   php_value memory_limit 512M
   php_value mbstring.func_overload 0
   php_value default_charset 'UTF-8'
   php_value output_buffering 0
   <IfModule mod_env.c>
     SetEnv htaccessWorking true
   </IfModule>
 </IfModule>






* ファイルをアップロードすると 'Integrity constraint violation...' エラーが表示される [#cbf41a70]

https://wiki.archlinuxjp.org/index.php/Nextcloud

https://wiki.archlinuxjp.org/index.php/Nextcloud#.E3.83.95.E3.82.A1.E3.82.A4.E3.83.AB.E3.82.92.E3.82.A2.E3.83.83.E3.83.97.E3.83.AD.E3.83.BC.E3.83.89.E3.81.99.E3.82.8B.E3.81.A8_.27Integrity_constraint_violation....27_.E3.82.A8.E3.83.A9.E3.83.BC.E3.81.8C.E8.A1.A8.E7.A4.BA.E3.81.95.E3.82.8C.E3.82.8B

PHPのキャッシュを止めるとOK

/usr/local/etc/php.ini
 ;opcache.enable=1
 ;opcache.enable_cli=1
 ;opcache.interned_strings_buffer=8
 ;opcache.max_accelerated_files=10000
 ;opcache.memory_consumption=128
 ;opcache.save_comments=1
 ;opcache.revalidate_freq=1

結局RedisをセットしてPHPキャッシュを止めると、エラーも出なくなる。

* ファイルロックを解除する [#k3d1dd4b]

https://help.nextcloud.com/t/file-is-locked-how-to-unlock/1883


* フォルダに65356個以上のファイルがあるとエラーする件  [#y747d4d0]

https://www.iij.ad.jp/company/development/tech/activities/weighttp/

コマンドにスペースが含まれるとエラーする
 # sysctl -w kern.ipc.somaxconn = 100000
   kern.ipc.somaxconn: 128
   sysctl: unknown oid ''
   sysctl: unknown oid '100000'

ので、こう

 # sysctl -w kern.ipc.somaxconn=100000
   kern.ipc.somaxconn: 128 -> 100000

ブート時にこの値になるよう設定するには、「/etc/sysctl.conf」に以下を書き加えます

 kern.ipc.somaxconn=100000

*AM3 ごろのエラーの件 [#d7c06fa5]

/etc/sysctrl.conf

 # https://pleiades.ucsc.edu/hyades/FreeBSD_Network_Tuning
 kern.maxfiles=6289573
 kern.maxfilesperproc=6289573
 #kern.maxvnodes=3339551

 Sep 25 02:55:00 sun1 /usr/sbin/cron[75782]: (munin) CMD (/usr/local/bin/munin-cron)
 Sep 25 03:00:00 sun1 /usr/sbin/cron[76073]: (root) CMD (newsyslog)
 Sep 25 03:00:00 sun1 /usr/sbin/cron[76074]: (root) CMD (/usr/libexec/atrun)
 Sep 25 03:00:00 sun1 /usr/sbin/cron[76075]: (operator) CMD (/usr/libexec/save-entropy)
 Sep 25 03:00:00 sun1 /usr/sbin/cron[76076]: (munin) CMD (/usr/local/bin/munin-cron)
 Sep 25 03:01:00 sun1 /usr/sbin/cron[76365]: (root) CMD (adjkerntz -a)
 Sep 25 03:01:00 sun1 /usr/sbin/cron[76366]: (root) CMD (periodic daily)
 Sep 25 04:39:58 sun1 kernel: sonewconn: pcb 0xfffff80079f03ae0: Listen queue overflow: 193 already in queue awaiting acceptance (1 occurrences)
 Sep 25 04:41:03 sun1 kernel: sonewconn: pcb 0xfffff80079f03ae0: Listen queue overflow: 193 already in queue awaiting acceptance (8 occurrences)
 Sep 25 04:42:07 sun1 kernel: sonewconn: pcb 0xfffff80079f03ae0: Listen queue overflow: 193 already in queue awaiting acceptance (10 occurrences)
 Sep 25 04:43:11 sun1 kernel: sonewconn: pcb 0xfffff80079f03ae0: Listen queue overflow: 193 already in queue awaiting acceptance (3 occurrences)
 Sep 25 04:44:15 sun1 kernel: sonewconn: pcb 0xfffff80079f03ae0: Listen queue overflow: 193 already in queue awaiting acceptance (8 occurrences)

https://blog.tyk.nu/blog/fun-with-freebsd-listen-queue-overflow/

https://github.com/tmux/tmux/issues/352

https://wiki.archlinux.jp/index.php/Nextcloud#CSync_failed_to_find_a_specific_file.

*Getting Start! [#vdb2cf1d]

+ウエッブブラウザで「指定されたnextcloudサーバ」へアクセスします。
+指定されたID・PWでログインする。
+ログインすると、アプリのダウンロードが提案されるので、端末型に応じてダウンロードインストールする。
+インストールしたアプリを起動し、「新規アカウント」指示に従って作成。
+自動同期したいファイルを含むフォルダを設定しておくとサーバと自動で同期されるようになります。



----
Total access &counter(total);:本日 &counter(today);:昨日 &counter(yesterday);
#counter([total|today|yesterday]);


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS