# HG changeset patch # User Oleksandr Gavenko # Date 1546546398 -7200 # Node ID c44e4331713c571f62ea4e623f9ec0c94a62779e # Parent 3a371f9736447444d7433d1e8e0375a344e968dc# Parent c3baf557ff0c3f74a73c01af3b15d9d8a0e22938 merged diff -r c3baf557ff0c -r c44e4331713c alpine.rst --- a/alpine.rst Tue Aug 01 01:00:35 2017 +0300 +++ b/alpine.rst Thu Jan 03 22:13:18 2019 +0200 @@ -56,8 +56,27 @@ Install package:: $ sudo apk add bash + +Install local package:: + $ sudo apk add --allow-untrusted /path/to/file.apk +To install package from specific Alpine release tag extra repository URL in +``/etc/apk/repositories``:: + + @edge http://nldl-cdn.alpinelinux.org/alpine/edge/main + +and pin dependencies to tag:: + + $ sudo apk add bash@edge + +To avoid registering repository in ``/etc/apk/repositories`` pass repository URL and fixate package +version:: + + $ sudo apk add postgresql==9.6.10-r0 --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.6/main + +To select Alpine release, package and package version use https://pkgs.alpinelinux.org/packages + Do not grab package index with ``--no-cache`` option to reduce installation size:: $ apk add --no-cache bash diff -r c3baf557ff0c -r c44e4331713c cygwin.rst --- a/cygwin.rst Tue Aug 01 01:00:35 2017 +0300 +++ b/cygwin.rst Thu Jan 03 22:13:18 2019 +0200 @@ -124,8 +124,10 @@ $ apt-cyg cache ~/net Cache set to C:\home\net. +https://github.com/kou1okada/apt-cyg + Still maintained project with extra features. https://github.com/transcode-open/apt-cyg/ - Home page. + Home page of abandoned project. https://github.com/transcode-open/apt-cyg/issues/19 Request to support multiply sources. http://stackoverflow.com/questions/22411162/how-to-add-a-repository-using-apt-cyg/ @@ -134,6 +136,22 @@ Depricated way to install from several sources with ``-m`` option using shell aliases as a trick. +Cygwin bash completion +====================== + +Cygwin ``bash`` has extra patch that adds ``completion_strip_exe`` option:: + + shopt -s completion_strip_exe + +If you complete executable ``.exe`` suffix is stripped if any. That halps with ``bash-completion`` +because usually comletion defined for base name without ``.exe`` suffix, like:: + + complete -F _figlet figlet + +https://github.com/cygwinports/bash + 7b. completion_strip_exe - using 'shopt -s completion_strip_exe' + makes completion strip .exe suffixes. + Cygwin file permission ====================== diff -r c3baf557ff0c -r c44e4331713c debian-apt.rst --- a/debian-apt.rst Tue Aug 01 01:00:35 2017 +0300 +++ b/debian-apt.rst Thu Jan 03 22:13:18 2019 +0200 @@ -65,6 +65,34 @@ https://www.google.com/linuxrepositories/ Links to Google repositories and verification key. +Enable/disable recommends and suggestions +========================================= + +To disable installation of recommended packages (which is by default) create file +``/etc/apt/apt.conf.d/01no-recommends``:: + + APT::Install-Recommends "0"; + APT::AutoRemove::RecommendsImportant "1"; + + APT::Install-Suggests "0"; + +Alternatively pass corresponding option to installation utility to suppress installation of +recommended packages:: + + apt --no-install-recommends + aptitude --without-recommends + aptitude -R + +To install suggested packages:: + + apt --install-suggests + aptitude --install-suggests + +Verify settings:: + + apt-config dump | fgrep -i recommend + apt-config dump | fgrep -i suggest + Find nearest mirror =================== @@ -300,3 +328,10 @@ $ sudo apt-get upgrade -s $ sudo aptitude upgrade -s +Making aptitude forget changes +============================== + +Following removes or override (like "hold" status) ``aptitude`` package state DB:: + + sudo rm /var/lib/aptitude/pkgstates + sudo aptitude keep-all diff -r c3baf557ff0c -r c44e4331713c elasticsearch.rst --- a/elasticsearch.rst Tue Aug 01 01:00:35 2017 +0300 +++ b/elasticsearch.rst Thu Jan 03 22:13:18 2019 +0200 @@ -11,6 +11,63 @@ https://amsterdam.luminis.eu/2016/10/18/elasticsearch-5-is-coming-what-is-new-and-improved/ New features of ES 5. +Releases +======== + +https://github.com/elastic/elasticsearch/releases + Git releases & tags. +https://www.elastic.co/support/eol + Elastic Product End of Life Dates. + +Installing & configuring +======================== + +https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html + Install Elasticsearch with Debian Package. + +Basic config +============ + +Common cluster name inside given intranet:: + + cluster.name: mycluster + +Unique node name within claser:: + + node.name: "node1" + +Node types:: + + node.master: true + node.ingest: true + node.data: true + +Network interfaces to bind to:: + + network.host: [_local_, node1.example.com] + +Port definitions:: + + http.port : 9200 + tcp.port : 9300 + +Override default locations:: + + path.data: /path/to/data1,/path/to/data2 + path.logs: /path/to/logs + path.plugins: /path/to/plugins + +Explicit list of seed nodes in cluster:: + + discovery.zen.ping.unicast.hosts: ["master1.example.com", "master2.example.com:9300"] + +https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html + Node types. +https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery-zen.html + Discovery settings. +https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-transport.html + Transport definitions. + REST syntax conventions ======================= @@ -41,6 +98,7 @@ List cluster state:: GET /_cluster/state?pretty + GET /_cluster/allocation/explain List of tasks executed in cluster:: @@ -66,6 +124,8 @@ https://www.elastic.co/guide/en/elasticsearch/reference/current/_cluster_health.html Cluster Health. +https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html + Cluster Allocation Explain API https://www.elastic.co/guide/en/elasticsearch/reference/current/_list_all_indices.html List All Indices. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html diff -r c3baf557ff0c -r c44e4331713c lxc.rst --- a/lxc.rst Tue Aug 01 01:00:35 2017 +0300 +++ b/lxc.rst Thu Jan 03 22:13:18 2019 +0200 @@ -6,12 +6,34 @@ .. contents:: :local: +LXC releases +============ + +https://discuss.linuxcontainers.org/tags/release + Announces of LXC & LXD releases. +https://discuss.linuxcontainers.org/t/lxc-3-0-0-has-been-released/1449 + LXC 3.0.0 has been released. + +Supported templates +=================== + +https://github.com/lxc/lxc-templates + Old style template scripts for LXC (prefer distrobuilder). +https://github.com/lxc/distrobuilder + System container image builder for LXC and LXD. +https://brauner.github.io/2018/02/27/lxc-removes-legacy-template-build-system.html + Details about replacing template stripts. + Install LXC under Debian ======================== :: $ sudo apt-get install lxc +Verify your host/kernel satisfy LXC requirements:: + + $ sudo lxc-checkconfig + To make network bridge install supplement packages:: $ sudo apt-get install bridge-utils dnsmasq @@ -34,30 +56,52 @@ $ sudo service lxc-net start -Check installation with:: - - $ sudo lxc-checkconfig - Create new container in LXC =========================== -``-t`` defines distro name, ``-n`` gives name for container for further -referencing, ``--`` allow pass options to template script, ``-r`` specifies -Debian release:: +Create container from template:: + + $ sudo lxc-create -t $TMPL -n $NAME -- $EXTRA_ARGS - $ sudo lxc-create -t debian -n debtest -- -r sid +.. note:: + * ``-t`` defines distro name + * ``-n`` gives name for container for further referencing + * everything after ``--`` is passed to template script + +Template name is based on file name from ``/usr/share/lxc/templates`` directory without ``lxc-`` +prefix. -In order to use another miror:: +List available templates with:: + + $ ls -alh /usr/share/lxc/templates/ + +Examples of container creation command:: - $ MIRROR=http://httpredir.debian.org/debian sudo lxc-create -t debian -n debtest -- -r sid + $ sudo lxc-create -t debian -n deb-sid -- -r sid --enable-non-free + $ sudo lxc-create -t debian -n deb-testing -- -r testing + $ sudo lxc-create -t debian -n deb-stable -- -r stable -a amd64 -Getting help for template specific options:: + $ sudo lxc-create -t alpine -n alpine-3.7 -- -r 3.7 + +Each template has own options, which can be passed after ``--``. To get help on template specific +options run:: $ /usr/share/lxc/templates/lxc-ubuntu -h $ /usr/share/lxc/templates/lxc-debian -h $ /usr/share/lxc/templates/lxc-alpine -h ... +For Debian in order to use another miror:: + + $ MIRROR=http://httpredir.debian.org/debian sudo lxc-create -t debian -n debtest -- -r sid + +Since LXC v3.0 sh-templates moved to separate project and only 4 are left supported:: + + $ lxc-create my-busybox -t busybox + $ lxc-create my-x -t download + $ lxc-create c1 -t local -- --metadata /path/to/meta.tar.xz --fstree /path/to/rootfs.tar.xz + $ lxc-create c2 -t oci -- --url docker://alpine + Put ``veth`` network configuration into container config ``/var/lib/lxc/$NAME/config``:: lxc.network.type = veth @@ -83,7 +127,7 @@ $ sudo lxc-start -n $NAME -Safely stop VM (with honer of init system):: +Safely stop VM (honoring init system):: $ sudo lxc-halt -n $NAME diff -r c3baf557ff0c -r c44e4331713c mumble.rst --- a/mumble.rst Tue Aug 01 01:00:35 2017 +0300 +++ b/mumble.rst Thu Jan 03 22:13:18 2019 +0200 @@ -13,8 +13,14 @@ https://wiki.mumble.info/wiki/Running_Murmur Running Murmur. https://wiki.mumble.info/wiki/Murmurguide - Setting Up a Murmur Server. + Setting Up a Murmur Server and managing ACL. +https://wiki.mumble.info/wiki/Authentication + Authentication +https://wiki.mumble.info/wiki/3rd_Party_Applications + 3rd Party Applications. https://wiki.mumble.info/wiki/FAQ/English FAQ. +https://wiki.mumble.info/wiki/Obtaining_a_Let%27s_Encrypt_Murmur_Certificate + Obtaining a Let's Encrypt Murmur Certificate. https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-mumble-server-murmur-on-ubuntu-14-04 How To Install and Configure Mumble Server (Murmur) on Ubuntu 14.04 diff -r c3baf557ff0c -r c44e4331713c postgres.rst --- a/postgres.rst Tue Aug 01 01:00:35 2017 +0300 +++ b/postgres.rst Thu Jan 03 22:13:18 2019 +0200 @@ -35,6 +35,19 @@ https://wiki.debian.org/PostgreSql Debian wiki instructions. +Check version +============= + +By SQL query:: + + SELECT version(); + SHOW server_version; + SHOW server_version_num; + +From executable:: + + $ postgres -V + Check locations =============== :: @@ -42,6 +55,55 @@ SHOW hba_file; SHOW config_file; +Check settings +============== +:: + + SELECT name, setting FROM pg_settings; + +Check extensions +================ +:: + + SELECT * FROM pg_available_extensions; + +Grant role options +================== +:: + + ALTER USER me WITH SUPERUSER; + ALTER USER me WITH CREATEDB CREATEROLE LOGIN; + +https://www.postgresql.org/docs/current/sql-createrole.html + ``CREATE ROLE``. + +Change password +=============== +:: + + ALTER USER me WITH PASSWORD 'PassWord'; + +Monitor connections +=================== +:: + + select * from pg_stat_activity; + +https://www.postgresql.org/docs/current/monitoring-stats.html + The Statistics Collector. + +Profile queries +=============== + +Stats on query execution time:: + + SELECT * FROM pg_stat_statements; + +https://www.postgresql.org/docs/current/pgstatstatements.html + ``pg_stat_statements``. +https://www.postgresql.org/docs/current/indexes-examine.html + Examining Index Usage. + List databases, schemas and tables ================================== @@ -62,14 +124,14 @@ Schemas:: - => select schema_name from information_schema.schemata; - => select nspname from pg_catalog.pg_namespace; - => \dn * + \dn * + select schema_name from information_schema.schemata; + select nspname from pg_catalog.pg_namespace; To list all tables in the current database:: - => SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name; - => \dt + \dt + SELECT table_schema, table_name FROM information_schema.tables ORDER BY table_schema, table_name; or in all schemas:: @@ -91,6 +153,68 @@ List indexes:: \di + select * from pg_indexes; + select * from pg_indexes where schemaname = '...'; + select * from pg_indexes where schemaname = '...' and tablename = '...'; + select * from pg_indexes where schemaname = '...' and indexname = '...'; + + select + t.relname as table_name, + i.relname as index_name, + a.attname as column_name + from + pg_class t, + pg_class i, + pg_index ix, + pg_attribute a + where + t.oid = ix.indrelid + and i.oid = ix.indexrelid + and a.attrelid = t.oid + and a.attnum = ANY(ix.indkey) + and t.relkind = 'r' + and t.relname like 'test%' + order by + t.relname, + i.relname; + + select + t.relname as table_name, + i.relname as index_name, + array_to_string(array_agg(a.attname), ', ') as column_names + from + pg_class t, + pg_class i, + pg_index ix, + pg_attribute a + where + t.oid = ix.indrelid + and i.oid = ix.indexrelid + and a.attrelid = t.oid + and a.attnum = ANY(ix.indkey) + and t.relkind = 'r' + and t.relname like 'test%' + group by + t.relname, + i.relname + order by + t.relname, + i.relname; + +List index usage:: + + SELECT * FROM pg_stat_all_indexes; + SELECT * FROM pg_stat_all_tables; + SELECT * FROM pg_stat_user_indexes; + SELECT * FROM pg_stat_user_tables; + +List constraints:: + + SELECT * FROM pg_constraint; + SELECT * FROM pg_constraint WHERE conrelid = (SELECT oid FROM pg_class WHERE relname LIKE 'tblName'); + +https://www.postgresql.org/docs/current/catalog-pg-constraint.html + pg_constraint. List functions:: @@ -100,7 +224,6 @@ \dy - List misc info:: select current_database(); @@ -148,6 +271,22 @@ SELECT relname, relpages FROM pg_class ORDER BY relpages DESC; +MVCC and transaction id +======================= + +As being MVCC Postgres doesn't delete or update existing rows. Row visibility is controled by +transaction id (monotonous incremented number): ``xmin`` - first transaction that can see row, +``xmax`` - last transaction that can see row::: + + SELECT xmin, xmax, * FROM foo WHERE id < 5 ORDER BY id; + +Vacuum +====== + +Stats on vacuum oprtations per table:: + + select * from pg_stat_user_tables; + Using psql client ================= @@ -202,3 +341,32 @@ $ psql -U $USER -h $HOST $DB -c "\\copy tbl_name from 'my.csv' csv" +JDBC driver +=========== + +https://jdbc.postgresql.org/about/about.html + The current version of the driver should be compatible with PostgreSQL 8.2 and higher, and Java 6 + (JDBC 4.0), Java 7 (JDBC 4.1), Java 8 (JDBC 4.2) and Java 9. +https://jdbc.postgresql.org/download.html + Java/JDBC/Postgres compatibility table. + +plpgsql +======= + +Simple function:: + + CREATE OR REPLACE FUNCTION incx(x INTEGER) + RETURNS INTEGER STABLE AS $$ + BEGIN + RETURN x + 1; + END; + $$ LANGUAGE plpgsql; + +Support for procedures is added only in Postgres v11. + +https://www.postgresql.org/docs/current/sql-createfunction.html + ``CREATE FUNCTION``. +https://www.postgresql.org/docs/current/plpgsql-control-structures.html + plpgsql control structures. +https://www.postgresql.org/docs/current/errcodes-appendix.html + PostgreSQL Error Codes. \ No newline at end of file diff -r c3baf557ff0c -r c44e4331713c systemd.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/systemd.rst Thu Jan 03 22:13:18 2019 +0200 @@ -0,0 +1,38 @@ + +========= + Systemd +========= + +Managing services +================= + +Display service details/status:: + + $ sudo systemctl show my.service + $ sudo systemctl status my.service + +Start/stop service:: + + $ sudo systemctl start repricer-server.service + $ sudo systemctl stop repricer-server.service + $ sudo systemctl restart repricer-server.service + +Enabling/disabling service:: + + $ sudo systemctl enable my.service + $ sudo systemctl disable my.service + +Systemd journal +=============== + +Get service console output:: + + $ journalctl -u repricer-server.service + +Like ``tail -n 20``:: + + $ journalctl -n 20 ... + +Like ``tail -f``:: + + $ journalctl -f ...