2020/04/16

ubuntu 18.04 安裝 jupyter 讓遠端可以開browser使用


sudo apt install python3 python3-pip

sudo apt install python3-matplotlib (畫圖使用 視需求安裝)

pip3 install jupyter

sudo apt install jupyter-core

sudo apt install jupyter-notebook

jupyter notebook --generate-config

Writing default config to: /home/user/.jupyter/jupyter_notebook_config.py


加上登入密碼

jupyter notebook password
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /home/user/.jupyter/jupyter_notebook_config.json

修改  /home/user/.jupyter/jupyter_notebook_config.py
檔案尾端加上

c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5678
c.NotebookApp.notebook_dir = '/tmp'

啟動 jupyter

jupyter notebook


就可以在別台几器上開browser
http://server_ip:5678
http://server_ip:5678
登入


簡單記一下ipython 跟 notebook的安裝設定過程 讓遠端可以存取

先安裝

sudo apt install -y ipython ipython-notebook ipython-notebook-common

產生 config file
ipython profile create nbserver

使用ipython產生密碼 hash

In [1]: from notebook.auth import passwd
In [2]: passwd()

Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

修改

/home/user/.ipython/profile_nbserver/ipython_notebook_config.py

在檔案最後加上

c = get_config()
c.NotebookApp.ip = ‘*’
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5678
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'


啟動server
ipython notebook

接下來就可以在遠方使用browser

http://server_ip:5678

登入使用了

2020/04/08

又是librenms的問題

/opt/librenms/daily.sh
出現

Fatal error: require(): Failed opening required '/opt/librenms/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/librenms/vendor/composer/autoload_real.php on line 69
PHP Fatal error:  require(): Failed opening required '/opt/librenms/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/librenms/vendor/composer/autoload_real.php on line 69

跑一下

/opt/librenms/validate.php

[FAIL]  Missing dependencies!
[FIX]:
/opt/librenms/scripts/composer_wrapper.php install --no-dev

執行 /opt/librenms/scripts/composer_wrapper.php install --no-dev

/opt/librenms/scripts/composer_wrapper.php install --no-dev
> LibreNMS\ComposerHelper::preInstall
Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 3 installs, 38 updates, 0 removals
  - Installing symfony/polyfill-mbstring (v1.15.0): Downloading (100%)       
  - Updating symfony/polyfill-intl-idn (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating egulias/email-validator (2.1.11 => 2.1.17): Downloading (100%)       
  - Updating erusev/parsedown (1.7.3 => 1.7.4): Downloading (100%)       
  - Updating symfony/polyfill-ctype (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating phpoption/phpoption (1.5.2 => 1.7.3): Downloading (100%)       
  - Updating vlucas/phpdotenv (v3.6.0 => v3.6.2): Downloading (100%)       
  - Updating symfony/css-selector (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/var-dumper (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/routing (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/process (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/polyfill-php73 (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating symfony/mime (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/http-foundation (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/event-dispatcher (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating psr/log (1.1.2 => 1.1.3): Downloading (100%)       
  - Updating symfony/debug (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/error-handler (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/http-kernel (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/finder (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/console (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/polyfill-iconv (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating ramsey/uuid (3.8.0 => 3.9.3): Downloading (100%)       
  - Updating opis/closure (3.4.1 => 3.5.1): Downloading (100%)       
  - Updating symfony/translation (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating nesbot/carbon (2.27.0 => 2.32.2): Downloading (100%)       
  - Updating monolog/monolog (1.25.2 => 1.25.3): Downloading (100%)       
  - Updating league/flysystem (1.0.57 => 1.0.66): Downloading (100%)       
  - Updating laravel/framework (v5.8.35 => v5.8.37): Downloading (100%)       
  - Updating fico7489/laravel-pivot (3.0.3 => 3.0.4): Downloading (100%)       
  - Updating fideloper/proxy (4.2.1 => 4.3.0): Downloading (100%)       
  - Updating guzzlehttp/guzzle (6.4.1 => 6.5.2): Downloading (100%)       
  - Updating martinlindhe/laravel-vue-i18n-generator (0.1.42 => 0.1.46): Downloading (100%)       
  - Installing phpseclib/phpseclib (2.0.26): Downloading (100%)       
  - Updating php-amqplib/php-amqplib (v2.0.2 => v2.11.1): Downloading (100%)       
  - Updating phpmailer/phpmailer (v6.1.3 => v6.1.5): Downloading (100%)       
  - Removing dnoegel/php-xdg-base-dir (0.1)
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Downloading (100%)       
  - Updating psy/psysh (v0.9.9 => v0.9.12): Downloading (100%)       
  - Updating symfony/dotenv (v3.4.35 => v3.4.39): Downloading (100%)       
  - Updating symfony/yaml (v4.4.0 => v4.4.7): Downloading (100%)       
  - Installing doctrine/cache (1.10.0): Downloading (100%)       
Generating optimized autoload files
Deprecation Notice: Class HTMLPurifier_Language_en_x_test located in ./vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language/classes/en-x-test.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Crypt_CHAP_MD5 located in ./vendor/dapphp/radius/lib/Pear_CHAP.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Crypt_CHAP_MSv1 located in ./vendor/dapphp/radius/lib/Pear_CHAP.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Crypt_CHAP_MSv2 located in ./vendor/dapphp/radius/lib/Pear_CHAP.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: darkghosthunter/larapoke
Discovered Package: fideloper/proxy
Discovered Package: laravel/laravel
Discovered Package: laravel/tinker
Discovered Package: martinlindhe/laravel-vue-i18n-generator
Discovered Package: nesbot/carbon
Discovered Package: oriceon/toastr-5-laravel
Discovered Package: spatie/laravel-cors
Discovered Package: tightenco/ziggy
Package manifest generated successfully.
26 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> LibreNMS\ComposerHelper::postInstall
> Illuminate\Foundation\ComposerScripts::postInstall
> @php artisan vue-i18n:generate --multi-locales --format=umd

再跑一次 validate.php

[librenms@librenms ~]$ ./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.62-28-g5f2eab0
DB Schema | 2020_03_25_165300_add_column_to_ports (161)
PHP       | 7.2.27
MySQL     | 5.5.64-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

[OK]    Composer Version: 1.10.1
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database schema correct
[FAIL]  Some folders have incorrect file permissions, this may cause issues.
[FIX]:
sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
Files:
/opt/librenms/storage/framework/views/95a740c2fd790034ee55f5aee95726c8


chown -R librenms:librenms /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/


跑完後就ok了