domenica 5 marzo 2017

Customization of the X keybindings with xmodmap

Here is how I customized the X keybindings with the purpose to make Lisp-editing on Emacs more comfortable.

$ xmodmap -pke # read the current configuration
...
$ cat .xsession
xmodmap ~/.Xmodmap
gnome-session
$ cat ~/.Xmodmap
! set F5, F6, F7, F8, F9 to control, alt, shift, (, )

clear control
clear mod1

keycode  71 = Control_L
keycode  72 = Alt_L Meta_L
keycode  73 = Shift_L
keycode  74 = parenleft
keycode  75 = parenright

add control = Control_L Control_R
add mod1 = Alt_L Meta_L
$ xmodmap ~/.Xmodmap # load the personalized bindings
$

Many thanks to Xah Lee for his tutorials: Linux Keybinding How-to

sabato 17 settembre 2016

Getting started with MongoDB on CentOS

Some notes about installing and using MongoDB on CentOS 7.

The notes are based on documentation found at http://docs.mongodb.com.

Installation

[root@mongodbhost1 ~]# ed
f /etc/yum.repos.d/mongodb-org-3.2.repo
/etc/yum.repos.d/mongodb-org-3.2.repo
a
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
.
w
202
q
[root@mongodbhost1 ~]# yum search mongodb
...
mongodb-org.x86_64 : MongoDB open source document-oriented database system (metapackage)
mongodb-org-mongos.x86_64 : MongoDB sharded cluster query router
mongodb-org-server.x86_64 : MongoDB database server
mongodb-org-shell.x86_64 : MongoDB shell client
mongodb-org-tools.x86_64 : MongoDB tools

  Name and summary matches only, use "search all" for everything.
[root@mongodbhost1 ~]# yum install -y mongodb-org
...
[root@mongodbhost1 ~]#

Startup

[root@mongodbhost1 ~]# service mongod start
Starting mongod (via systemctl):                           [  OK  ]
[root@mongodbhost1 ~]# ps -efa | grep mongo
mongod   17481     1  8 14:47 ?        00:00:00 /usr/bin/mongod -f /etc/mongod.conf
root     17500 10332  0 14:47 pts/0    00:00:00 grep --color=auto mongo
[root@mongodbhost1 ~]# grep STARTED /var/log/mongodb/mongod.log|tail -1
2016-08-17T14:47:21.405+0200 I CONTROL  [main] ***** SERVER RESTARTED *****
[root@mongodbhost1 ~]# 

Shutdown

[root@mongodbhost1 ~]# service mongod stop
Stopping mongod (via systemctl):                           [  OK  ]
[root@mongodbhost1 ~]# ps -efa | grep mongo
root     17561 10332  0 14:58 pts/0    00:00:00 grep --color=auto mongo
[root@mongodbhost1 ~]# grep dbexit /var/log/mongodb/mongod.log|tail -1
2016-08-17T14:58:12.586+0200 I CONTROL  [signalProcessingThread] dbexit:  rc: 0
[root@mongodbhost1 ~]# 

Automatic Startup

[root@mongodbhost1 ~]# chkconfig mongod on
[root@mongodbhost1 ~]# chkconfig

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mongod          0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole      0:off 1:off 2:off 3:off 4:off 5:off 6:off
network         0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mongodbhost1 ~]# 

Kernel Optimizations

[root@mongodbhost1 ~]# cat /var/log/mongodb/mongod.log
...
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] 
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] 
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] 
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2016-08-17T14:47:22.003+0200 I CONTROL  [initandlisten] 
...
[root@mongodbhost1 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@mongodbhost1 ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
[root@mongodbhost1 ~]# 

### create this configuration. as of
###    https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/
### and
###    https://serverfault.com/questions/688392/disable-thp-and-thp-defrag-on-centos-7-ec2-instance
###

[root@mongodbhost1 no-thp]# pwd
/etc/tuned/no-thp
[root@mongodbhost1 no-thp]# ls -l
total 8
-rwxr-xr-x. 1 root root 161 Aug 17 15:24 disable_transparent_hugepages_defrag.sh
-rw-r--r--. 1 root root 120 Aug 17 15:23 tuned.conf
[root@mongodbhost1 no-thp]# cat tuned.conf
[main]
include=virtual-guest

[vm]
transparent_hugepages=never

[script]
script=disable_transparent_hugepages_defrag.sh
[root@mongodbhost1 no-thp]# cat disable_transparent_hugepages_defrag.sh
#!/bin/sh

. /usr/lib/tuned/functions

start() {
    echo never > /sys/kernel/mm/transparent_hugepage/defrag
    return 0
}

stop() {
    return 0
}

process $@
[root@mongodbhost1 no-thp]# tuned-adm profile no-thp
[root@mongodbhost1 no-thp]# cat /sys/kernel/mm/transparent_hugepage/enabled 
always madvise [never]
[root@mongodbhost1 no-thp]# cat /sys/kernel/mm/transparent_hugepage/defrag 
always madvise [never]
[root@mongodbhost1 no-thp]# 



Extending the number of allowed processes

### At startup, in the logs, we get a warning about the limit to the number of processes for the mongod user which is too restrictive.
[root@mongodbhost1 ~]# cat /var/log/mongodb/mongod.log
...
2016-09-17T13:30:01.551+0200 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] MongoDB starting : pid=2396 port=27017 dbpath=/var/lib/mongo 64-bit host=mongodbhost1.localdomain
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] db version v3.2.9
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] allocator: tcmalloc
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] modules: none
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] build environment:
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten]     distmod: rhel70
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten]     distarch: x86_64
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten]     target_arch: x86_64
2016-09-17T13:30:01.602+0200 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-09-17T13:30:01.646+0200 I -        [initandlisten] Detected data files in /var/lib/mongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-09-17T13:30:01.646+0200 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-09-17T13:30:02.393+0200 I CONTROL  [initandlisten] 
2016-09-17T13:30:02.393+0200 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2016-09-17T13:30:02.442+0200 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'
2016-09-17T13:30:02.443+0200 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-09-17T13:30:02.444+0200 I NETWORK  [initandlisten] waiting for connections on port 27017
...
### Let's extend the aforementioned limit.
[root@mongodbhost1 ~]# ed /etc/security/limits.d/20-nproc.conf 
191
,p
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     4096
root       soft    nproc     unlimited
a
mongod     soft    nproc     64000
.
w
226
q
[root@mongodbhost1 ~]# 
### We got rid of the warning.
2016-09-17T13:44:02.349+0200 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] MongoDB starting : pid=2532 port=27017 dbpath=/var/lib/mongo 64-bit host=mongodbhost1.localdomain
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] db version v3.2.9
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] allocator: tcmalloc
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] modules: none
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] build environment:
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten]     distmod: rhel70
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten]     distarch: x86_64
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten]     target_arch: x86_64
2016-09-17T13:44:02.354+0200 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-09-17T13:44:02.369+0200 I -        [initandlisten] Detected data files in /var/lib/mongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-09-17T13:44:02.369+0200 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-09-17T13:44:02.816+0200 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'
2016-09-17T13:44:02.816+0200 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-09-17T13:44:02.817+0200 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
[root@mongodbhost1 ~]# 

Default configuration and log files

[root@mongodbhost1 ~]# ps -efa | grep mongod
mongod    2532     1  0 13:44 ?        00:00:00 /usr/bin/mongod -f /etc/mongod.conf
root      2557  2446  0 13:46 pts/0    00:00:00 grep --color=auto mongod
[root@mongodbhost1 ~]# cat  /etc/mongod.conf
# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:
[root@mongodbhost1 ~]# 

Playing with the getting started tutorial

See https://docs.mongodb.com/getting-started/shell/import-data.

mercoledì 17 agosto 2016

Getting started with MariaDB on CentOS

Some notes about installing and using MariaDB on CentOS 7.

The notes are based on documentation found at https://mariadb.com/kb/en.

Installation

# yum install mariadb-server

Startup

[root@mariadbhost ~]# systemctl start mariadb
[root@mariadbhost ~]# systemctl|awk 'NR==1||/mariadb/'
UNIT             LOAD   ACTIVE SUB       DESCRIPTION
mariadb.service  loaded active running   MariaDB database server
[root@mariadbhost ~]# 

Shutdown

[root@mariadbhost ~]# systemctl stop mariadb
[root@mariadbhost ~]# systemctl|awk 'NR==1||/mariadb/'
UNIT             LOAD   ACTIVE SUB       DESCRIPTION
[root@mariadbhost ~]# ps -efa | grep mariadb
root      2936  2425  0 11:26 pts/0    00:00:00 grep --color=auto mariadb
[root@mariadbhost ~]# 

Automatic Startup

[root@mariadbhost ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@mariadbhost ~]# reboot
...
[root@mariadbhost ~]# systemctl|awk 'NR==1||/mariadb/'
UNIT             LOAD   ACTIVE SUB       DESCRIPTION
mariadb.service  loaded active running   MariaDB database server
[root@mariadbhost ~]# 

Default configuration and log files

[root@mariadbhost ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

[root@mariadbhost ~]# find /etc/my.cnf.d/
/etc/my.cnf.d/
/etc/my.cnf.d/mysql-clients.cnf
/etc/my.cnf.d/client.cnf
/etc/my.cnf.d/server.cnf
[root@mariadbhost ~]# ls -l /etc/my.cnf.d/
total 12
-rw-r--r--. 1 root root 295 Jun 16 21:08 client.cnf
-rw-r--r--. 1 root root 232 Jun 16 21:08 mysql-clients.cnf
-rw-r--r--. 1 root root 744 Jun 16 21:08 server.cnf
[root@mariadbhost ~]# cat /etc/my.cnf.d/mysql-clients.cnf
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#

[mysql]

[mysql_upgrade]

[mysqladmin]

[mysqlbinlog]

[mysqlcheck]

[mysqldump]

[mysqlimport]

[mysqlshow]

[mysqlslap]

[root@mariadbhost ~]# cat /etc/my.cnf.d/client.cnf
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#


[client]

# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]

[root@mariadbhost ~]# cat /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

# this is only for embedded server
[embedded]

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

[mariadb-5.5]

[root@mariadbhost ~]# cat /var/run/mariadb/mariadb.pid
2770
[root@mariadbhost ~]# ps -efa | grep -w 2770
mysql     2770  2613  0 11:03 ?        00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root      2861  2425  0 11:11 pts/0    00:00:00 grep --color=auto -w 2770
[root@mariadbhost ~]# cat /var/log/mariadb/mariadb.log
160817 11:03:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160817 11:03:03 [Note] /usr/libexec/mysqld (mysqld 5.5.50-MariaDB) starting as process 2770 ...
160817 11:03:03 InnoDB: The InnoDB memory heap is disabled
160817 11:03:03 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160817 11:03:03 InnoDB: Compressed tables use zlib 1.2.7
160817 11:03:03 InnoDB: Using Linux native AIO
160817 11:03:03 InnoDB: Initializing buffer pool, size = 128.0M
160817 11:03:03 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
160817 11:03:03  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
160817 11:03:04  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
160817 11:03:04  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
160817 11:03:04  InnoDB: Waiting for the background threads to start
160817 11:03:05 Percona XtraDB (http://www.percona.com) 5.5.49-MariaDB-37.9 started; log sequence number 0
160817 11:03:05 [Note] Plugin 'FEEDBACK' is disabled.
160817 11:03:05 [Note] Server socket created on IP: '0.0.0.0'.
160817 11:03:05 [Note] Event Scheduler: Loaded 0 events
160817 11:03:05 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.50-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
[root@mariadbhost ~]# 

Administration

[root@mariadbhost ~]# mysqladmin  status
Uptime: 797  Threads: 1  Questions: 4  Slow queries: 0  Opens: 0  Flush tables: 2  Open tables: 26  Queries per second avg: 0.005
[root@mariadbhost ~]# mysqladmin  processlist
+----+------+-----------+----+---------+------+-------+------------------+----------+
| Id | User | Host      | db | Command | Time | State | Info             | Progress |
+----+------+-----------+----+---------+------+-------+------------------+----------+
| 5  | root | localhost |    | Query   | 0    |       | show processlist | 0.000    |
+----+------+-----------+----+---------+------+-------+------------------+----------+
[root@mariadbhost ~]# mysqladmin ver
mysqladmin  Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Server version  5.5.50-MariaDB
Protocol version 10
Connection  Localhost via UNIX socket
UNIX socket  /var/lib/mysql/mysql.sock
Uptime:   16 min 47 sec

Threads: 1  Questions: 33  Slow queries: 0  Opens: 0  Flush tables: 2  Open tables: 26  Queries per second avg: 0.032
[root@mariadbhost ~]# mysqladmin variables|grep datadir
| datadir                                           | /var/lib/mysql/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
[root@mariadbhost ~]# mysqladmin 
mysqladmin  Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Administration program for the mysqld daemon.
Usage: mysqladmin [OPTIONS] command command....

Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf 
The following groups are read: mysqladmin client client-server client-mariadb
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

  -c, --count=#       Number of iterations to make. This works with -i
                      (--sleep) only.
  --debug-check       Check memory and open file usage at exit.
  --debug-info        Print some debug info at exit.
  -f, --force         Don't ask for confirmation on drop database; with
                      multiple commands, continue even if an error occurs.
  -C, --compress      Use compression in server/client protocol.
  --character-sets-dir=name 
                      Directory for character set files.
  --default-character-set=name 
                      Set the default character set.
  -?, --help          Display this help and exit.
  -h, --host=name     Connect to host.
  -b, --no-beep       Turn off beep on error.
  -p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
  -P, --port=#        Port number to use for connection or 0 for default to, in
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
                      /etc/services, built-in default (3306).
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -r, --relative      Show difference between current and previous values when
                      used with -i. Currently only works with extended-status.
  -s, --silent        Silently exit if one can't connect to server.
  -S, --socket=name   The socket file to use for connection.
  -i, --sleep=#       Execute commands repeatedly with a sleep between.
  --ssl               Enable SSL for connection (automatically enabled with
                      other flags).
  --ssl-ca=name       CA file in PEM format (check OpenSSL docs, implies
                      --ssl).
  --ssl-capath=name   CA directory (check OpenSSL docs, implies --ssl).
  --ssl-cert=name     X509 cert in PEM format (implies --ssl).
  --ssl-cipher=name   SSL cipher to use (implies --ssl).
  --ssl-key=name      X509 key in PEM format (implies --ssl).
  --ssl-verify-server-cert 
                      Verify server's "Common Name" in its cert against
                      hostname used when connecting. This option is disabled by
                      default.
  -u, --user=name     User for login if not current user.
  -v, --verbose       Write more information.
  -V, --version       Output version information and exit.
  -E, --vertical      Print output vertically. Is similar to --relative, but
                      prints output vertically.
  -w, --wait[=#]      Wait and retry if connection is down.
  --connect-timeout=# 
  --shutdown-timeout=# 
  --plugin-dir=name   Directory for client-side plugins.
  --default-auth=name Default authentication client-side plugin to use.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
count                             0
debug-check                       FALSE
debug-info                        FALSE
force                             FALSE
compress                          FALSE
character-sets-dir                (No default value)
default-character-set             auto
host                              (No default value)
no-beep                           FALSE
port                              0
relative                          FALSE
socket                            (No default value)
sleep                             0
ssl                               FALSE
ssl-ca                            (No default value)
ssl-capath                        (No default value)
ssl-cert                          (No default value)
ssl-cipher                        (No default value)
ssl-key                           (No default value)
ssl-verify-server-cert            FALSE
user                              (No default value)
verbose                           FALSE
vertical                          FALSE
connect-timeout                   43200
shutdown-timeout                  3600
plugin-dir                        (No default value)
default-auth                      (No default value)

Where command is a one or more of: (Commands may be shortened)
  create databasename   Create a new database
  debug     Instruct server to write debug information to log
  drop databasename   Delete a database and all its tables
  extended-status         Gives an extended status message from the server
  flush-all-statistics    Flush all statistics tables
  flush-all-status        Flush status and statistics
  flush-client-statistics Flush client statistics
  flush-hosts             Flush all cached hosts
  flush-index-statistics  Flush index statistics
  flush-logs              Flush all logs
  flush-privileges        Reload grant tables (same as reload)
  flush-slow-log          Flush slow query log
  flush-status    Clear status variables
  flush-table-statistics  Clear table statistics
  flush-tables            Flush all tables
  flush-threads           Flush the thread cache
  flush-user-statistics   Flush user statistics
  kill id,id,... Kill mysql threads
  password [new-password] Change old password to new-password in current format
  old-password [new-password] Change old password to new-password in old format
  ping   Check if mysqld is alive
  processlist  Show list of active threads in server
  reload  Reload grant tables
  refresh  Flush all tables and close and open logfiles
  shutdown  Take server down
  status  Gives a short status message from the server
  start-slave  Start slave
  stop-slave  Stop slave
  variables             Prints variables available
  version  Get version info from server
[root@mariadbhost ~]# 

Create an user

[root@mariadbhost ~]# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'test123test!';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SELECT User,Host FROM mysql.user;
+----------+-------------------------+
| User     | Host                    |
+----------+-------------------------+
| root     | 127.0.0.1               |
| root     | ::1                     |
|          | localhost               |
| root     | localhost               |
| testuser | localhost               |
|          | mariadbhost.localdomain |
| root     | mariadbhost.localdomain |
+----------+-------------------------+
7 rows in set (0.00 sec)

MariaDB [(none)]> 

Connecting

[root@mariadbhost ~]# mysql -u testuser -p -h localhost test
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [test]> 

Creating a database

MariaDB [test]> CREATE DATABASE IF NOT EXISTS test;
Query OK, 1 row affected, 1 warning (0.00 sec)

MariaDB [test]> SHOW WARNINGS;
+-------+------+-----------------------------------------------+
| Level | Code | Message                                       |
+-------+------+-----------------------------------------------+
| Note  | 1007 | Can't create database 'test'; database exists |
+-------+------+-----------------------------------------------+
1 row in set (0.00 sec)

MariaDB [test]> USE test;
Database changed
MariaDB [test]>

Creating tables

MariaDB [test]> CREATE TABLE IF NOT EXISTS books (BookID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Title VARCHAR(100) NOT NULL, SeriesID INT, AuthorID INT); 
Query OK, 0 rows affected (0.04 sec)

MariaDB [test]> CREATE TABLE IF NOT EXISTS series (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT);
Query OK, 0 rows affected (0.05 sec)

Adding records to a table

MariaDB [test]> INSERT INTO books (Title,SeriesID,AuthorID) VALUES ('testbook1',1,1), ('testbook2',1,1), ('testbook3',1,1), ('testbook4',2,2), ('testbook5',2,2), ('testbook6',2,2), ('testbook7',0,1);
Query OK, 7 rows affected (0.02 sec)
Records: 7  Duplicates: 0  Warnings: 0

MariaDB [test]> 

Showing tables

MariaDB [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| books          |
| series         |
+----------------+
2 rows in set (0.00 sec)

MariaDB [test]> describe books;
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| BookID   | int(11)      | NO   | PRI | NULL    | auto_increment |
| Title    | varchar(100) | NO   |     | NULL    |                |
| SeriesID | int(11)      | YES  |     | NULL    |                |
| AuthorID | int(11)      | YES  |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

MariaDB [test]> select * from books;
+--------+-----------+----------+----------+
| BookID | Title     | SeriesID | AuthorID |
+--------+-----------+----------+----------+
|      1 | testbook1 |        1 |        1 |
|      2 | testbook2 |        1 |        1 |
|      3 | testbook3 |        1 |        1 |
|      4 | testbook4 |        2 |        2 |
|      5 | testbook5 |        2 |        2 |
|      6 | testbook6 |        2 |        2 |
|      7 | testbook7 |        0 |        1 |
+--------+-----------+----------+----------+
7 rows in set (0.00 sec)

MariaDB [test]> 

Modifying records

MariaDB [test]> update books set Title = 'lastbook' where BookID = 7;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [test]> select * from books;
+--------+-----------+----------+----------+
| BookID | Title     | SeriesID | AuthorID |
+--------+-----------+----------+----------+
|      1 | testbook1 |        1 |        1 |
|      2 | testbook2 |        1 |        1 |
|      3 | testbook3 |        1 |        1 |
|      4 | testbook4 |        2 |        2 |
|      5 | testbook5 |        2 |        2 |
|      6 | testbook6 |        2 |        2 |
|      7 | lastbook  |        0 |        1 |
+--------+-----------+----------+----------+
7 rows in set (0.00 sec)

MariaDB [test]> 

sabato 9 gennaio 2016

How To Backup an Android Phone to a Linux PC

These are my notes about doing the backup of a Samsung S4 GT-I9515 smartphone running Android 5.0.1 to a Fedora Linux 23 Workstation Edition system.

Install the ADB tools

On the Linux system, install the ADB tools (Android Debug Bridge):

root@localhost ~]# dnf install android-tools
...
Complete!
[root@localhost ~]# 

Enable Developer mode on the smartphone

Connect the phone to the Linux system.

It is needed to enable the developer mode on the smartphone. This can be done by going to "Settings" => "More" => "About device" => tap on "Build number" until you get a message saying that the developer mode was enabled.

The new entry "Settings" => "More" => "Developer options" will appear. You need to check the "USB debugging" box.

The smartphone will ask if you want to connect to the PC, you need to answer "yes".

Do the backup

On the Linux system can run the command "adb" without arguments to see all the possible options.

[root@localhost ~]# adb
Android Debug Bridge version 1.0.32

...
 -s           - directs command to the device or emulator with the given
                                 serial number or qualifier. Overrides ANDROID_SERIAL
                                 environment variable.
...
 devices [-l]                  - list all connected devices
                                 ('-l' will also list device qualifiers)
...
device commands:
...
  adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] []
                               - write an archive of the device's data to .
                                 If no -f option is supplied then the data is written
                                 to "backup.ab" in the current directory.
                                 (-apk|-noapk enable/disable backup of the .apks themselves
                                    in the archive; the default is noapk.)
                                 (-obb|-noobb enable/disable backup of any installed apk expansion
                                    (aka .obb) files associated with each application; the default
                                    is noobb.)
                                 (-shared|-noshared enable/disable backup of the device's
                                    shared storage / SD card contents; the default is noshared.)
                                 (-all means to back up all installed applications)
                                 (-system|-nosystem toggles whether -all automatically includes
                                    system applications; the default is to include system apps)
                                 ( is the list of applications to be backed up.  If
                                    the -all or -shared flags are passed, then the package
                                    list is optional.  Applications explicitly given on the
                                    command line will be included even if -nosystem would
                                    ordinarily cause them to be omitted.)

  adb restore            - restore device contents from the  backup archive

  adb help                     - show this help message
  adb version                  - show version num
...
[root@localhost ~]# 

Let's see if the smartphone is recognized:

[root@localhost ~]# adb devices -l
List of devices attached 
xxxxxxxx               device usb:3-1.6 product:zzzzzzzz model:GT_I9515 device:yyyyyy

[root@localhost ~]# 

It is, so let's start the backup.

[root@localhost phone]# adb backup -apk -all -s xxxxxxxx -f OUTPUTFILENAMEOFYOURCHOICE
Now unlock your device and confirm the backup operation.

Now you need to unlock your phone, it will ask you if you want to do the backup, and eventually it will ask for the encryption password. Answer, and the backup will start.

venerdì 31 luglio 2015

Fedora: installing non-free video codecs

For installing non-free video codecs (which are not distributed by Fedora):

  • Add the RPM Fusion repository to your system: http://rpmfusion.org
  • install the codecs: dnf install gstreamer-plugins-bad gstreamer-plugins-bad-free-extras gstreamer-plugins-ugly gstreamer-ffmpeg libmatroska xvidcore xine-lib-extras-freeworld libdvdread libdvdnav gstreamer-plugins-good lsdvd libdvbpsi ffmpeg ffmpeg-libs gstreamer-ffmpeg

martedì 26 agosto 2014

FreeBSD: Subversion service configuration - basic example

SOFTWARE INSTALLATION

root@fbsd1:~ # pkg install subversion
Updating repository catalogue
FreeBSD repository is up-to-date
All repositories are up-to-date
The following 7 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        subversion: 1.8.10
        serf: 1.3.7
        apr: 1.5.1.1.5.3_3
        expat: 2.1.0_1
        sqlite3: 3.8.5_1
        gdbm: 1.11_2
        db48: 4.8.30.0_2

The process will require 32 MB more space
5 MB to be downloaded

Proceed with this action [y/N]: y
Fetching subversion-1.8.10.txz: 100% of 2 MB
Fetching serf-1.3.7.txz: 100% of 76 KB
Fetching apr-1.5.1.1.5.3_3.txz: 100% of 393 KB
Fetching expat-2.1.0_1.txz: 100% of 99 KB
Fetching sqlite3-3.8.5_1.txz: 100% of 654 KB
Fetching gdbm-1.11_2.txz: 100% of 143 KB
Fetching db48-4.8.30.0_2.txz: 100% of 915 KB
Checking integrity... done (0 conflicting)
[1/7] Installing expat-2.1.0_1: 100%
[2/7] Installing gdbm-1.11_2: 100%
[3/7] Installing db48-4.8.30.0_2: 100%
[4/7] Installing apr-1.5.1.1.5.3_3: 100%
[5/7] Installing serf-1.3.7: 100%
[6/7] Installing sqlite3-3.8.5_1: 100%
[7/7] Installing subversion-1.8.10: 100%
root@fbsd1:~ #

REPOSITORY CREATION

root@fbsd1:/m1pool/m1fs # svnadmin create /m1pool/m1fs/repos
root@fbsd1:/m1pool/m1fs #

root@fbsd1:/m1pool/m1fs # grep svn /etc/services
svn             3690/tcp   #Subversion
svn             3690/udp   #Subversion
root@fbsd1:/m1pool/m1fs #

root@fbsd1:/m1pool/m1fs # cd repos
root@fbsd1:/m1pool/m1fs/repos # find .
.
./hooks
./hooks/pre-commit.tmpl
./hooks/pre-revprop-change.tmpl
./hooks/post-lock.tmpl
./hooks/start-commit.tmpl
./hooks/post-unlock.tmpl
./hooks/pre-lock.tmpl
./hooks/pre-unlock.tmpl
./hooks/post-revprop-change.tmpl
./hooks/post-commit.tmpl
./format
./README.txt
./locks
./locks/db-logs.lock
./locks/db.lock
./conf
./conf/hooks-env.tmpl
./conf/svnserve.conf
./conf/authz
./conf/passwd
./db
./db/txn-current
./db/txn-protorevs
./db/write-lock
./db/transactions
./db/uuid
./db/format
./db/txn-current-lock
./db/revs
./db/revs/0
./db/revs/0/0
./db/fsfs.conf
./db/min-unpacked-rev
./db/revprops
./db/revprops/0
./db/revprops/0/0
./db/fs-type
./db/current
root@fbsd1:/m1pool/m1fs/repos #

BASIC CONFIGURATION

root@fbsd1:/m1pool/m1fs/repos/conf # mv svnserve.conf svnserve.conf~; cp svnserve.conf~ svnserve.conf
root@fbsd1:/m1pool/m1fs/repos/conf # vi svnserve.conf
root@fbsd1:/m1pool/m1fs/repos/conf # diff svnserve.conf~ svnserve.conf
19,20c19,20
< # anon-access = read
< # auth-access = write
---
> anon-access = none
> auth-access = write
27c27
< # password-db = passwd
---
> password-db = passwd
42c42
< # groups-db = groups
---
> groups-db = groups
47c47
< # realm = My First Repository
---
> realm = Marco Repository
54c54
< # force-username-case = none
---
> force-username-case = none
61c61
< # hooks-env = hooks-env
---
> hooks-env = hooks-env
root@fbsd1:/m1pool/m1fs/repos/conf # ed passwd
309
a
marco = MYPASSWORD
.
w
326
q
root@fbsd1:/m1pool/m1fs/repos/conf # ed /etc/rc.conf
251
a
svnserve_enable="YES"
svnserve_data="/m1pool/m1fs/repos"
svnserve_flags="-d --listen-port=3690 --listen-host 192.168.0.11"
.
w
374
q
root@fbsd1:/m1pool/m1fs/repos/conf # pw groupadd -n svn -g 90
root@fbsd1:/m1pool/m1fs/repos/conf # pw useradd -n svn -u 90 -g svn -d /nonexistent -s /nonexistent
root@fbsd1:/m1pool/m1fs/repos/conf # chown -R svn:svn /m1pool/m1fs/repos
root@fbsd1:/m1pool/m1fs/repos/conf # service svnserve start
Starting svnserve.
root@fbsd1:/m1pool/m1fs/repos/conf # service svnserve status
svnserve is running as pid 3714.
root@fbsd1:/m1pool/m1fs/repos/conf #

IMPORTING THE DATA

root@fbsd1:/m1pool/m1fs/repos/conf # cd ~marco
root@fbsd1:~marco # svn import src file:///m1pool/m1fs/repos/marco/src -m "initial import"
...
Committed revision 1.
root@fbsd1:~marco #


[marco@othersystem ~]$ svn import src/ svn://192.168.0.11/othersys/src -m "initial import"
Authentication realm:  Marco Repository
Password for 'marco': 
Adding         ...

Committed revision 5.
[marco@othersystem ~]$ 

$ svn co svn://192.168.0.11/othersys
Authentication realm:  Marco Repository
Password for 'marco': ********

A    othersys/src
...

Checked out revision 5.
$

LINKS

giovedì 14 agosto 2014

FreeBSD: gpg 2.x ends with error because pinentry is not installed

PROBLEM

$ gpg ciphered.tar.gpg
gpg: 3DES encrypted data
gpg-agent[1264]: can't connect to the PIN entry module: IPC connect call failed
gpg-agent[1264]: command get_passphrase failed: No pinentry
gpg: problem with the agent: No pinentry
gpg: encrypted with 1 passphrase
gpg: decryption failed: No secret key
$

SOLUTION

root@fbsd1:/home/marco # pkg install pinentry
Updating repository catalogue
FreeBSD repository is up-to-date
All repositories are up-to-date
The following 85 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        pinentry: 0.8.3_1
[...]
        xprop: 1.2.2

The process will require 669 MB more space
128 MB to be downloaded

Proceed with this action [y/N]: n
root@fbsd1:/home/marco # pkg
pkg: not enough arguments
Usage: pkg [-v] [-d] [-l] [-N] [-j |-c ] [-C ] [-R ] [-o var=value]  []


For more information on available commands and options see 'pkg help'.
root@fbsd1:/home/marco # pkg help
Usage: pkg [-v] [-d] [-l] [-N] [-j |-c ] [-C ] [-R ] [-o var=value]  []
[...]

Commands supported:
[...]
        search         Performs a search of package repository catalogues
[...]
root@fbsd1:/home/marco # pkg search pinentry
pinentry-0.8.3_1
pinentry-curses-0.8.3
pinentry-gtk-0.8.3
pinentry-gtk2-0.8.3
pinentry-qt4-0.8.3
root@fbsd1:/home/marco # pkg install pinentry-curses
Updating repository catalogue
FreeBSD repository is up-to-date
All repositories are up-to-date
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        pinentry-curses: 0.8.3

The process will require 78 KB more space
30 KB to be downloaded

Proceed with this action [y/N]: y
Fetching pinentry-curses-0.8.3.txz: 100% of 30 KB
Checking integrity... done (0 conflicting)
[1/1] Installing pinentry-curses-0.8.3: 100%
root@fbsd1:/home/marco #

$ gpg ciphered.tar.gpg
gpg: 3DES encrypted data

  lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
  x Enter passphrase                                    x
  x                                                     x
  x                                                     x
  x Passphrase **************************************__ x
  x                                                     x
  x       [OK]                             [Cancel]     x
  mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected
$ ls
ciphered.tar            ciphered.tar.gpg        prova
$