■公式サイト

Jupyter Project Documentation

JupyterHub(公式ドキュメント)

 

■概要

上記②に下記のように記載

・Four subsystems make up JupyterHub:

  • Hub (tornado process) that is the heart of JupyterHub

  • configurable http proxy (node-http-proxy) that receives the requests from the client’s browser

  • multiple single-user Jupyter notebook servers (Python/IPython/tornado) that are monitored by Spawners

  • an authentication class that manages how users can access the system

Besides these central pieces, you can add optional configurations through a config.py file and manage users kernels on an admin panel. 

 

 

 

■インストーラ―ダウンロード

上記②のInstallationリンクをクリックする。

prerequisit

上記のprerequisitによると、python3.5以上とnodejsとnpm

が必要とのこと。

・python3インストール

[centos7copy]$ yum install -y python3

・nodejsとnpmインストール

 こちらを猿真似

[centos7copy]$ curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash -

 

================================================================================
================================================================================

                              DEPRECATION WARNING

  Node.js 8.x LTS Carbon is no longer actively supported!

  You will not receive security or critical stability updates for this version.

  You should migrate to a supported version of Node.js as soon as possible.
  Use the installation script that corresponds to the version of Node.js you
  wish to install. e.g.

   * https://deb.nodesource.com/setup_10.x ― Node.js v10 LTS "Dubnium"
   * https://deb.nodesource.com/setup_12.x ― Node.js v12 LTS "Erbium" (recommended)
   * https://deb.nodesource.com/setup_14.x ― Node.js v14 LTS "Fermium"
   * https://deb.nodesource.com/setup_15.x ― Node.js v15 "Fifteen"

  Please see https://github.com/nodejs/Release for details about which
  version may be appropriate for you.

----(略)----

→がっつりnodejsするわけじゃないからええねん。

[centos7copy]$ ll /etc/yum.repos.d/
total 56
-rw-r--r--. 1 root root  824 Apr 16  2020 bareos.repo
-rw-r--r--. 1 root root 1664 Apr  8  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr  8  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Apr  8  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Apr  8  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Apr  8  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr  8  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 7577 Apr  8  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 Apr  8  2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root  951 Aug 31 23:15 epel.repo
-rw-r--r--. 1 root root 1050 Oct  3  2017 epel-testing.repo
-rw-r--r--. 1 root root  201 Aug 15 22:11 mongodb-org-4.4.repo
-rw-r--r--. 1 root root  472 Jan  5  2018 nodesource-el7.repo

[centos7copy]$ cat /etc/yum.repos.d/nodesource-el7.repo
[nodesource]
name=Node.js Packages for Enterprise Linux 7 - $basearch
baseurl=https://rpm.nodesource.com/pub_8.x/el/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL

[nodesource-source]
name=Node.js for Enterprise Linux 7 - $basearch - Source
baseurl=https://rpm.nodesource.com/pub_8.x/el/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
gpgcheck=1

[centos7copy]$ yum install -y nodejs

[centos7copy]$ node -v
v8.17.0

installation

[centos7copy]$ python3 -m pip install jupyterhub

→いろんなものがいっぱいインストールされた

[centos7copy]$ npm install -g configurable-http-proxy

----ここから脱線-----

※npmでインストールされたパッケージの場所は/usr/lib/node_modules

[centos7copy]$ ll /usr/lib/node_modules
total 8
drwxr-xr-x. 5 root root 4096 Nov  1 23:00 configurable-http-proxy
drwxr-xr-x. 9 root root 4096 Nov  1 22:48 npm

configurable-http-proxyはindividual serversへのリクエストをルーティングするリバースプロキシ参照

----ここまで脱線----- 

[centos7copy]$ python3 -m pip install notebook

→いろんなものがいっぱいインストールされた

[centos7copy]$ jupyterhub -V
1.2.1

[centos7copy]$ configurable-http-proxy -V
4.2.2

[centos7copy]$ jupyterhub -h
Start a multi-user Jupyter Notebook server

Spawns a configurable-http-proxy and multi-user Hub, which authenticates users
and spawns single-user Notebook servers on behalf of users.

Subcommands
-----------

Subcommands are launched as `jupyterhub cmd [args]`. For information on using
subcommand 'cmd', do: `jupyterhub cmd -h`.

token
    Generate an API token for a user
upgrade-db
    Upgrade your JupyterHub state database to the current version.

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

--debug
    set log level to logging.DEBUG (maximize logging output)
--generate-config
    generate default config file
--generate-certs
    generate certificates used for internal ssl
--no-db
    disable persisting state database to disk
--upgrade-db
    Automatically upgrade the database if needed on startup.

    Only safe if the database has been backed up.
    Only SQLite database files will be backed up automatically.
--no-ssl
    [DEPRECATED in 0.7: does nothing]
--base-url=<URLPrefix> (JupyterHub.base_url)
    Default: '/'
    The base URL of the entire application.
    Add this to the beginning of all JupyterHub URLs. Use base_url to run
    JupyterHub within an existing website.
    .. deprecated: 0.9
        Use JupyterHub.bind_url
-y <Bool> (JupyterHub.answer_yes)
    Default: False
    Answer yes to any questions (e.g. confirm overwrite)
--ssl-key=<Unicode> (JupyterHub.ssl_key)
    Default: ''
    Path to SSL key file for the public facing interface of the proxy
    When setting this, you should also set ssl_cert
--ssl-cert=<Unicode> (JupyterHub.ssl_cert)
    Default: ''
    Path to SSL certificate file for the public facing interface of the proxy
    When setting this, you should also set ssl_key
--url=<Unicode> (JupyterHub.bind_url)
    Default: 'http://:8000'
    The public facing URL of the whole JupyterHub application.
    This is the address on which the proxy will bind. Sets protocol, ip,
    base_url
--ip=<Unicode> (JupyterHub.ip)
    Default: ''
    The public facing ip of the whole JupyterHub application (specifically
    referred to as the proxy).
    This is the address on which the proxy will listen. The default is to listen
    on all interfaces. This is the only address through which JupyterHub should
    be accessed by users.
    .. deprecated: 0.9
        Use JupyterHub.bind_url
--port=<Int> (JupyterHub.port)
    Default: 8000
    The public facing port of the proxy.
    This is the port on which the proxy will listen. This is the only port
    through which JupyterHub should be accessed by users.
    .. deprecated: 0.9
        Use JupyterHub.bind_url
--pid-file=<Unicode> (JupyterHub.pid_file)
    Default: ''
    File to write PID Useful for daemonizing JupyterHub.
--log-file=<Unicode> (JupyterHub.extra_log_file)
    Default: ''
    DEPRECATED: use output redirection instead, e.g.
    jupyterhub &>> /var/log/jupyterhub.log
--log-level=<Enum> (Application.log_level)
    Default: 30
    Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
    Set the log level by value or name.
-f <Unicode> (JupyterHub.config_file)
    Default: 'jupyterhub_config.py'
    The config file to load
--config=<Unicode> (JupyterHub.config_file)
    Default: 'jupyterhub_config.py'
    The config file to load
--db=<Unicode> (JupyterHub.db_url)
    Default: 'sqlite:///jupyterhub.sqlite'
    url for the database. e.g. `sqlite:///jupyterhub.sqlite`

To see all available configurables, use `--help-all`

Examples
--------

    generate default config file:

        jupyterhub --generate-config -f /etc/jupyterhub/jupyterhub_config.py

    spawn the server on 10.0.1.2:443 with https:

        jupyterhub --ip 10.0.1.2 --port 443 --ssl-key my_ssl.key --ssl-cert my_ssl.cert


[centos7copy]$ configurable-http-proxy -h
Usage: configurable-http-proxy [options]

Options:
  -V, --version                      output the version number
  --ip <ip-address>                  Public-facing IP of the proxy
  --port <n> (defaults to 8000)      Public-facing port of the proxy
  --ssl-key <keyfile>                SSL key to use, if any
  --ssl-cert <certfile>              SSL certificate to use, if any
  --ssl-ca <ca-file>                 SSL certificate authority, if any
  --ssl-request-cert                 Request SSL certs to authenticate clients
  --ssl-reject-unauthorized          Reject unauthorized SSL connections (only meaningful if --ssl-request-cert is given)
  --ssl-protocol <ssl-protocol>      Set specific SSL protocol, e.g. TLSv1_2, SSLv3
  --ssl-ciphers <ciphers>            `:`-separated ssl cipher list. Default excludes RC4
  --ssl-allow-rc4                    Allow RC4 cipher for SSL (disabled by default)
  --ssl-dhparam <dhparam-file>       SSL Diffie-Helman Parameters pem file, if any
  --api-ip <ip>                      Inward-facing IP for API requests (default: "localhost")
  --api-port <n>                     Inward-facing port for API requests (defaults to --port=value+1)
  --api-ssl-key <keyfile>            SSL key to use, if any, for API requests
  --api-ssl-cert <certfile>          SSL certificate to use, if any, for API requests
  --api-ssl-ca <ca-file>             SSL certificate authority, if any, for API requests
  --api-ssl-request-cert             Request SSL certs to authenticate clients for API requests
  --api-ssl-reject-unauthorized      Reject unauthorized SSL connections (only meaningful if --api-ssl-request-cert is given)
  --client-ssl-key <keyfile>         SSL key to use, if any, for proxy to client requests
  --client-ssl-cert <certfile>       SSL certificate to use, if any, for proxy to client requests
  --client-ssl-ca <ca-file>          SSL certificate authority, if any, for proxy to client requests
  --client-ssl-request-cert          Request SSL certs to authenticate clients for API requests
  --client-ssl-reject-unauthorized   Reject unauthorized SSL connections (only meaningful if --client-ssl-request-cert is given)
  --default-target <host>            Default proxy target (proto://host[:port])
  --error-target <host>              Alternate server for handling proxy errors (proto://host[:port])
  --error-path <path>                Alternate server for handling proxy errors (proto://host[:port])
  --redirect-port <redirect-port>    Redirect HTTP requests on this port to the server on HTTPS
  --redirect-to <port>               Redirect HTTP requests from --redirect-port to this port
  --pid-file <pid-file>              Write our PID to a file
  --no-x-forward                     Don't add 'X-forward-' headers to proxied requests
  --no-prepend-path                  Avoid prepending target paths to proxied requests
  --no-include-prefix                Don't include the routing prefix in proxied requests
  --auto-rewrite                     Rewrite the Location header host/port in redirect responses
  --change-origin                    Changes the origin of the host header to the target URL
  --protocol-rewrite <proto>         Rewrite the Location header protocol in redirect responses to the specified protocol
  --custom-header <header>           Custom header to add to proxied requests. Use same option for multiple headers (--custom-header k1:v1 --custom-header k2:v2) (default: {})
  --insecure                         Disable SSL cert verification
  --host-routing                     Use host routing (host as first level of path)
  --statsd-host <host>               Host to send statsd statistics to
  --statsd-port <port>               Port to send statsd statistics to
  --statsd-prefix <prefix>           Prefix to use for statsd statistics
  --log-level <loglevel>             Log level (debug, info, warn, error) (default: "info")
  --timeout <n>                      Timeout (in millis) when proxy drops connection for a request.
  --proxy-timeout <n>                Timeout (in millis) when proxy receives no response from target.
  --storage-backend <storage-class>  Define an external storage class. Defaults to in-MemoryStore.
  -h, --help                         display help for command

Start the Hub server

[centos7copy]$ jupyterhub &
[1] 24629
[centos7copy]$ [I 2020-11-01 23:10:50.068 JupyterHub app:2332] Running JupyterHub version 1.2.1
[I 2020-11-01 23:10:50.068 JupyterHub app:2363] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.2.1
[I 2020-11-01 23:10:50.068 JupyterHub app:2363] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-1.2.1
[I 2020-11-01 23:10:50.068 JupyterHub app:2363] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-1.2.1
[I 2020-11-01 23:10:50.070 JupyterHub app:1457] Writing cookie_secret to /root/jupyterhub_cookie_secret
[I 2020-11-01 23:10:50.086 alembic.runtime.migration migration:155] Context impl SQLiteImpl.
[I 2020-11-01 23:10:50.086 alembic.runtime.migration migration:162] Will assume non-transactional DDL.
[I 2020-11-01 23:10:50.093 alembic.runtime.migration migration:517] Running stamp_revision  -> 4dc2d5a8c53c
[I 2020-11-01 23:10:50.131 JupyterHub proxy:461] Generating new CONFIGPROXY_AUTH_TOKEN
[W 2020-11-01 23:10:50.132 JupyterHub app:1687] No admin users, admin interface will be unavailable.
[W 2020-11-01 23:10:50.132 JupyterHub app:1689] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2020-11-01 23:10:50.132 JupyterHub app:1718] Not using allowed_users. Any authenticated user will be allowed.
[I 2020-11-01 23:10:50.166 JupyterHub app:2402] Initialized 0 spawners in 0.001 seconds
[W 2020-11-01 23:10:50.169 JupyterHub proxy:643] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
[I 2020-11-01 23:10:50.169 JupyterHub proxy:646] Starting proxy @ http://:8000
23:10:50.290 [ConfigProxy] info: Proxying http://*:8000 to (no default)
23:10:50.292 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes

[centos7copy]$ lsof -p 24629
COMMAND     PID USER   FD      TYPE             DEVICE  SIZE/OFF    NODE NAME
jupyterhu 24629 root  cwd       DIR                8,2      4096  786433 /root
jupyterhu 24629 root  rtd       DIR                8,2      4096       2 /
jupyterhu 24629 root  txt       REG                8,2     11336  950063 /usr/bin/python3.6
jupyterhu 24629 root  mem       REG                8,2     99952  938690 /usr/lib64/libelf-0.176.so
jupyterhu 24629 root  mem       REG                8,2     19896  919961 /usr/lib64/libattr.so.1.1.0
jupyterhu 24629 root  mem       REG                8,2     88776  925306 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
jupyterhu 24629 root  mem       REG                8,2    338672  932093 /usr/lib64/libdw-0.176.so
jupyterhu 24629 root  mem       REG                8,2     43712  925847 /usr/lib64/librt-2.17.so
jupyterhu 24629 root  mem       REG                8,2     20048  925890 /usr/lib64/libcap.so.2.22
jupyterhu 24629 root  mem       REG                8,2     86464  922057 /usr/lib64/libnss_myhostname.so.2
jupyterhu 24629 root  mem       REG                8,2     31344  919315 /usr/lib64/libnss_dns-2.17.so
jupyterhu 24629 root  mem       REG                8,2     61560  925844 /usr/lib64/libnss_files-2.17.so
jupyterhu 24629 root  mem       REG                8,2    753280  920020 /usr/lib64/libsqlite3.so.0.8.6
jupyterhu 24629 root  mem       REG                8,2     85808  308130 /usr/lib64/python3.6/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     23968  919943 /usr/lib64/libcap-ng.so.0.0.0
jupyterhu 24629 root  mem       REG                8,2    127184  919944 /usr/lib64/libaudit.so.1.0.0
jupyterhu 24629 root  mem       REG                8,2     61680  921942 /usr/lib64/libpam.so.0.83.1
jupyterhu 24629 root  mem       REG                8,2     46632 1049058 /usr/local/lib64/python3.6/site-packages/cffi.libs/libffi-806b1a9d.so.6.0.4
jupyterhu 24629 root  mem       REG                8,2    853792 1049056 /usr/local/lib64/python3.6/site-packages/_cffi_backend.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     27069  170066 /usr/local/lib64/python3.6/site-packages/cryptography/hazmat/bindings/_padding.abi3.so
jupyterhu 24629 root  mem       REG                8,2     16400  308147 /usr/lib64/python3.6/lib-dynload/resource.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     26680  308141 /usr/lib64/python3.6/lib-dynload/mmap.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     19496  308138 /usr/lib64/python3.6/lib-dynload/fcntl.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2   1802435 1048984 /usr/local/lib64/python3.6/site-packages/_ruamel_yaml.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     20064  934647 /usr/lib64/libuuid.so.1.3.0
jupyterhu 24629 root  mem       REG                8,2     32328  919951 /usr/lib64/libffi.so.6.0.1
jupyterhu 24629 root  mem       REG                8,2    134000  308105 /usr/lib64/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     35640  308104 /usr/lib64/python3.6/lib-dynload/_csv.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    174576  919648 /usr/lib64/libtinfo.so.5.9
jupyterhu 24629 root  mem       REG                8,2    234720  919640 /usr/lib64/libncursesw.so.5.9
jupyterhu 24629 root  mem       REG                8,2     85872  308106 /usr/lib64/python3.6/lib-dynload/_curses.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     29384 1048606 /usr/local/lib64/python3.6/site-packages/tornado/speedups.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     69120 1048777 /usr/local/lib64/python3.6/site-packages/sqlalchemy/cresultproxy.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     36712 1048782 /usr/local/lib64/python3.6/site-packages/sqlalchemy/cutils.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     58048 1048786 /usr/local/lib64/python3.6/site-packages/sqlalchemy/cprocessors.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    899576  308152 /usr/lib64/python3.6/lib-dynload/unicodedata.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     38875   23836 /usr/local/lib64/python3.6/site-packages/markupsafe/_speedups.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    402000  308110 /usr/lib64/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     26008  308151 /usr/lib64/python3.6/lib-dynload/termios.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    110968  308108 /usr/lib64/python3.6/lib-dynload/_datetime.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     51592  308115 /usr/lib64/python3.6/lib-dynload/_json.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     26728  308136 /usr/lib64/python3.6/lib-dynload/binascii.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    118576  308131 /usr/lib64/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     59976  308093 /usr/lib64/python3.6/lib-dynload/_asyncio.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2      7448  308121 /usr/lib64/python3.6/lib-dynload/_opcode.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     16752  308123 /usr/lib64/python3.6/lib-dynload/_posixsubprocess.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     17008  308120 /usr/lib64/python3.6/lib-dynload/_multiprocessing.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     20576  308124 /usr/lib64/python3.6/lib-dynload/_random.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     13608  308094 /usr/lib64/python3.6/lib-dynload/_bisect.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     98176  308127 /usr/lib64/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     47480  308095 /usr/lib64/python3.6/lib-dynload/_blake2.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    402384  919745 /usr/lib64/libpcre.so.1.2.0
jupyterhu 24629 root  mem       REG                8,2    155744  922449 /usr/lib64/libselinux.so.1
jupyterhu 24629 root  mem       REG                8,2    109976  925846 /usr/lib64/libresolv-2.17.so
jupyterhu 24629 root  mem       REG                8,2     15688  920528 /usr/lib64/libkeyutils.so.1.5
jupyterhu 24629 root  mem       REG                8,2     67104  931658 /usr/lib64/libkrb5support.so.0.1
jupyterhu 24629 root  mem       REG                8,2    210784  921017 /usr/lib64/libk5crypto.so.3.1
jupyterhu 24629 root  mem       REG                8,2     15856  921269 /usr/lib64/libcom_err.so.2.1
jupyterhu 24629 root  mem       REG                8,2    967760  921023 /usr/lib64/libkrb5.so.3.3
jupyterhu 24629 root  mem       REG                8,2    320720  921013 /usr/lib64/libgssapi_krb5.so.2.2
jupyterhu 24629 root  mem       REG                8,2   2521144  921037 /usr/lib64/libcrypto.so.1.0.2k
jupyterhu 24629 root  mem       REG                8,2    470376  921039 /usr/lib64/libssl.so.1.0.2k
jupyterhu 24629 root  mem       REG                8,2     27080  308113 /usr/lib64/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     13224  308139 /usr/lib64/python3.6/lib-dynload/grp.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    157424  919770 /usr/lib64/liblzma.so.5.2.2
jupyterhu 24629 root  mem       REG                8,2     38944  308117 /usr/lib64/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     68192  919877 /usr/lib64/libbz2.so.1.0.6
jupyterhu 24629 root  mem       REG                8,2     23056  308096 /usr/lib64/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     90248  919757 /usr/lib64/libz.so.1.2.7
jupyterhu 24629 root  mem       REG                8,2     34528  308154 /usr/lib64/python3.6/lib-dynload/zlib.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     58024  308134 /usr/lib64/python3.6/lib-dynload/array.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    106056  308129 /usr/lib64/python3.6/lib-dynload/_socket.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2    132240  308122 /usr/lib64/python3.6/lib-dynload/_pickle.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     52664  308132 /usr/lib64/python3.6/lib-dynload/_struct.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     33536  308148 /usr/lib64/python3.6/lib-dynload/select.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     51320  308140 /usr/lib64/python3.6/lib-dynload/math.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2     22904  308114 /usr/lib64/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root  mem       REG                8,2 106172832  138666 /usr/lib/locale/locale-archive
jupyterhu 24629 root  mem       REG                8,2   2156240  919299 /usr/lib64/libc-2.17.so
jupyterhu 24629 root  mem       REG                8,2   1136944  925841 /usr/lib64/libm-2.17.so
jupyterhu 24629 root  mem       REG                8,2     14424  919333 /usr/lib64/libutil-2.17.so
jupyterhu 24629 root  mem       REG                8,2     19248  925840 /usr/lib64/libdl-2.17.so
jupyterhu 24629 root  mem       REG                8,2    142144  919325 /usr/lib64/libpthread-2.17.so
jupyterhu 24629 root  mem       REG                8,2   3131840  950054 /usr/lib64/libpython3.6m.so.1.0
jupyterhu 24629 root  mem       REG                8,2    163312  919292 /usr/lib64/ld-2.17.so
jupyterhu 24629 root  DEL       REG                8,2            168780 /tmp/#168780
jupyterhu 24629 root  mem       REG                8,2     26970  919615 /usr/lib64/gconv/gconv-modules.cache
jupyterhu 24629 root    0u      CHR              136,2       0t0       5 /dev/pts/2
jupyterhu 24629 root    1u      CHR              136,2       0t0       5 /dev/pts/2  ←標準出力が端末にひもづいてる
jupyterhu 24629 root    2u      CHR              136,2       0t0       5 /dev/pts/2  ←標準エラー出力が端末にひもづいてる

jupyterhu 24629 root    3u  a_inode               0,10         0    8534 [eventpoll]
jupyterhu 24629 root    4u     unix 0xffff9aefe9abf2c0       0t0  423325 socket
jupyterhu 24629 root    5u     unix 0xffff9aefe9abd0c0       0t0  423326 socket
jupyterhu 24629 root    6u      REG                8,2      4096  168780 /tmp/#168780 (deleted)
jupyterhu 24629 root    7u     IPv4             423383       0t0     TCP localhost:tproxy (LISTEN)

[centos7copy]$ netstat -naptl | grep 24629
tcp        0      0 127.0.0.1:8081          0.0.0.0:*               LISTEN      24629/python3

[centos7copy]$ pstree -p 24629

[centos7copy]$ ls -1 /usr/local/bin/jupyter*|while read line;do echo ---$line---;file $line;done
---/usr/local/bin/jupyter---
/usr/local/bin/jupyter: Python script, ASCII text executable
---/usr/local/bin/jupyter-bundlerextension---
/usr/local/bin/jupyter-bundlerextension: Python script, ASCII text executable
---/usr/local/bin/jupyterhub---
/usr/local/bin/jupyterhub: Python script, ASCII text executable

---/usr/local/bin/jupyterhub-singleuser---
/usr/local/bin/jupyterhub-singleuser: Python script, ASCII text executable
---/usr/local/bin/jupyter-kernel---
/usr/local/bin/jupyter-kernel: Python script, ASCII text executable
---/usr/local/bin/jupyter-kernelspec---
/usr/local/bin/jupyter-kernelspec: Python script, ASCII text executable
---/usr/local/bin/jupyter-migrate---
/usr/local/bin/jupyter-migrate: Python script, ASCII text executable
---/usr/local/bin/jupyter-nbconvert---
/usr/local/bin/jupyter-nbconvert: Python script, ASCII text executable
---/usr/local/bin/jupyter-nbextension---
/usr/local/bin/jupyter-nbextension: Python script, ASCII text executable
---/usr/local/bin/jupyter-notebook---
/usr/local/bin/jupyter-notebook: Python script, ASCII text executable
---/usr/local/bin/jupyter-run---
/usr/local/bin/jupyter-run: Python script, ASCII text executable
---/usr/local/bin/jupyter-serverextension---
/usr/local/bin/jupyter-serverextension: Python script, ASCII text executable
---/usr/local/bin/jupyter-troubleshoot---
/usr/local/bin/jupyter-troubleshoot: Python script, ASCII text executable
---/usr/local/bin/jupyter-trust---
/usr/local/bin/jupyter-trust: Python script, ASCII text executable

 

■初期設定

Get StartedConfiguration Basicsから順にやってみる

Generate a default config fileに書かれてるデフォルトコンフィグファイルを生成する

[centos7copy]$ jupyterhub --generate-config
Writing default config to: jupyterhub_config.py

 

→カレントディレクトリにjupyterhub_config.pyが作られた。

[centos7copy]$ wc -l jupyterhub_config.py
1061 jupyterhub_config.py

 

推奨されてる通り移動する。

[centos7copy]$ mv jupyterhub_config.py /etc/

コンフィグの設定を適用してjupyterhubデーモンを起動する場合は、

jupyterhub -f /path/to/jupyterhub_config.py

また、コマンドラインオプションでデーモンを制御する場合は、例えば、

jupyterhub --ip 10.0.1.2 --port 443 --ssl-key my_ssl.key --ssl-cert my_ssl.cert

のようにする。

 

[centos7copy]$ jupyterhub -f /etc/jupyterhub_config.py &
[1] 48067
[centos7copy]$ [I 2020-11-02 00:25:32.029 JupyterHub app:2332] Running JupyterHub version 1.2.1
[I 2020-11-02 00:25:32.030 JupyterHub app:2363] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.2.1
[I 2020-11-02 00:25:32.030 JupyterHub app:2363] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-1.2.1
[I 2020-11-02 00:25:32.030 JupyterHub app:2363] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-1.2.1
[I 2020-11-02 00:25:32.031 JupyterHub app:1412] Loading cookie_secret from /root/jupyterhub_cookie_secret
[I 2020-11-02 00:25:32.050 JupyterHub proxy:461] Generating new CONFIGPROXY_AUTH_TOKEN
[W 2020-11-02 00:25:32.051 JupyterHub app:1687] No admin users, admin interface will be unavailable.
[W 2020-11-02 00:25:32.051 JupyterHub app:1689] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2020-11-02 00:25:32.051 JupyterHub app:1718] Not using allowed_users. Any authenticated user will be allowed.
[I 2020-11-02 00:25:32.088 JupyterHub app:2402] Initialized 0 spawners in 0.002 seconds
[W 2020-11-02 00:25:32.090 JupyterHub proxy:643] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
[I 2020-11-02 00:25:32.091 JupyterHub proxy:646] Starting proxy @ http://:8000
00:25:32.226 [ConfigProxy] info: Proxying http://*:8000 to (no default)
00:25:32.228 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes

[centos7copy]$
[centos7copy]$ 00:25:38.347 [ConfigProxy] info: 200 GET /api/routes
[I 2020-11-02 00:25:38.348 JupyterHub app:2647] Hub API listening on http://127.0.0.1:8081/hub/
00:25:38.351 [ConfigProxy] info: 200 GET /api/routes
[I 2020-11-02 00:25:38.352 JupyterHub proxy:320] Checking routes
[I 2020-11-02 00:25:38.352 JupyterHub proxy:400] Adding default route for Hub: / => http://127.0.0.1:8081
00:25:38.354 [ConfigProxy] info: Adding route / -> http://127.0.0.1:8081
00:25:38.354 [ConfigProxy] info: Route added / -> http://127.0.0.1:8081
00:25:38.355 [ConfigProxy] info: 201 POST /api/routes/
[I 2020-11-02 00:25:38.355 JupyterHub app:2722] JupyterHub is now running at http://:8000

 

 

■接続してみる

[centos7copy]$ setenforce 0
[centos7copy]$ iptables -F

ブラウザから、http://192.168.19.201:8000にアクセス。

pam認証がデフォルトとのことなので、OSに居るユーザ「dagyah」に/etc/shadowのパスワードでログイン

 

■logファイル

[centos7copy]$ cat -n /etc/jupyterhub_config.py | grep -i log | grep -vi login
     9  ## The date format used by logging formatters for %(asctime)s
    10  #c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'
    12  ## The Logging format template
    13  #c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'
    15  ## Set the log level by value or name.
    16  #c.Application.log_level = 30
   183  ## log all database transactions. This has A LOT of output
   238  #  jupyterhub &>> /var/log/jupyterhub.log
   239  #c.JupyterHub.extra_log_file = ''
   241  ## Extra log handlers to set on JupyterHub logger
   242  #c.JupyterHub.extra_log_handlers = []
   388  ## Specify path to a logo image to override the Jupyter logo in the banner.
   389  #c.JupyterHub.logo_file = ''
   482  ## Shuts down all user servers on logout
   483  #c.JupyterHub.shutdown_on_logout = False
   577  #  ensure the correct client IP addresses are recorded in the logs instead of the
   599  # Spawner(LoggingConfigurable) configuration
   682  ## Enable debug-logging of the single-user server
   885  # Authenticator(LoggingConfigurable) configuration
   893  #   - Use the admin panel to see list of users logged in
   904  ## Set of usernames that are allowed to log in.
   906  #  Use this with supported authenticators to restrict which users can log in.
   936  ## Set of usernames that are not allowed to log in.
   938  #  Use this with supported authenticators to restrict which users can not log in.
  1020  #  user logs in again.

 

[centos7copy]$ cat -n /etc/jupyterhub_config.py

----(略)----

    236 ## DEPRECATED: use output redirection instead, e.g.  ←非推奨とのこと
    237 #
    238 #  jupyterhub &>> /var/log/jupyterhub.log
    239 #c.JupyterHub.extra_log_file = ''                                    ←こっちでlogを指定する。
    240
    241 ## Extra log handlers to set on JupyterHub logger
    242 #c.JupyterHub.extra_log_handlers = []

----(略)----

※非推奨だけど下記のようにログ取得もできる。

[centos7copy]$ jupyterhub -f /etc/jupyterhub_config.py >> /var/log/jupyterhub.log 2>&1 &

■logローテーション

上記のc.JupyterHub.extra_log_fileにログを書き込んでrenameした後もログが書き込まれるか?

[centos7copy]$ cp -p  /etc/jupyterhub_config.py  /etc/jupyterhub_config.py.org
[centos7copy]$ vi  /etc/jupyterhub_config.py

----(編集)----
[centos7copy]$ diff  /etc/jupyterhub_config.py{.org,}
239a240
> c.JupyterHub.extra_log_file = '/tmp/chinko.log'

・jupyterhubをバックグラウンド実行してるterminalにて下記によりjupyterhubを終了

[centos7copy]$ kill %1

----(略)----

・jupyterhubを再起動

[centos7copy]$  jupyterhub -f /etc/jupyterhub_config.py &

----(略)----

→以前ターミナルには標準出力と標準エラー出力が出力されているw

[centos7copy]$ ll /tmp/chinko.log
-rw-r--r--. 1 root root 1806 Nov 15 23:11 /tmp/chinko.log

[centos7copy]$ head -2 /tmp/chinko.log
[I 2020-11-15 23:11:46.804 JupyterHub app:2332] Running JupyterHub version 1.2.1
[I 2020-11-15 23:11:46.805 JupyterHub app:2363] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.2.1

[centos7copy]$ tail -2 /tmp/chinko.log
[I 2020-11-15 23:11:58.559 JupyterHub proxy:400] Adding default route for Hub: / => http://127.0.0.1:8081
[I 2020-11-15 23:11:58.563 JupyterHub app:2722] JupyterHub is now running at http://:8000

・ログエントリを追記してみる。

[centos7copy]$ curl -X POST -d 'unko=unchi' http://127.0.0.1:8081

----(略)----

[centos7copy]$ tail -1 /tmp/chinko.log
[W 2020-11-15 23:20:40.084 JupyterHub log:181] 405 POST / (@127.0.0.1) 1.32ms

・ログファイルをリネームしてみる

[centos7copy]$ mv /tmp/chinko.log{,old}
[centos7copy]$ ll /tmp/chinko.log*

-rw-r--r--. 1 root root 2332 Nov 15 23:21 /tmp/chinko.logold

[centos7copy]$ curl -X POST -d 'unko=unchi' http://127.0.0.1:8081

----(略)----

[centos7copy]$ ll /tmp/chinko.log*
-rw-r--r--. 1 root root 2421 Nov 15 23:23 /tmp/chinko.logold

[centos7copy]$ tail -3 /tmp/chinko.logold
[W 2020-11-15 23:20:40.084 JupyterHub log:181] 405 POST / (@127.0.0.1) 1.32ms  ←リネーム前のエントリ
[I 2020-11-15 23:21:58.575 JupyterHub proxy:320] Checking routes
[W 2020-11-15 23:23:40.296 JupyterHub log:181] 405 POST / (@127.0.0.1) 1.80ms  ←リネーム後のエントリ

 

→ログファイル名をリネームしてもリネーム前のログファイルにログを追記したので、jupyterhubのログローテーション時にはデーモンの再起動かリロードが必要

[centos7copy]$ jupyterhub --help | grep -i reload;echo $?
1

リロードできないっぽい。

グレイスフルリスタートとかあるのかな?よくわかんないけど。apacheとかnginxをかましてフロントエンドリバースプロキシでやるしかない臭い。

ちなみに、jupyterhub_config.pyの「c.JupyterHub.extra_log_file」パラメータでログファイルを指定しても下記のように、起動したptsに標準出力と標準エラー出力が紐づいている。

[centos7copy]$ ps -ef | grep jupyterhu[b]
root      81721   4962  0 23:11 pts/1    00:00:00 /usr/bin/python3 /usr/local/bin/jupyterhub -f /etc/jupyterhub_config.py
[centos7copy]$ lsof -p 81721 | egrep [012]u
jupyterhu 81721 root    0u      CHR              136,1       0t0        4 /dev/pts/1
jupyterhu 81721 root    1u      CHR              136,1       0t0        4 /dev/pts/1
jupyterhu 81721 root    2u      CHR              136,1       0t0        4 /dev/pts/1

 

■公式サイト

https://redis.io

 

■公式ドキュメント

https://redis.io/documentatio

 

■インストーラ―ダウンロード

上記公式サイトトップページの「Download it」のRedis 6.0.9 is the latest stable version.リンクをクリックすると、最新安定板のtarボールがダウンロードされる。

上記からダウンロードしたredis-6.0.9.tar.gzを/usr/local/srcにコピーして展開

[centos7copy]$ pwd
/usr/local/src/redis-6.0.9
[centos7copy]$ ll
total 292
-rw-rw-r--.  1 root root 108806 Oct 27 16:12 00-RELEASENOTES
-rw-rw-r--.  1 root root     51 Oct 27 16:12 BUGS
-rw-rw-r--.  1 root root   2499 Oct 27 16:12 CONTRIBUTING
-rw-rw-r--.  1 root root   1487 Oct 27 16:12 COPYING
drwxrwxr-x.  6 root root   4096 Oct 27 16:12 deps
-rw-rw-r--.  1 root root     11 Oct 27 16:12 INSTALL
-rw-rw-r--.  1 root root    151 Oct 27 16:12 Makefile
-rw-rw-r--.  1 root root   6888 Oct 27 16:12 MANIFESTO
-rw-rw-r--.  1 root root  21099 Oct 27 16:12 README.md
-rw-rw-r--.  1 root root  84841 Oct 27 16:12 redis.conf
-rwxrwxr-x.  1 root root    275 Oct 27 16:12 runtest
-rwxrwxr-x.  1 root root    280 Oct 27 16:12 runtest-cluster
-rwxrwxr-x.  1 root root    795 Oct 27 16:12 runtest-moduleapi
-rwxrwxr-x.  1 root root    281 Oct 27 16:12 runtest-sentinel
-rw-rw-r--.  1 root root  10744 Oct 27 16:12 sentinel.conf
drwxrwxr-x.  3 root root   4096 Oct 27 16:12 src
drwxrwxr-x. 11 root root   4096 Oct 27 16:12 tests
-rw-rw-r--.  1 root root   3055 Oct 27 16:12 TLS.md
drwxrwxr-x.  9 root root   4096 Oct 27 16:12 utils

上記の「README.md」を見ると、makeしてmake installすればとりあえずインストールできるって書かれていたのでこの通りやったら、エラーでまくり。

google先生したら、redis6.0.9のgccは4.9以上じゃないとだめらしい。

https://stackoverflow.com/questions/61535050/redis-build-failure

よくわかんないから、gccのミラーサイトからダウンロード

[centos7copy]$ cd /usr/local/src/

[centos7copy]$ wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.9.4/gcc-4.9.4.tar.gz

 

[centos7copy]$ tar xf gcc-4.9.4.tar.gz

[centos7copy]$ cd gcc-4.9.4

下記を猿真似してgccをインストール

https://qiita.com/liveralmask/items/6ed4a98ebb3bf6b7f707

[centos7copy]$  ./contrib/download_prerequisites

 

←gccのビルドに必要なモジュールをダウンロードするらしい。よくわかんないけど。

[centos7copy]$ ../configure --enable-languages=c,c++ --prefix=/usr/local --disable-bootstrap --disable-multilib

←上記サイトによるとこれらのオプションが必要らしい。よくわかんないけど。

[centos7copy]$ echo $?
130

→ぷに。まあいっか。

[centos7copy]$ make

→20分くらいかかったw

[centos7copy]$ make install

→1分くらいで完了。

[centos7copy]$ /usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.4/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --prefix=/usr/local --disable-bootstrap --disable-multilib
Thread model: posix
gcc version 4.9.4 (GCC)

[centos7copy]$ /usr/local/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.4/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --prefix=/usr/local --disable-bootstrap --disable-multilib
Thread model: posix
gcc version 4.9.4 (GCC)

→インストールできたくさい。

redis-6.0.9のインストールを上記のgccを指定して実行

[centos7copy]$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/oracle/product/18c/dbhome_1/bin:/root/bin:/opt/oracle/product/18c/dbhome_1/bin
[centos7copy]$ which gcc
/usr/local/bin/gcc

[centos7copy]$ cd /usr/local/src/redis-6.0.9

[centos7copy]$ pwd
/usr/local/src/redis-6.0.9

[centos7copy]$ make distclean

[centos7copy]$ make

→やっぱりエラー出まくりw うそだったくさいw

もう一度redis公式サイトからold version(5.0.10)をダウンロードしてためす。

[centos7copy]$ cd /usr/local/src/r

[centos7copy]$ wget https://download.redis.io/releases/redis-5.0.10.tar.gz?_ga=2.20773360.973794997.1604063364-421086587.1604063364

[centos7copy]$ mv redis-5.0.10.tar.gz?_ga=2.20773360.973794997.1604063364-421086587.1604063364 redis-5.0.10.tar.gz

[centos7copy]$ tar xf redis-5.0.10.tar.gz
[centos7copy]$ cd redis-5.0.10
[centos7copy]$ make

[centos7copy]$ make install

cd src && make install
make[1]: Entering directory `/usr/local/src/redis-5.0.10/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/src/redis-5.0.10/src'
make[1]: Entering directory `/usr/local/src/redis-5.0.10/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/src/redis-5.0.10/src'

[centos7copy]$ ll /usr/local/bin/redis-*
-rwxr-xr-x. 1 root root 4695056 Oct 31 00:50 /usr/local/bin/redis-benchmark
-rwxr-xr-x. 1 root root 8462304 Oct 31 00:50 /usr/local/bin/redis-check-aof
-rwxr-xr-x. 1 root root 8462304 Oct 31 00:50 /usr/local/bin/redis-check-rdb
-rwxr-xr-x. 1 root root 5136288 Oct 31 00:50 /usr/local/bin/redis-cli
lrwxrwxrwx. 1 root root      12 Oct 31 00:50 /usr/local/bin/redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 8462304 Oct 31 00:50 /usr/local/bin/redis-server

[centos7copy]$ /usr/local/bin/redis-server --version
Redis server v=5.0.10 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=6e70b1f684c53f2c

→出来たんギラス。

・redis起動

※README.mdによると、./redis-server /path/to/redis.confってするのが普通らしい。ちなみに、redis.confはtarを展開したとこに居る。

[centos7copy]$ ls -l /usr/local/src/redis-5.0.10/
total 288
-rw-rw-r--.  1 root root 123280 Oct 27 15:49 00-RELEASENOTES
-rw-rw-r--.  1 root root     53 Oct 27 15:49 BUGS
-rw-rw-r--.  1 root root   2381 Oct 27 15:49 CONTRIBUTING
-rw-rw-r--.  1 root root   1487 Oct 27 15:49 COPYING
drwxrwxr-x.  6 root root   4096 Oct 31 00:45 deps
-rw-r--r--.  1 root root     93 Oct 31 00:57 dump.rdb
-rw-rw-r--.  1 root root     11 Oct 27 15:49 INSTALL
-rw-rw-r--.  1 root root    151 Oct 27 15:49 Makefile
-rw-rw-r--.  1 root root   6888 Oct 27 15:49 MANIFESTO
-rw-rw-r--.  1 root root  20555 Oct 27 15:49 README.md
-rw-rw-r--.  1 root root  61797 Oct 27 15:49 redis.conf
-rwxrwxr-x.  1 root root    275 Oct 27 15:49 runtest
-rwxrwxr-x.  1 root root    280 Oct 27 15:49 runtest-cluster
-rwxrwxr-x.  1 root root    373 Oct 27 15:49 runtest-moduleapi
-rwxrwxr-x.  1 root root    281 Oct 27 15:49 runtest-sentinel
-rw-rw-r--.  1 root root   9710 Oct 27 15:49 sentinel.conf
drwxrwxr-x.  3 root root   4096 Oct 31 00:50 src
drwxrwxr-x. 11 root root   4096 Oct 27 15:49 tests
drwxrwxr-x.  8 root root   4096 Oct 27 15:49 utils

※また、同じくREADME.mdに下記のような起動オプションの例が書かれていた。

$ ./redis-server --port 9999 --replicaof 127.0.0.1 6379
$ ./redis-server /etc/redis/6379.conf --loglevel debug

 

[centos7copy]$ /usr/local/bin/redis-server &
[1] 52580
[centos7copy]$ 52580:C 31 Oct 2020 00:56:47.121 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52580:C 31 Oct 2020 00:56:47.121 # Redis version=5.0.10, bits=64, commit=00000000, modified=0, pid=52580, just started
52580:C 31 Oct 2020 00:56:47.121 # Warning: no config file specified, using the default config. In order to specify a config file use /usr/local/bin/redis-server /path/to/redis.conf
52580:M 31 Oct 2020 00:56:47.122 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 52580
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

52580:M 31 Oct 2020 00:56:47.123 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
52580:M 31 Oct 2020 00:56:47.123 # Server initialized
52580:M 31 Oct 2020 00:56:47.123 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
52580:M 31 Oct 2020 00:56:47.123 * Ready to accept connections

[centos7copy]$ ps -ef| grep redi[s]
root      52634  18523  0 00:57 pts/0    00:00:00 /usr/local/bin/redis-server *:6379

[centos7copy]$ netstat -naptl | grep 6379
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      52634/redis-server
tcp6       0      0 :::6379                 :::*                    LISTEN      52634/redis-server

→起動してるくさい

・クライアントから接続

[centos7copy]$ /usr/local/bin/redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> incr mycounter
(integer) 1
127.0.0.1:6379> incr mycounter
(integer) 2

127.0.0.1:6379> incr mycounter
(integer) 3
127.0.0.1:6379> set "Hello" "World"
OK
127.0.0.1:6379> get Hello
"World"
127.0.0.1:6379> exit

→レディれたンゴ

 

■redisのコマンド

http://redis.io/commands.

 

■logファイル

README.mdによると、redis-server /Path/To/redis.confでredis.confを読み込んでデーモンが実行するらしい。

そんでtarボールに付属していたredis.confを適当な場所(たとえば/usr/local/etc/redis.confとか)にコピーして実行するとすると、logファイルは、上記のredis.confに記載して指定する。ちなみに下記の通り

 

 [centos7copy]$ cat -n /usr/local/src/redis-5.0.10/redis.conf

----(略)----

    168 # Specify the log file name. Also the empty string can be used to force
    169 # Redis to log on the standard output. Note that if you use standard
    170 # output for logging but daemonize, logs will be sent to /dev/null
    171 logfile ""
    172
    173 # To enable logging to the system logger, just set 'syslog-enabled' to yes,
    174 # and optionally update the other syslog parameters to suit your needs.
    175 # syslog-enabled no
    176
    177 # Specify the syslog identity.
    178 # syslog-ident redis
    179
    180 # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
    181 # syslog-facility local0
    182
    183 # Set the number of databases. The default database is DB 0, you can select
    184 # a different one on a per-connection basis using SELECT <dbid> where
    185 # dbid is a number between 0 and 'databases'-1
    186 databases 16

----(略)----

 

[centos7copy]$ ps -ef | grep redi[s]
root      52634      1  0 Oct31 ?        00:03:51 /usr/local/bin/redis-server *:6379

[centos7copy]$ lsof -p 52634
COMMAND     PID USER   FD      TYPE DEVICE  SIZE/OFF   NODE NAME
redis-ser 52634 root  cwd       DIR    8,2      4096  21772 /usr/local/src/redis-5.0.10
redis-ser 52634 root  rtd       DIR    8,2      4096      2 /
redis-ser 52634 root  txt       REG    8,2   8462304 950046 /usr/local/bin/redis-server
redis-ser 52634 root  mem       REG    8,2 106172832 138666 /usr/lib/locale/locale-archive
redis-ser 52634 root  mem       REG    8,2   2156240 919299 /usr/lib64/libc-2.17.so
redis-ser 52634 root  mem       REG    8,2    142144 919325 /usr/lib64/libpthread-2.17.so
redis-ser 52634 root  mem       REG    8,2     43712 925847 /usr/lib64/librt-2.17.so
redis-ser 52634 root  mem       REG    8,2     19248 925840 /usr/lib64/libdl-2.17.so
redis-ser 52634 root  mem       REG    8,2   1136944 925841 /usr/lib64/libm-2.17.so
redis-ser 52634 root  mem       REG    8,2    163312 919292 /usr/lib64/ld-2.17.so
redis-ser 52634 root    0u      CHR  136,0       0t0      3 /dev/pts/0 (deleted)
redis-ser 52634 root    1u      CHR  136,0       0t0      3 /dev/pts/0 (deleted)
redis-ser 52634 root    2u      CHR  136,0       0t0      3 /dev/pts/0 (deleted)
redis-ser 52634 root    3r     FIFO    0,9       0t0 161955 pipe
redis-ser 52634 root    4w     FIFO    0,9       0t0 161955 pipe
redis-ser 52634 root    5u  a_inode   0,10         0   8534 [eventpoll]
redis-ser 52634 root    6u     IPv6 161956       0t0    TCP *:6379 (LISTEN)
redis-ser 52634 root    7u     IPv4 161957       0t0    TCP *:6379 (LISTEN)

[centos7copy]$ lsof /var/log/redis_6379.log;echo $?
1

 

■初期設定

redis-6.0.9ではmakeにsystemdを指定するコンパイルオプションつけてbuildすればsystemdでデーモンを制御できるようにbuildされる。

redis-5.0.10では、make、make install後、/usr/local/src/redis-5.0.10/utils/install_server.sh

を実行すると、initスクリプトが作られる。

[centos7copy]$ ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/src/redis-5.0.10/redis.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port           : 6379
Config file    : /usr/local/src/redis-5.0.10/redis.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.

Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

ちなみに作られたinitスクリプトは下記の通り

[centos7copy]$ cat -n /etc/rc.d/init.d/redis_6379
     1  #!/bin/sh
     2  #Configurations injected by install_server below....
     3
     4  EXEC=/usr/local/bin/redis-server
     5  CLIEXEC=/usr/local/bin/redis-cli
     6  PIDFILE=/var/run/redis_6379.pid
     7  CONF="/usr/local/src/redis-5.0.10/redis.conf"
     8  REDISPORT="6379"
     9  ###############
    10  # SysV Init Information
    11  # chkconfig: - 58 74
    12  # description: redis_6379 is the redis daemon.
    13  ### BEGIN INIT INFO
    14  # Provides: redis_6379
    15  # Required-Start: $network $local_fs $remote_fs
    16  # Required-Stop: $network $local_fs $remote_fs
    17  # Default-Start: 2 3 4 5
    18  # Default-Stop: 0 1 6
    19  # Should-Start: $syslog $named
    20  # Should-Stop: $syslog $named
    21  # Short-Description: start and stop redis_6379
    22  # Description: Redis daemon
    23  ### END INIT INFO
    24
    25
    26  case "$1" in
    27      start)
    28          if [ -f $PIDFILE ]
    29          then
    30              echo "$PIDFILE exists, process is already running or crashed"
    31          else
    32              echo "Starting Redis server..."
    33              $EXEC $CONF
    34          fi
    35          ;;
    36      stop)
    37          if [ ! -f $PIDFILE ]
    38          then
    39              echo "$PIDFILE does not exist, process is not running"
    40          else
    41              PID=$(cat $PIDFILE)
    42              echo "Stopping ..."
    43              $CLIEXEC -p $REDISPORT shutdown
    44              while [ -x /proc/${PID} ]
    45              do
    46                  echo "Waiting for Redis to shutdown ..."
    47                  sleep 1
    48              done
    49              echo "Redis stopped"
    50          fi
    51          ;;
    52      status)
    53          PID=$(cat $PIDFILE)
    54          if [ ! -x /proc/${PID} ]
    55          then
    56              echo 'Redis is not running'
    57          else
    58              echo "Redis is running ($PID)"
    59          fi
    60          ;;
    61      restart)
    62          $0 stop
    63          $0 start
    64          ;;
    65      *)
    66          echo "Please use start, stop, restart or status as first argument"
    67          ;;
    68  esac

[centos7copy]$ pwd
/usr/local/src/redis-5.0.10
[centos7copy]$ diff redis.conf.org redis.conf
0a1,2
> ## Generated by install_server.sh ##
> ## Generated by install_server.sh ##
136c138
< daemonize no
---
> daemonize yes
171c173
< logfile ""
---
> logfile /var/log/redis_6379.log
263c265
< dir ./
---
> dir /var/lib/redis/6379

 

■その他参考情報

Qiita 【入門】Redis