https://wiki.archlinux.org/api.php?action=feedcontributions&user=Infiniteh&feedformat=atomArchWiki - User contributions [en]2024-03-28T21:36:12ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371950PostgreSQL2015-04-30T20:44:06Z<p>Infiniteh: /* Installing PostgreSQL */ updated formatting for postgres user name for consistency</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created ''postgres'' user.<br />
<br />
{{Note|Commands that should be run as the postgres user are prefixed by {{ic|[postgres]$}} in this article. You can change to the postgres user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main configuration files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default, this folder will not be browsable or searchable by a regular user. This is why {{ic|find}} and {{ic|locate}} are not finding the configuration files.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section, add the {{ic|listen_addresses}} line to your needs:<br />
<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''', including the database superuser. Add a line like the following:<br />
<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[restart]] {{ic|postgresql.service}} for the changes to take effect.<br />
<br />
{{Note|PostgreSQL uses port {{ic|5432}} by default for remote connections. Make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file:<br />
<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the postgres user its owner:<br />
<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
<br />
Become the postgres user, and initialize the new cluster:<br />
<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
<br />
If enabled, disable {{ic|postgresql.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required.}}<br />
<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: {{ic|template0}} is vanilla, while {{ic|template1}} is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of a new database, one of the options is to change on-site {{ic|template1}}. To do this, log into PostgreSQL shell ({{ic|psql}}) and execute the following:<br />
<br />
First, we need to drop {{ic|template1}}. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
<br />
Now we can drop it:<br />
<br />
DROP DATABASE template1;<br />
<br />
The next step is to create a new database from {{ic|template0}}, with a new default encoding:<br />
<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
<br />
Now modify {{ic|template1}} so it is actually a template:<br />
<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
<br />
Optionally, if you do not want anyone connecting to this template, set {{ic|datallowconn}} to {{ic|FALSE}}:<br />
<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|This last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
<br />
[postgres]$ createdb blog<br />
<br />
If you log back in to {{ic|psql}} and check the databases, you should see the proper encoding of your new database:<br />
<br />
\l<br />
<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate from 9.3 to 9.4, change versions before executing commands. If {{ic|/var/lib/postgres/data-9.2}} already exists and you just copy-paste all commands, {{ic|pg_upgrade}} will complain about the wrong version of the database, because your version 9.3 database will be stored in {{ic|/var/lib/postgres/data-9.2/data/}}.}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like {{ic|pg_hba.conf}} and {{ic|postgresql.conf}}, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the {{ic|pg_upgrade}} step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the postgres user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use {{ic|su - postgres}} instead of {{ic|sudo -u postgres}}.<br />
<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, {{ic|C}} or {{ic|en_US.UTF-8}} for example, and force it when calling {{ic|initdb}}.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error, then chances are there is an old PID file you need to clear out.<br />
{{hc|$ sudo -u postgres ls -l /var/lib/postgres/data-9.2|<nowiki><br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem</nowiki>}}<br />
<br />
$ sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve {{ic|postgis-2.0.so}} from {{Pkg|postgis}} for version postgresql 9.2 () and copy it to {{ic|/opt/pgsql-9.2/lib}} (make sure the privileges are right).<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
{{Warning|The following instructions could cause data loss. '''Use at your own risk'''.}}<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
<br />
IgnorePkg = postgresql postgresql-libs<br />
<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in {{ic|pacman.conf}}. Minor version upgrades (e.g. 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g. 9.0.x to 9.1.x), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case, see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the [[official repositories]] that will always run one major version behind the real PostgreSQL package. This can be installed side-by-side with the new version of PostgreSQL. <br />
<br />
When you are ready, upgrade the following packages: {{Pkg|postgresql}}, {{Pkg|postgresql-libs}}, and {{Pkg|postgresql-old-upgrade}}. Note that the data directory does not change from version to version, so before running {{ic|pg_upgrade}}, it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
The upgrade invocation will likely look something like the following. '''Do not run this command blindly without understanding what it does!''' Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of {{Pkg|postgresql-old-upgrade}}).<br />
<br />
{{Note|Below are the commands for PostgreSQL 8.4. You can find similar commands in {{ic|/opt/}} for PostgreSQL 9.2.}}<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|/var/lib/postgres/data/postgresql.conf|<nowiki>synchronous_commit = off</nowiki>}}<br />
<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks from spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|/var/lib/postgres/data/postgresql.conf|<nowiki>stats_temp_directory = '/run/postgresql'</nowiki>}}<br />
<br />
=== Cannot connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the {{ic|php.ini}} file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}}, then restart {{ic|httpd}}.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Nextcloud&diff=371838Nextcloud2015-04-29T22:14:42Z<p>Infiniteh: /* Troubleshooting */ style and grammar</p>
<hr />
<div>[[Category:Web Server]]<br />
[[fr:Owncloud]]<br />
[[ja:ownCloud]]<br />
{{lowercase title}}<br />
{{Related articles start}}<br />
{{Related|LAMP}}<br />
{{Related|Nginx}}<br />
{{Related|OpenSSL}}<br />
{{Related|WebDAV}}<br />
{{Related articles end}}<br />
From [[Wikipedia:ownCloud|Wikipedia]]:<br />
: ''ownCloud is a software suite that provides a location-independent storage area for data (cloud storage).''<br />
The ownCloud installation and configuration mainly depends on what web server and database you decide to run. Currently the wiki discusses [[#Apache configuration]] and [[#Nginx + uwsgi_php configuration]].<br />
== Prerequisites ==<br />
<br />
''ownCloud'' needs a [[:Category:Web_Server|web server]], [[PHP]] and a [[:Category:Database_management_systems|database]]. For instance, a classic [[LAMP|LAMP stack]] should work fine and is the [http://doc.owncloud.org/server/7.0/admin_manual/installation/installation_source.html#manual-installation recommended configuration].<br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|owncloud}} from the [[official repositories]]. Alternatively see the packages available in the [[Arch User Repository]]: [https://aur.archlinux.org/packages.php?K=owncloud].<br />
<br />
Uncomment the following '''required''' extensions in {{ic|/etc/php/php.ini}}:<br />
gd.so<br />
iconv.so<br />
xmlrpc.so<br />
zip.so<br />
<br />
It is also [http://doc.owncloud.org/server/7.0/admin_manual/installation/installation_source.html#prerequisites recommended] to install {{Pkg|php-intl}}, {{Pkg|php-mcrypt}} and uncomment the following extensions:<br />
bz2.so<br />
curl.so<br />
intl.so<br />
mcrypt.so<br />
openssl.so<br />
<br />
For enhanced performance, you may install ''either'':<br />
* {{Pkg|php-apcu}}: only provides user data caching. Enable it by removing the comment in {{ic|/etc/php/conf.d/apcu.ini}}. Then for opcode caching use the [http://www.php.net/manual/en/book.opcache.php opcache extension]: uncomment {{ic|1=zend_extension=opcache.so}} in {{ic|/etc/php/php.ini}}.<br />
* {{Pkg|php-xcache}}: development version which provides both an opcode and user data cache. Uncomment it in {{ic|/etc/php/conf.d/xcache.ini}} after installation.<br />
<br />
==== Database support ====<br />
Depending on which database backend you are going to use, uncomment both of the following two extensions in {{ic|/etc/php/php.ini}}:<br />
{| class="wikitable"<br />
!SQLite!!MySQL!!PostgreSQL<br />
|-<br />
|{{bc|pdo_sqlite.so<br />
sqlite3.so}}<br />
|{{bc|pdo_mysql.so<br />
mysql.so}}<br />
|{{bc|pdo_pgsql.so<br />
pgsql.so}}<br />
|-<br />
|}<br />
<br />
{{note|1=When using [[MySQL]] you need {{ic|mysql.so}}, even though it is deprecated. As of July 2014 (ownCloud 7.0) {{ic|mysqli.so}} is not supported.[http://doc.owncloud.org/server/7.0/admin_manual/configuration/configuration_database.html][https://forum.owncloud.org/viewtopic.php?f=26&t=21534]}}<br />
Do not forget to install the appropriate php-module for the database. In the PostgreSQL case thats {{Pkg|php-pgsql}} or for SQLite {{Pkg|php-sqlite}}.<br />
<br />
==== Exif support ====<br />
Additionally enable exif support by installing {{Pkg|exiv2}} from the [[official repositories]] and uncommenting the {{ic|exif.so}} extension in {{ic|php.ini}}.<br />
<br />
=== An all-in-one alternative with Docker ===<br />
<br />
A quick and safe alternative to installing and configuring ''ownCloud'' on your own is to use [[Docker]]. You can find several images of fully working LAMP stack with pre-installed ''ownCloud'' in the [https://index.docker.io/search?q=ownCloud Docker repositories]. ''Docker'' containers are generally safer than a [[chroot]] environment and the overhead is very low,; ''ownCloud'' in Docker works smoothly even on quite old machines. The whole setup including installing ''Docker'' and ''ownCloud'' image is considerably easier and quicker than a native installation.<br />
<br />
== Apache configuration ==<br />
<br />
Copy the Apache configuration file to its configuration directory:<br />
# cp /etc/webapps/owncloud/apache.example.conf /etc/httpd/conf/extra/owncloud.conf<br />
<br />
And include it at the bottom of {{ic|/etc/httpd/conf/httpd.conf}}:<br />
Include conf/extra/owncloud.conf<br />
<br />
Activate php (install package php-apache):<br />
LoadModule php5_module modules/libphp5.so<br />
Include conf/extra/php5_module.conf<br />
<br />
Make sure the web server can write to the ownCloud directory:<br />
# chown http:http /usr/share/webapps/owncloud/<br />
<br />
{{Warning|see [https://doc.owncloud.org/server/8.0/admin_manual/installation/installation_wizard.html#setting-strong-directory-permissions important security details] regarding permissions to avoid problems during installation}}<br />
<br />
ownCloud comes with its own [[WebDAV]] implementation enabled, which may conflict with the one shipped with Apache. If you have enabled WebDAV (not enabled by default with Apache), disable {{ic|mod_dav}} and {{ic|mod_dav_fs}} in {{ic|/etc/httpd/conf/httpd.conf}}. See https://forum.owncloud.org/viewtopic.php?f=17&t=7240 for details.<br />
<br />
Now restart Apache ({{ic|httpd.service}}).<br />
<br />
Replace this module in case of httpd startup problems (Invalid command 'php_admin_value'...):<br />
LoadModule mpm_event_module modules/mod_mpm_event.so<br />
<br />
by this one: <br />
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so<br />
<br />
Open http://localhost/ in your browser. You should now be able to create a user account and follow the installation wizard.<br />
<br />
==== Running ownCloud in a subdirectory ====<br />
<br />
By including the default {{ic|owncloud.conf}} in {{ic|httpd.conf}}, ownCloud will take control of port 80 and your localhost domain. <br />
<br />
If you would like to have ownCloud run in a subdirectory, then edit the {{ic|/etc/httpd/conf/extra/owncloud.conf}} you included and comment out the {{ic|<nowiki><VirtualHost *:80> ... </VirtualHost></nowiki>}} part of the include file.<br />
<br />
== Nginx + uwsgi_php configuration ==<br />
<br />
You can avoid the use of Apache, and run ownCloud in its own process by using the {{pkg|uwsgi-plugin-php}} application server. uWSGI itself has a wealth of features to limit the resource use, and to harden the security of the application, and by being a separate process it can run under its own user.<br />
<br />
=== Configuration ===<br />
<br />
*First of all you should set up your Nginx server. See the [[Nginx]] page for further information.<br />
*Set a server with the following lines in the http section of your {{ic|/etc/nginx/nginx.conf}} file:<br />
{{bc|<nowiki><br />
#this is to avoid Request Entity Too Large error<br />
client_max_body_size 1000M;<br />
# deny access to some special files<br />
location ~ ^/(data|config|\.ht|db_structure\.xml|README) {<br />
deny all;<br />
}<br />
# pass all .php or .php/path urls to uWSGI<br />
location ~ ^(.+\.php)(.*)$ {<br />
include uwsgi_params;<br />
uwsgi_modifier1 14;<br />
#Uncomment line below if you get connection refused error. Remember to commet out line with "uwsgi_pass 127.0.0.1:3001;" below<br />
#uwsgi_pass unix:/run/uwsgi/owncloud.sock;<br />
uwsgi_pass 127.0.0.1:3001;<br />
}<br />
# everything else goes to the filesystem,<br />
# but / will be mapped to index.php and run through uwsgi<br />
location / {<br />
root /usr/share/webapps/owncloud;<br />
index index.php;<br />
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;<br />
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;<br />
}<br />
</nowiki>}}<br />
*Then create a [[Uwsgi|uWSGI]] config file. {{ic|/etc/uwsgi/owncloud.ini}} could be a good choice:<br />
{{bc|<nowiki><br />
[uwsgi]<br />
master = true<br />
socket = 127.0.0.1:3001<br />
<br />
# Change this to where you want ownlcoud data to be stored (maybe /home/owncloud)<br />
owncloud_data_dir = /usr/share/webapps/owncloud/data/<br />
chdir = %(owncloud_data_dir)<br />
<br />
plugins = php<br />
php-docroot = /usr/share/webapps/owncloud<br />
php-index = index.php<br />
<br />
# only allow these php files, I do not want to inadvertently run something else<br />
php-allowed-ext = /index.php<br />
php-allowed-ext = /public.php<br />
php-allowed-ext = /remote.php<br />
php-allowed-ext = /cron.php<br />
php-allowed-ext = /status.php<br />
php-allowed-ext = /settings/apps.php<br />
php-allowed-ext = /core/ajax/update.php<br />
php-allowed-ext = /core/ajax/share.php<br />
php-allowed-ext = /core/ajax/requesttoken.php<br />
php-allowed-ext = /core/ajax/translations.php<br />
php-allowed-ext = /search/ajax/search.php<br />
php-allowed-ext = /search/templates/part.results.php<br />
php-allowed-ext = /settings/admin.php<br />
php-allowed-ext = /settings/users.php<br />
php-allowed-ext = /settings/personal.php<br />
php-allowed-ext = /settings/help.php<br />
php-allowed-ext = /settings/ajax/getlog.php<br />
php-allowed-ext = /settings/ajax/setlanguage.php<br />
php-allowed-ext = /settings/ajax/setquota.php<br />
php-allowed-ext = /settings/ajax/userlist.php<br />
php-allowed-ext = /settings/ajax/createuser.php<br />
php-allowed-ext = /settings/ajax/removeuser.php<br />
php-allowed-ext = /settings/ajax/enableapp.php<br />
php-allowed-ext = /core/ajax/appconfig.php<br />
php-allowed-ext = /settings/ajax/setloglevel.php<br />
php-allowed-ext = /ocs/v1.php<br />
<br />
# set php configuration for this instance of php, no need to edit global php.ini<br />
php-set = date.timezone=Etc/UTC<br />
php-set = open_basedir=%(owncloud_data_dir):/tmp/:/usr/share/pear/:/usr/share/webapps/owncloud:/etc/webapps/owncloud<br />
php-set = session.save_path=/tmp<br />
php-set = post_max_size=1000M<br />
php-set = upload_max_filesize=1000M<br />
php-set = always_populate_raw_post_data=-1<br />
<br />
# load all extensions only in this instance of php, no need to edit global php.ini<br />
php-set = extension=bz2.so<br />
php-set = extension=curl.so<br />
php-set = extension=intl.so<br />
php-set = extension=openssl.so<br />
php-set = extension=pdo_sqlite.so<br />
php-set = extension=exif.so<br />
php-set = extension=gd.so<br />
php-set = extension=imagick.so<br />
php-set = extension=gmp.so<br />
php-set = extension=iconv.so<br />
php-set = extension=mcrypt.so<br />
php-set = extension=sockets.so<br />
php-set = extension=sqlite3.so<br />
php-set = extension=xmlrpc.so<br />
php-set = extension=xsl.so<br />
php-set = extension=zip.so<br />
<br />
processes = 10<br />
cheaper = 2<br />
cron = -3 -1 -1 -1 -1 /usr/bin/php -f /usr/share/webapps/owncloud/cron.php 1>/dev/null<br />
<br />
</nowiki>}}<br />
<br />
=== Activation ===<br />
<br />
[[Uwsgi|uWSGI]] provides a [[Systemd#Using_units|template unit]] that allows to start and enable application using their configuration file name as instance identifier. For example:<br />
# systemctl start uwsgi@owncloud.service<br />
would start it referencing the configuration file {{ic|/etc/uwsgi/owncloud.ini}}. <br />
<br />
To enable the uwsgi service by default at start-up, run:<br />
# systemctl enable uwsgi@owncloud.service<br />
<br />
See also [[Uwsgi#Starting_service]].<br />
<br />
== Synchronization ==<br />
<br />
=== Desktop ===<br />
<br />
The official client can be installed with the package {{Pkg|owncloud-client}} from the official repositories. Alternative versions are avaiable in the [[AUR]]: {{AUR|owncloud-client-beta}}, {{AUR|owncloud-client-git}} and {{AUR|owncloud-client-qt5}}. Its use is described in [http://doc.owncloud.org/server/7.0/user_manual/files/sync.html this page] of the documentation.<br />
<br />
==== Calendar ====<br />
<br />
To access your ''ownCloud'' calendars using Mozilla [[Thunderbird]]'s [[Thunderbird#Lightning_-_Calendar|Lightning calendar]] you would use the following URL:<br />
<br />
<nowiki>https://ADDRESS/remote.php/caldav/calendars/USERNAME/CALENDARNAME</nowiki><br />
<br />
To access your ''ownCloud'' calendars using CalDAV-compatible programs like Kontact or [[Evolution]], you would use the following URL:<br />
<br />
<nowiki>https://ADDRESS/remote.php/caldav</nowiki><br />
<br />
For details see the [http://doc.owncloud.org/server/7.0/user_manual/pim/calendar.html#synchronizing-calendars-using-caldav official documentation].<br />
<br />
==== Contacts ====<br />
<br />
To sync contacts with [[Thunderbird]] you must install the [http://www.sogo.nu/downloads/frontends.html SOGo frontend], [[Thunderbird#Lightning_-_Calendar|Lightning extension]] and follow [http://doc.owncloud.org/server/7.0/user_manual/pim/sync_thunderbird.html those instructions] from the official doc.<br />
<br />
==== Mounting files with davfs2 ====<br />
<br />
If you want to mount your ownCloud permanently install {{Pkg|davfs2}} (as described in [[Davfs]]) first.<br />
<br />
Considering your ownCloud were at {{ic|https://own.example.com}}, your WebDAV URL would be {{ic|https://own.example.com/remote.php/webdav}} (as of ownCloud 6.0).<br />
<br />
To mount your ownCloud, use:<br />
<br />
# mount -t davfs https://own.example.com/remote.php/webdav /path/to/mount<br />
<br />
You can also create an entry for this in {{ic|/etc/fstab}}<br />
<br />
{{hc|/etc/fstab|<br />
https://own.example.com/remote.php/webdav /path/to/mount davfs rw,user,noauto 0 0<br />
}}<br />
<br />
{{Tip|In order to allow automount you can also store your username (and password if you like) in a file as described in [[Davfs#Mounting as regular user]].}}<br />
<br />
{{Note| If creating/copying files is not possible, while the same operations work on directories, see [[Davfs#Creating.2Fcopying_files_not_possible]].}}<br />
<br />
=== Android ===<br />
<br />
There is an official Android app available for a small fee on the Play Store and for free [https://f-droid.org/repository/browse/?fdfilter=owncloud&fdid=com.owncloud.android on F-Droid].<br />
<br />
To enable contacts and calendar sync:<br />
* if using Android 4+:<br />
*# download [http://davdroid.bitfire.at/what-is-davdroid DAVdroid] (available in [https://f-droid.org/repository/browse/?fdfilter=owncloud&fdid=at.bitfire.davdroid F-Droid])<br />
*# Enable mod_rewrite.so in httpd.conf<br />
*# create a new DAVdroid account in the ''Account'' settings, and specify your "short" server address and login/password couple, e.g. {{ic|<nowiki>https://cloud.example.com</nowiki>}} (there is no need for the {{ic|<nowiki>/remote.php/{carddav,webdav}</nowiki>}} part if you configured your web server with the proper redirections, as illustrated previously in the article; ''DAVdroid'' will find itself the right URLs)<br />
:For an older version of the app but with still useful info, see [http://www.slsmk.com/sync-android-contacts-calendar-and-files-to-owncloud/ this article].<br />
<br />
* if using an Android version below 4.0 and favouring Free/Libre software solutions, give a try to [https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=com.morphoss.acal aCal] for calendar and contacts sync or CalDAV Sync Adapter ([https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=org.gege.caldavsyncadapter F-Droid]) for just calendar sync; if you are willing to use non-libre software, then the [http://doc.owncloud.org/server/7.0/user_manual/pim/contacts.html#synchronizing-with-android recommended solution] is to use [http://dmfs.org/ CardDAV-Sync and CalDAV-Sync].<br />
<br />
== Important notes ==<br />
<br />
* When using a subdomain (like cloud.example.net), make sure it is covered by your certificate. Otherwise, connection via the ownCloud client or webdav might fail.<br />
<br />
* If you are planning on using ownCloud's [http://owncloud.org/sync-clients/ sync-clients], make sure to have [[ntpd]] installed and running on your ownCloud server, otherwise the sync-clients will fail.<br />
<br />
* Add some [[LAMP#SSL|SSL encryption]] to your connection!<br />
(If adding SSL encryption as above, be sure to edit /etc/httpd/conf/extra/httpd-ssl.conf and change DocumentRoot "/srv/http" to DocumentRoot "/usr/share/webapps/owncloud" )<br />
<br />
* More Apps for ownCloud can be found [http://apps.owncloud.com/ here]<br />
<br />
* To install an new application, download the zip from the apps store, extract it into /srv/http/owncloud/apps/.<br />
Afterwards restart httpd:<br />
<br />
# systemctl restart httpd<br />
<br />
log into your server go to the app sections you should see the new apps in there,<br />
<br />
* If you are protecting access to your ownCloud location with HTTP basic auth, the file "status.php" must be excluded from auth and be publicly accessible. [https://github.com/owncloud/mirall/issues/734]<br />
<br />
=== SABnzbd ===<br />
<br />
When using [[SABnzbd]], you might want to set<br />
folder_rename 0<br />
in your sabnzbd.ini file, because ownCloud will scan the files as soon as they get uploaded, preventing SABnzbd from removing UNPACKING prefixes etc.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Self-signed certificate not accepted ===<br />
<br />
ownCloud uses [[Wikipedia:cURL]] and [[Wikipedia:SabreDAV]] to check if WebDAV is enabled. If you use SSL/TLS with a self-signed certificate, e.g. as shown in [[LAMP]], and access ownCloud's admin panel, you will see the following error message:<br />
<br />
Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.<br />
<br />
Assuming that you followed the [[LAMP]] tutorial, execute the following steps:<br />
<br />
Create a local directory for non-distribution certificates and copy [[LAMP]]s certificate there. This will prevent {{ic|ca-certificates}}-updates from overwriting it.<br />
<br />
# cp /etc/httpd/conf/server.crt /usr/share/ca-certificates/''WWW.EXAMPLE.COM.crt''<br />
<br />
Add ''WWW.EXAMPLE.COM.crt'' to {{ic|/etc/ca-certificates.conf}}:<br />
<br />
''WWW.EXAMPLE.COM.crt''<br />
<br />
Now, regenerate your certificate store:<br />
<br />
# update-ca-certificates<br />
<br />
Restart the httpd service to activate your certificate.<br />
<br />
Should this not work, consider disabling {{ic|mod_curl}} in {{ic|/etc/php/php.ini}}.<br />
<br />
=== Self-signed certificate for Android devices ===<br />
<br />
Once you have followed the setup for SSL, as on [https://wiki.archlinux.org/index.php/LAMP#TLS.2FSSL LAMP] for example, [https://f-droid.org/repository/browse/?fdfilter=davdroid&fdid=at.bitfire.davdroid davdroid] will fail to work because the certificate is not accepted. A certificate can be made as follows on your server:<br />
<br />
# openssl x509 -req -days 365 -in /etc/httpd/conf/server.csr -signkey /etc/httpd/conf/server.key -extfile android.txt -out CA.crt<br />
# openssl x509 -inform PEM -outform DER -in CA.crt -out CA.der.crt <br />
<br />
The file {{ic|android.txt}} should contain the following:<br />
<br />
basicConstraints=CA:true<br />
<br />
Then import {{ic|CA.der.crt}} to your Android device:<br />
<br />
Put the {{ic|CA.der.crt}} file onto the sdcard of your Android device (usually to the internal one, e.g. save from a mail attachment). It should be in the root directory. Go to ''Settings > Security > Credential storage'' and select ''Install from device storage''.<br />
The {{ic|.crt}} file will be detected and you will be prompted to enter a certificate name. After importing the certificate, you will find it in ''Settings > Security > Credential storage > Trusted credentials > User''.<br />
<br />
Thanks to: [http://www.leftbrainthings.com/2013/10/13/creating-and-importing-self-signed-certificate-to-android-device/]<br />
<br />
=== Cannot write into config directory! ===<br />
<br />
Check your httpd configuration file (like {{ic|owncloud.conf}}). Add your configuration directory ({{ic|/etc/webapps}} by default) to <br />
<br />
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/"<br />
<br />
Restart the httpd or php-fpm service to activate the change.<br />
<br />
=== Cannot create data directory (/path/to/dir) ===<br />
<br />
Check your httpd configuration file (like {{ic|owncloud.conf}}). Add your data directory to<br />
<br />
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/"<br />
<br />
Restart the httpd or php-fpm service to activate the change.<br />
<br />
=== CSync failed to find a specific file. ===<br />
<br />
This is most likely a certificate issue. Recreate it, and do not leave the common name empty or you will see the error again.<br />
<br />
openssl genrsa -out server.key 2048<br />
openssl req -new -key server.key -x509 -days 365 -out server.crt<br />
<br />
=== Seeing white page after login ===<br />
<br />
The cause is probably a new app that you installed. To fix that, you can either use [[phpMyAdmin]] to edit the {{ic|oc_appconfig}} table (if you got lucky and the table has an edit option), or do it by hand with mysql:<br />
<br />
mysql -u root -p owncloud<br />
MariaDB [owncloud]> '''delete from''' oc_appconfig '''where''' appid='<nameOfExtension>' '''and''' configkey='enabled' '''and''' configvalue='yes'<br />
MariaDB [owncloud]> '''insert into''' oc_appconfig (appid,configkey,configvalue) '''values''' ('<nameOfExtension>','enabled','no');<br />
<br />
This should delete the relevant configuration from the table and add it again.<br />
<br />
=== GUI sync client fails to connect ===<br />
<br />
If using HTTP basic authentication, make sure to exclude "status.php", which must be publicly accessible. [https://github.com/owncloud/mirall/issues/734]<br />
<br />
=== "Cannot write into apps directory" ===<br />
<br />
As mentioned in the [http://doc.owncloud.org/server/6.0/admin_manual/configuration/configuration_apps.html official admin manual], either you need an apps directory that is writable by the http user, or you need to set {{ic|appstoreenabled}} to {{ic|false}}. <br />
<br />
''Also'', not mentioned there, the directory needs to be in the {{ic|open_basedir}} line in {{ic|/etc/php/php.ini}}.<br />
<br />
{{Accuracy|Does not seem to work with 8.0.2}}<br />
<br />
One clean method is to have the package-installed directory at {{ic|/usr/share/webapps/owncloud/apps}} stay owned by root, and have the user-installed apps go into e.g. {{ic|/var/www/owncloud/apps}}, which is owned by http. Then you can set {{ic|appstoreenabled}} to {{ic|true}} and package upgrades of apps should work fine as well. Relevant lines from {{ic|/etc/webapps/owncloud/config/config.php}}:<br />
<br />
{{bc|<nowiki><br />
'apps_paths' => <br />
array (<br />
0 => <br />
array (<br />
'path' => '/usr/share/webapps/owncloud/apps',<br />
'url' => '/apps',<br />
'writable' => false,<br />
),<br />
1 => <br />
array (<br />
'path' => '/var/www/owncloud/apps',<br />
'url' => '/wapps',<br />
'writable' => true,<br />
),<br />
),<br />
</nowiki>}}<br />
<br />
Example {{ic|open_basedir}} line from {{ic|/etc/php/php.ini}} (you might have other directories in there as well):<br />
<br />
open_basedir = /srv/http/:/usr/share/webapps/:/var/www/owncloud/apps/<br />
<br />
Directory permissions:<br />
<br />
{{hc|$ ls -ld /usr/share/webapps/owncloud/apps /var/www/owncloud/apps/|<br />
<nowiki>drwxr-xr-x 26 root root 4096 des. 14 20:48 /usr/share/webapps/owncloud/apps<br />
drwxr-xr-x 2 http http 48 jan. 20 20:01 /var/www/owncloud/apps/</nowiki>}}<br />
<br />
== Upload and Share from File Manager ==<br />
You can use the following script to quickly upload and share files to your ownCloud installation from Thunar (and possibly other filemanagers): https://github.com/schiesbn/shareLinkCreator<br />
You need to edit the file with the proper configuration settings.<br />
'''Note: password is stored as plain text.'''<br />
<br />
== See also ==<br />
* [http://owncloud.org/ ownCloud official website]<br />
* [http://doc.owncloud.org/server/8.0/admin_manual/ ownCloud 8.0 Admin Documentation]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Beets&diff=371831Beets2015-04-29T20:05:02Z<p>Infiniteh: follow Help:Style guidelines; also, bullet points seemed unnecessary</p>
<hr />
<div>[[Category:Audio/Video]]<br />
[[ja:Beets]]<br />
[http://beets.radbox.org/ Beets] is a music tagger and library organizer using the [http://musicbrainz.org/ MusicBrainz] database.<br />
<br />
== Installation ==<br />
<br />
[[Pacman|Install]] the {{Pkg|beets}} package from the [[official repositories]] or {{AUR|beets-git}} from the [[AUR]].<br />
<br />
== Configuration ==<br />
<br />
{{Tip|Beets provides a command for configuration manipulations. To edit the configuration file, run {{ic|beet config -e}}. It will be opened with the text editor specified in the [[Environment variables|environment variable]] {{ic|EDITOR}}.}}<br />
User configuration is done in {{ic|~/.config/beets/config.yaml}} using [[Wikipedia:YAML|YAML]] syntax. For example:<br />
{{hc|~/.config/beets/config.yaml|<br />
directory: ~/Music # The default library root directory.<br />
library: ~/Music/library.db # The default library database file to use.<br />
color: yes # Using colors in the terminal<br />
}}<br />
<br />
== Usage ==<br />
<br />
=== Add music ===<br />
<br />
Add music to your library and attempt to fix tags:<br />
$ beet import <path><br />
<br />
Add the single track without an album:<br />
$ beet import -s <path><br />
<br />
=== List music ===<br />
<br />
List all music in your library:<br />
$ beet ls<br />
<br />
List all albums in your library:<br />
$ beet ls -a<br />
<br />
=== Remove music ===<br />
<br />
{{Tip|If you remove music from your filesystem or do any changes to the files without using {{ic|beet}}, do not forget to run {{ic|beet upd}} to update your library database.}}<br />
<br />
Remove track(s) from your library:<br />
$ beet rm <part of name><br />
<br />
Remove album(s) from your library:<br />
$ beet rm -a <part of name><br />
<br />
== Tips and tricks ==<br />
<br />
=== Enabling tab-completion in bash ===<br />
<br />
Beets includes support for Bash shell [[Bash#Tab completion|command completion]]. To enable completion, put the following line into your {{ic|.bashrc}}:<br />
{{hc|~/.bashrc|eval "$(beet completion)"}}<br />
You will also need to [[Pacman|install]] {{Pkg|bash-completion}} for this to work.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371829PostgreSQL2015-04-29T19:41:33Z<p>Infiniteh: /* Troubleshooting */ style edits</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main configuration files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default, this folder will not be browsable or searchable by a regular user. This is why {{ic|find}} and {{ic|locate}} are not finding the configuration files.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section, add the {{ic|listen_addresses}} line to your needs:<br />
<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''', including the database superuser. Add a line like the following:<br />
<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[restart]] {{ic|postgresql.service}} for the changes to take effect.<br />
<br />
{{Note|PostgreSQL uses port {{ic|5432}} by default for remote connections. Make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file:<br />
<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the postgres user its owner:<br />
<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
<br />
Become the postgres user, and initialize the new cluster:<br />
<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
<br />
If enabled, disable {{ic|postgresql.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required.}}<br />
<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: {{ic|template0}} is vanilla, while {{ic|template1}} is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of a new database, one of the options is to change on-site {{ic|template1}}. To do this, log into PostgreSQL shell ({{ic|psql}}) and execute the following:<br />
<br />
First, we need to drop {{ic|template1}}. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
<br />
Now we can drop it:<br />
<br />
DROP DATABASE template1;<br />
<br />
The next step is to create a new database from {{ic|template0}}, with a new default encoding:<br />
<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
<br />
Now modify {{ic|template1}} so it is actually a template:<br />
<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
<br />
Optionally, if you do not want anyone connecting to this template, set {{ic|datallowconn}} to {{ic|FALSE}}:<br />
<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|This last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
<br />
[postgres]$ createdb blog<br />
<br />
If you log back in to {{ic|psql}} and check the databases, you should see the proper encoding of your new database:<br />
<br />
\l<br />
<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate from 9.3 to 9.4, change versions before executing commands. If {{ic|/var/lib/postgres/data-9.2}} already exists and you just copy-paste all commands, {{ic|pg_upgrade}} will complain about the wrong version of the database, because your version 9.3 database will be stored in {{ic|/var/lib/postgres/data-9.2/data/}}.}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like {{ic|pg_hba.conf}} and {{ic|postgresql.conf}}, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the {{ic|pg_upgrade}} step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the postgres user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use {{ic|su - postgres}} instead of {{ic|sudo -u postgres}}.<br />
<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, {{ic|C}} or {{ic|en_US.UTF-8}} for example, and force it when calling {{ic|initdb}}.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error, then chances are there is an old PID file you need to clear out.<br />
{{hc|$ sudo -u postgres ls -l /var/lib/postgres/data-9.2|<nowiki><br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem</nowiki>}}<br />
<br />
$ sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve {{ic|postgis-2.0.so}} from {{Pkg|postgis}} for version postgresql 9.2 () and copy it to {{ic|/opt/pgsql-9.2/lib}} (make sure the privileges are right).<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
{{Warning|The following instructions could cause data loss. '''Use at your own risk'''.}}<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
<br />
IgnorePkg = postgresql postgresql-libs<br />
<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in {{ic|pacman.conf}}. Minor version upgrades (e.g. 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g. 9.0.x to 9.1.x), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case, see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the [[official repositories]] that will always run one major version behind the real PostgreSQL package. This can be installed side-by-side with the new version of PostgreSQL. <br />
<br />
When you are ready, upgrade the following packages: {{Pkg|postgresql}}, {{Pkg|postgresql-libs}}, and {{Pkg|postgresql-old-upgrade}}. Note that the data directory does not change from version to version, so before running {{ic|pg_upgrade}}, it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
The upgrade invocation will likely look something like the following. '''Do not run this command blindly without understanding what it does!''' Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of {{Pkg|postgresql-old-upgrade}}).<br />
<br />
{{Note|Below are the commands for PostgreSQL 8.4. You can find similar commands in {{ic|/opt/}} for PostgreSQL 9.2.}}<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|/var/lib/postgres/data/postgresql.conf|<nowiki>synchronous_commit = off</nowiki>}}<br />
<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks from spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|/var/lib/postgres/data/postgresql.conf|<nowiki>stats_temp_directory = '/run/postgresql'</nowiki>}}<br />
<br />
=== Cannot connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the {{ic|php.ini}} file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}}, then restart {{ic|httpd}}.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371828PostgreSQL2015-04-29T19:37:03Z<p>Infiniteh: /* Detailed instructions */ style, see Help:Style; improved logical sequence of instructions</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main configuration files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default, this folder will not be browsable or searchable by a regular user. This is why {{ic|find}} and {{ic|locate}} are not finding the configuration files.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section, add the {{ic|listen_addresses}} line to your needs:<br />
<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''', including the database superuser. Add a line like the following:<br />
<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[restart]] {{ic|postgresql.service}} for the changes to take effect.<br />
<br />
{{Note|PostgreSQL uses port {{ic|5432}} by default for remote connections. Make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file:<br />
<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the postgres user its owner:<br />
<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
<br />
Become the postgres user, and initialize the new cluster:<br />
<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
<br />
If enabled, disable {{ic|postgresql.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required.}}<br />
<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: {{ic|template0}} is vanilla, while {{ic|template1}} is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of a new database, one of the options is to change on-site {{ic|template1}}. To do this, log into PostgreSQL shell ({{ic|psql}}) and execute the following:<br />
<br />
First, we need to drop {{ic|template1}}. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
<br />
Now we can drop it:<br />
<br />
DROP DATABASE template1;<br />
<br />
The next step is to create a new database from {{ic|template0}}, with a new default encoding:<br />
<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
<br />
Now modify {{ic|template1}} so it is actually a template:<br />
<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
<br />
Optionally, if you do not want anyone connecting to this template, set {{ic|datallowconn}} to {{ic|FALSE}}:<br />
<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|This last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
<br />
[postgres]$ createdb blog<br />
<br />
If you log back in to {{ic|psql}} and check the databases, you should see the proper encoding of your new database:<br />
<br />
\l<br />
<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate from 9.3 to 9.4, change versions before executing commands. If {{ic|/var/lib/postgres/data-9.2}} already exists and you just copy-paste all commands, {{ic|pg_upgrade}} will complain about the wrong version of the database, because your version 9.3 database will be stored in {{ic|/var/lib/postgres/data-9.2/data/}}.}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like {{ic|pg_hba.conf}} and {{ic|postgresql.conf}}, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the {{ic|pg_upgrade}} step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the postgres user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use {{ic|su - postgres}} instead of {{ic|sudo -u postgres}}.<br />
<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, {{ic|C}} or {{ic|en_US.UTF-8}} for example, and force it when calling {{ic|initdb}}.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error, then chances are there is an old PID file you need to clear out.<br />
{{hc|$ sudo -u postgres ls -l /var/lib/postgres/data-9.2|<nowiki><br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem</nowiki>}}<br />
<br />
$ sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve {{ic|postgis-2.0.so}} from {{Pkg|postgis}} for version postgresql 9.2 () and copy it to {{ic|/opt/pgsql-9.2/lib}} (make sure the privileges are right).<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
{{Warning|The following instructions could cause data loss. '''Use at your own risk'''.}}<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
<br />
IgnorePkg = postgresql postgresql-libs<br />
<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in {{ic|pacman.conf}}. Minor version upgrades (e.g. 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g. 9.0.x to 9.1.x), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case, see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the [[official repositories]] that will always run one major version behind the real PostgreSQL package. This can be installed side-by-side with the new version of PostgreSQL. <br />
<br />
When you are ready, upgrade the following packages: {{Pkg|postgresql}}, {{Pkg|postgresql-libs}}, and {{Pkg|postgresql-old-upgrade}}. Note that the data directory does not change from version to version, so before running {{ic|pg_upgrade}}, it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
The upgrade invocation will likely look something like the following. '''Do not run this command blindly without understanding what it does!''' Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of {{Pkg|postgresql-old-upgrade}}).<br />
<br />
{{Note|Below are the commands for PostgreSQL 8.4. You can find similar commands in {{ic|/opt/}} for PostgreSQL 9.2.}}<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371751PostgreSQL2015-04-29T09:33:58Z<p>Infiniteh: /* Quick guide */ style edits; see Help:Style; this section needs more work by someone more knowledgeable than me</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main configuration files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default, this folder will not be browsable or searchable by a regular user. This is why {{ic|find}} and {{ic|locate}} are not finding the configuration files.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section, add the {{ic|listen_addresses}} line to your needs:<br />
<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''', including the database superuser. Add a line like the following:<br />
<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[restart]] {{ic|postgresql.service}} for the changes to take effect.<br />
<br />
{{Note|PostgreSQL uses port {{ic|5432}} by default for remote connections. Make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file:<br />
<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the postgres user its owner:<br />
<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
<br />
Become the postgres user, and initialize the new cluster:<br />
<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
<br />
If enabled, disable {{ic|postgresql.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required.}}<br />
<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: {{ic|template0}} is vanilla, while {{ic|template1}} is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of a new database, one of the options is to change on-site {{ic|template1}}. To do this, log into PostgreSQL shell ({{ic|psql}}) and execute the following:<br />
<br />
First, we need to drop {{ic|template1}}. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
<br />
Now we can drop it:<br />
<br />
DROP DATABASE template1;<br />
<br />
The next step is to create a new database from {{ic|template0}}, with a new default encoding:<br />
<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
<br />
Now modify {{ic|template1}} so it is actually a template:<br />
<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
<br />
Optionally, if you do not want anyone connecting to this template, set {{ic|datallowconn}} to {{ic|FALSE}}:<br />
<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|This last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
<br />
[postgres]$ createdb blog<br />
<br />
If you log back in to {{ic|psql}} and check the databases, you should see the proper encoding of your new database:<br />
<br />
\l<br />
<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate from 9.3 to 9.4, change versions before executing commands. If {{ic|/var/lib/postgres/data-9.2}} already exists and you just copy-paste all commands, {{ic|pg_upgrade}} will complain about the wrong version of the database, because your version 9.3 database will be stored in {{ic|/var/lib/postgres/data-9.2/data/}}.}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like {{ic|pg_hba.conf}} and {{ic|postgresql.conf}}, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the {{ic|pg_upgrade}} step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the postgres user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use {{ic|su - postgres}} instead of {{ic|sudo -u postgres}}.<br />
<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, {{ic|C}} or {{ic|en_US.UTF-8}} for example, and force it when calling {{ic|initdb}}.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error, then chances are there is an old PID file you need to clear out.<br />
{{hc|$ sudo -u postgres ls -l /var/lib/postgres/data-9.2|<nowiki><br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem</nowiki>}}<br />
<br />
$ sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve {{ic|postgis-2.0.so}} from {{Pkg|postgis}} for version postgresql 9.2 () and copy it to {{ic|/opt/pgsql-9.2/lib}} (make sure the privileges are right).<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371745PostgreSQL2015-04-29T09:15:12Z<p>Infiniteh: /* Change default encoding of new databases to UTF-8 */ style edits; see Help:Style; note that the diff makes this change seem bigger than it really is</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main configuration files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default, this folder will not be browsable or searchable by a regular user. This is why {{ic|find}} and {{ic|locate}} are not finding the configuration files.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section, add the {{ic|listen_addresses}} line to your needs:<br />
<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''', including the database superuser. Add a line like the following:<br />
<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[restart]] {{ic|postgresql.service}} for the changes to take effect.<br />
<br />
{{Note|PostgreSQL uses port {{ic|5432}} by default for remote connections. Make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file:<br />
<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the postgres user its owner:<br />
<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
<br />
Become the postgres user, and initialize the new cluster:<br />
<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
<br />
If enabled, disable {{ic|postgresql.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required.}}<br />
<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: {{ic|template0}} is vanilla, while {{ic|template1}} is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of a new database, one of the options is to change on-site {{ic|template1}}. To do this, log into PostgreSQL shell ({{ic|psql}}) and execute the following:<br />
<br />
First, we need to drop {{ic|template1}}. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
<br />
Now we can drop it:<br />
<br />
DROP DATABASE template1;<br />
<br />
The next step is to create a new database from {{ic|template0}}, with a new default encoding:<br />
<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
<br />
Now modify {{ic|template1}} so it is actually a template:<br />
<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
<br />
Optionally, if you do not want anyone connecting to this template, set {{ic|datallowconn}} to {{ic|FALSE}}:<br />
<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|This last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
<br />
[postgres]$ createdb blog<br />
<br />
If you log back in to {{ic|psql}} and check the databases, you should see the proper encoding of your new database:<br />
<br />
\l<br />
<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371744PostgreSQL2015-04-29T09:09:35Z<p>Infiniteh: /* Change default data directory */ style edits; see Help:Style</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main configuration files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default, this folder will not be browsable or searchable by a regular user. This is why {{ic|find}} and {{ic|locate}} are not finding the configuration files.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section, add the {{ic|listen_addresses}} line to your needs:<br />
<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''', including the database superuser. Add a line like the following:<br />
<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[restart]] {{ic|postgresql.service}} for the changes to take effect.<br />
<br />
{{Note|PostgreSQL uses port {{ic|5432}} by default for remote connections. Make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file:<br />
<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the postgres user its owner:<br />
<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
<br />
Become the postgres user, and initialize the new cluster:<br />
<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
<br />
If enabled, disable {{ic|postgresql.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371743PostgreSQL2015-04-29T09:07:46Z<p>Infiniteh: /* Configure PostgreSQL to be accessible from remote hosts */ style edits; see Help:Style</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main configuration files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default, this folder will not be browsable or searchable by a regular user. This is why {{ic|find}} and {{ic|locate}} are not finding the configuration files.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section, add the {{ic|listen_addresses}} line to your needs:<br />
<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''', including the database superuser. Add a line like the following:<br />
<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[restart]] {{ic|postgresql.service}} for the changes to take effect.<br />
<br />
{{Note|PostgreSQL uses port {{ic|5432}} by default for remote connections. Make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file:<br />
<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371739PostgreSQL2015-04-29T08:59:38Z<p>Infiniteh: /* Access the database shell */ style; see Help:Style</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary database shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the {{ic|-d}} option to connect to the database you created (without specifying a database, {{ic|psql}} will try to access a database that matches your username).<br />
<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help:<br />
=> \help<br />
Connect to a particular database:<br />
=> \c <database><br />
List all users and their permission levels:<br />
=> \du<br />
Show summary information about all tables in the current database:<br />
=> \dt<br />
Exit/quit the {{ic|psql}} shell:<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main config files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why {{ic|find}} or {{ic|locate}} is not finding the conf files, this is the reason.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section add the {{ic|listen_addresses}} line to your needs:<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''' including the database superuser. Add a line like the following:<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[Systemd#Using units|restart]] the {{ic|postgresql}} daemon for the changes to take effect.<br />
<br />
{{Note|Postgresql uses port 5432 by default for remote connections. So make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371738PostgreSQL2015-04-29T08:56:07Z<p>Infiniteh: /* Create your first database/user */ minor style edit for consistency</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the postgres user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
<br />
$ createdb myDatabaseName<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary db shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the "-d" option to connect to the database you created (without specifying a database, psql will try to access a database that matches your username)<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help<br />
=> \help<br />
Connect to a particular database<br />
=> \c <database><br />
List all users and their permission levels<br />
=> \du<br />
Shows summary information about all tables in the current database<br />
=> \dt<br />
exit/quit the psql shell<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main config files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why {{ic|find}} or {{ic|locate}} is not finding the conf files, this is the reason.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section add the {{ic|listen_addresses}} line to your needs:<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''' including the database superuser. Add a line like the following:<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[Systemd#Using units|restart]] the {{ic|postgresql}} daemon for the changes to take effect.<br />
<br />
{{Note|Postgresql uses port 5432 by default for remote connections. So make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371725PostgreSQL2015-04-29T08:00:28Z<p>Infiniteh: /* Setup HHVM to work with PostgreSQL */ changed style status to out of date</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Out of date|hhvm-pgsql fails to compile against HHVM 3.7.0, but upstream has not resolved the problem yet. See https://github.com/PocketRent/hhvm-pgsql/issues/82|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the ''postgres'' user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
$ createdb myDatabaseName<br />
<br />
<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary db shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the "-d" option to connect to the database you created (without specifying a database, psql will try to access a database that matches your username)<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help<br />
=> \help<br />
Connect to a particular database<br />
=> \c <database><br />
List all users and their permission levels<br />
=> \du<br />
Shows summary information about all tables in the current database<br />
=> \dt<br />
exit/quit the psql shell<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main config files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why {{ic|find}} or {{ic|locate}} is not finding the conf files, this is the reason.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section add the {{ic|listen_addresses}} line to your needs:<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''' including the database superuser. Add a line like the following:<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[Systemd#Using units|restart]] the {{ic|postgresql}} daemon for the changes to take effect.<br />
<br />
{{Note|Postgresql uses port 5432 by default for remote connections. So make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371694PostgreSQL2015-04-28T20:12:18Z<p>Infiniteh: /* Setup HHVM to work with PostgreSQL */ flagged for style</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
{{Style|There is an {{AUR|hhvm-pgsql}} package in the AUR. If it can be used here, it would be better than a manual install. If not, feel free to delete this flag.|section=Setting up HHVM}}<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the ''postgres'' user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
$ createdb myDatabaseName<br />
<br />
<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary db shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the "-d" option to connect to the database you created (without specifying a database, psql will try to access a database that matches your username)<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help<br />
=> \help<br />
Connect to a particular database<br />
=> \c <database><br />
List all users and their permission levels<br />
=> \du<br />
Shows summary information about all tables in the current database<br />
=> \dt<br />
exit/quit the psql shell<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main config files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why {{ic|find}} or {{ic|locate}} is not finding the conf files, this is the reason.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section add the {{ic|listen_addresses}} line to your needs:<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''' including the database superuser. Add a line like the following:<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[Systemd#Using units|restart]] the {{ic|postgresql}} daemon for the changes to take effect.<br />
<br />
{{Note|Postgresql uses port 5432 by default for remote connections. So make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Talk:PostgreSQL&diff=371693Talk:PostgreSQL2015-04-28T19:58:28Z<p>Infiniteh: /* Before you start */ mention my change to the "Installing..." section</p>
<hr />
<div>Updated this wiki to make it more clear and up-to-date. -- Evanlec<br />
<br />
== Problem with installation ==<br />
<br />
I tried to install postgresql with the wiki, but i found this problem:<br />
pg_ctl: PID file "/var/lib/postgres/data/postmaster.pid" does not exist<br />
Is server running?<br />
<br />
I searched the forums and I found out that an instruction was missed to do:<br />
<br />
$ initdb -D /var/lib/postgres/data/<br />
<br />
I hope this helps for this wiki. -- {{Unsigned|08:26, 11 April 2010|Himito}}<br />
<br />
== UTF-8 ==<br />
<br />
Added instructions on how to create new databases as unicode by default. This seems relevant as the default "encoding" SQL_ASCII is pretty useless for most people. --[[User:Cabrilo|Cabrilo]] 06:15, 11 January 2010 (EST)<br />
<br />
Is step 4 correct? [[User:Elipsion|Elipsion]] 08:15, 13 January 2010 (EST)<br />
<br />
:Good catch. Obviously it wasn't, datistemplate should've been set to TRUE for that database. Thanks for noticing it, I fixed it. --[[User:Cabrilo|Cabrilo]] 12:00, 13 January 2010 (EST)<br />
<br />
:Is this section still necessary? I am just learning, but did a "show client_encoding" on template1 and it returns UTF8 out of the box. --[[User:Nitmd|Nitmd]] 11:55, 18 September 2010 (CDT)<br />
<br />
::I think it's still necessary (and thank you for making this section). Just removed "vacuum freeze", since it's no longer recommended and the command will be obsolete in future releases of postgresql. BTW: I ran into a problem with the statement to disallow connections to the template1 database. This is because I wanted to build a new database named "postgres". After dropping the postgresql db, creating a new template1 and disallowing the connections to template1, I had no database to connect to, so I couldn't create a new database. Had to delete the data dir and start over.[[User:Tankgrun|Tankgrun]] 10:07, 12 August 2011 (EDT)<br />
<br />
== Better systemd support ==<br />
<br />
The wiki is out dated and the package will most certainly not work with systemd without tinkering with the service files. This article needs a re-write. {{Unsigned|08:18, 30 September 2012| Newtonelectron}}<br />
<br />
== Installing PostgreSQL -> reboot not necessary ==<br />
<br />
"Reboot the system to automatically create the file tmpfiles.d for /run/postgresql". I believe "systemd-tmpfiles --create" is enough to create /run/postfix without reboot. But I'm not confident enough to change it without asking first :).<br />
--[[User:Hiciu|Hiciu]] ([[User talk:Hiciu|talk]]) 13:35, 26 November 2012 (UTC)<br />
<br />
:well, I was wrong. "systemd-tmpfiles --create" creates /run/postgresql, but it also (at least for me) breaks sudo so reboot is necessary anyway (sudo, after asking for password, returns "System is booting up."). --[[User:Hiciu|Hiciu]] ([[User talk:Hiciu|talk]]) 13:46, 26 November 2012 (UTC)<br />
<br />
:correct command is "sudo systemd-tmpfiles --create /usr/lib/tmpfiles.d/postgresql.conf" --[[User:Hiciu|Hiciu]] ([[User talk:Hiciu|talk]]) 14:01, 26 November 2012 (UTC)<br />
<br />
== Before you start ==<br />
<br />
This section is confusing because it assumes "postgres" user has already been created, whereas it is created by "pacman -S postgresql" issued in the following section. I'd suggest to restructure the article this way: 1. Installing PostgreSQL - with single package installation instruction only, 2. Before you start, 3. Configuring PostgreSQL --[[User:Mloskot|Mloskot]] ([[User talk:Mloskot|talk]]) 20:03, 24 March 2013 (UTC)<br />
<br />
:Agreed. I simplified the "Installing PostgreSQL" section and merged the instructions from "Before you start". Hopefully it is clear now. [[User:Infiniteh|Infiniteh]] ([[User talk:Infiniteh|talk]]) 19:58, 28 April 2015 (UTC)<br />
<br />
== Package in the repo is not fully ready for systemd ==<br />
<br />
The page talks about PGROOT, but if you follow the instructions it is never set. From [https://bbs.archlinux.org/viewtopic.php?id=149446 this thread] I found that a file should be created at {{ic|/etc/conf.d/postgres}} that contains the following:<br />
<br />
##<br />
## Parameters to be passed to postgresql<br />
##<br />
## Default data directory location<br />
PGROOT="/var/lib/postgres"<br />
## Passed to initdb if necessary<br />
INITOPTS="--locale en_US.UTF-8"<br />
## Default log file location<br />
PGLOG="/var/log/postgresql.log"<br />
## Additional options to pass via pg_ctl's '-o' option<br />
#PGOPTS=""<br />
<br />
Maybe this could go into the postgresql.conf, I dunno. All I know is that systemd will refuse to run the service if PGROOT isn't set. I'll give putting that in the conf file a try and update with results. {{Unsigned|17:53, 21 June 2013|Slippery John}}<br />
<br />
== Problem changing default data directory ==<br />
<br />
I followed the instructions to change default data directory, however, when starting the service again, it fails with the following error:<br />
<br />
/var/lib/postgres/data" is missing or empty.<br />
<br />
What could I be doing wrong? {{Unsigned|22:50, 15 September 2014|Ajendrex}}<br />
<br />
== Setting up HHVM ==<br />
<br />
There are AUR packages {{AUR|hhvm-pgsql}} and {{AUR|hhvm-pgsql-git}}. Could either of these be used instead of the manual instructions that are given? I am not a PostgreSQL user, so I do not want to break something inadvertently by making such a change myself. [[User:Infiniteh|Infiniteh]] ([[User talk:Infiniteh|talk]]) 18:58, 28 April 2015 (UTC)</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371692PostgreSQL2015-04-28T19:52:48Z<p>Infiniteh: removed "Before you start" section, as this is now handled in the "Installing..." section</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the ''postgres'' user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
$ createdb myDatabaseName<br />
<br />
<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary db shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the "-d" option to connect to the database you created (without specifying a database, psql will try to access a database that matches your username)<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help<br />
=> \help<br />
Connect to a particular database<br />
=> \c <database><br />
List all users and their permission levels<br />
=> \du<br />
Shows summary information about all tables in the current database<br />
=> \dt<br />
exit/quit the psql shell<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main config files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why {{ic|find}} or {{ic|locate}} is not finding the conf files, this is the reason.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section add the {{ic|listen_addresses}} line to your needs:<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''' including the database superuser. Add a line like the following:<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[Systemd#Using units|restart]] the {{ic|postgresql}} daemon for the changes to take effect.<br />
<br />
{{Note|Postgresql uses port 5432 by default for remote connections. So make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371691PostgreSQL2015-04-28T19:49:32Z<p>Infiniteh: /* Installing PostgreSQL */ moved instructions about postgres user to the install section for a more logical flow; please check for correctness</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Before you start ==<br />
<br />
Several sections have instructions stating "become the ''postgres'' user". Commands that should be run as the ''postgres'' user are prefixed by {{ic|[postgres]$}} in this article.<br />
<br />
Execute the following as root to get a shell as the ''postgres'' user:<br />
# su - postgres<br />
<br />
If you use sudo, you can use the following:<br />
$ sudo -i -u postgres<br />
<br />
The ''postgres'' [[Users and groups|user]] will automatically be created by installing PostgreSQL. You will then need to specify the ''postgres'' user password.<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]], then [[Users_and_groups#Other_examples_of_user_management|set a password]] for the newly created {{ic|postgres}} user.<br />
<br />
{{Note|Commands that should be run as the {{ic|postgres}} user are prefixed by {{ic|[postgres]$}} in this article. You can change to the {{ic|postgres}} user by running {{ic|su - postgres}} as root. Alternatively, if you use [[sudo]], run {{ic|sudo -i -u postgres}} as a regular user.}}<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the ''postgres'' user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
$ createdb myDatabaseName<br />
<br />
<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary db shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the "-d" option to connect to the database you created (without specifying a database, psql will try to access a database that matches your username)<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help<br />
=> \help<br />
Connect to a particular database<br />
=> \c <database><br />
List all users and their permission levels<br />
=> \du<br />
Shows summary information about all tables in the current database<br />
=> \dt<br />
exit/quit the psql shell<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main config files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why {{ic|find}} or {{ic|locate}} is not finding the conf files, this is the reason.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section add the {{ic|listen_addresses}} line to your needs:<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''' including the database superuser. Add a line like the following:<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[Systemd#Using units|restart]] the {{ic|postgresql}} daemon for the changes to take effect.<br />
<br />
{{Note|Postgresql uses port 5432 by default for remote connections. So make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Talk:PostgreSQL&diff=371690Talk:PostgreSQL2015-04-28T18:58:35Z<p>Infiniteh: /* Setting up HHVM */ new section</p>
<hr />
<div>Updated this wiki to make it more clear and up-to-date. -- Evanlec<br />
<br />
== Problem with installation ==<br />
<br />
I tried to install postgresql with the wiki, but i found this problem:<br />
pg_ctl: PID file "/var/lib/postgres/data/postmaster.pid" does not exist<br />
Is server running?<br />
<br />
I searched the forums and I found out that an instruction was missed to do:<br />
<br />
$ initdb -D /var/lib/postgres/data/<br />
<br />
I hope this helps for this wiki. -- {{Unsigned|08:26, 11 April 2010|Himito}}<br />
<br />
== UTF-8 ==<br />
<br />
Added instructions on how to create new databases as unicode by default. This seems relevant as the default "encoding" SQL_ASCII is pretty useless for most people. --[[User:Cabrilo|Cabrilo]] 06:15, 11 January 2010 (EST)<br />
<br />
Is step 4 correct? [[User:Elipsion|Elipsion]] 08:15, 13 January 2010 (EST)<br />
<br />
:Good catch. Obviously it wasn't, datistemplate should've been set to TRUE for that database. Thanks for noticing it, I fixed it. --[[User:Cabrilo|Cabrilo]] 12:00, 13 January 2010 (EST)<br />
<br />
:Is this section still necessary? I am just learning, but did a "show client_encoding" on template1 and it returns UTF8 out of the box. --[[User:Nitmd|Nitmd]] 11:55, 18 September 2010 (CDT)<br />
<br />
::I think it's still necessary (and thank you for making this section). Just removed "vacuum freeze", since it's no longer recommended and the command will be obsolete in future releases of postgresql. BTW: I ran into a problem with the statement to disallow connections to the template1 database. This is because I wanted to build a new database named "postgres". After dropping the postgresql db, creating a new template1 and disallowing the connections to template1, I had no database to connect to, so I couldn't create a new database. Had to delete the data dir and start over.[[User:Tankgrun|Tankgrun]] 10:07, 12 August 2011 (EDT)<br />
<br />
== Better systemd support ==<br />
<br />
The wiki is out dated and the package will most certainly not work with systemd without tinkering with the service files. This article needs a re-write. {{Unsigned|08:18, 30 September 2012| Newtonelectron}}<br />
<br />
== Installing PostgreSQL -> reboot not necessary ==<br />
<br />
"Reboot the system to automatically create the file tmpfiles.d for /run/postgresql". I believe "systemd-tmpfiles --create" is enough to create /run/postfix without reboot. But I'm not confident enough to change it without asking first :).<br />
--[[User:Hiciu|Hiciu]] ([[User talk:Hiciu|talk]]) 13:35, 26 November 2012 (UTC)<br />
<br />
:well, I was wrong. "systemd-tmpfiles --create" creates /run/postgresql, but it also (at least for me) breaks sudo so reboot is necessary anyway (sudo, after asking for password, returns "System is booting up."). --[[User:Hiciu|Hiciu]] ([[User talk:Hiciu|talk]]) 13:46, 26 November 2012 (UTC)<br />
<br />
:correct command is "sudo systemd-tmpfiles --create /usr/lib/tmpfiles.d/postgresql.conf" --[[User:Hiciu|Hiciu]] ([[User talk:Hiciu|talk]]) 14:01, 26 November 2012 (UTC)<br />
<br />
== Before you start ==<br />
<br />
This section is confusing because it assumes "postgres" user has already been created, whereas it is created by "pacman -S postgresql" issued in the following section. I'd suggest to restructure the article this way: 1. Installing PostgreSQL - with single package installation instruction only, 2. Before you start, 3. Configuring PostgreSQL --[[User:Mloskot|Mloskot]] ([[User talk:Mloskot|talk]]) 20:03, 24 March 2013 (UTC)<br />
<br />
== Package in the repo is not fully ready for systemd ==<br />
<br />
The page talks about PGROOT, but if you follow the instructions it is never set. From [https://bbs.archlinux.org/viewtopic.php?id=149446 this thread] I found that a file should be created at {{ic|/etc/conf.d/postgres}} that contains the following:<br />
<br />
##<br />
## Parameters to be passed to postgresql<br />
##<br />
## Default data directory location<br />
PGROOT="/var/lib/postgres"<br />
## Passed to initdb if necessary<br />
INITOPTS="--locale en_US.UTF-8"<br />
## Default log file location<br />
PGLOG="/var/log/postgresql.log"<br />
## Additional options to pass via pg_ctl's '-o' option<br />
#PGOPTS=""<br />
<br />
Maybe this could go into the postgresql.conf, I dunno. All I know is that systemd will refuse to run the service if PGROOT isn't set. I'll give putting that in the conf file a try and update with results. {{Unsigned|17:53, 21 June 2013|Slippery John}}<br />
<br />
== Problem changing default data directory ==<br />
<br />
I followed the instructions to change default data directory, however, when starting the service again, it fails with the following error:<br />
<br />
/var/lib/postgres/data" is missing or empty.<br />
<br />
What could I be doing wrong? {{Unsigned|22:50, 15 September 2014|Ajendrex}}<br />
<br />
== Setting up HHVM ==<br />
<br />
There are AUR packages {{AUR|hhvm-pgsql}} and {{AUR|hhvm-pgsql-git}}. Could either of these be used instead of the manual instructions that are given? I am not a PostgreSQL user, so I do not want to break something inadvertently by making such a change myself. [[User:Infiniteh|Infiniteh]] ([[User talk:Infiniteh|talk]]) 18:58, 28 April 2015 (UTC)</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PostgreSQL&diff=371688PostgreSQL2015-04-28T18:36:28Z<p>Infiniteh: /* Installing PostgreSQL */ Removed redundant sudo command. Removed systemctl commands to comply with Help:Style.</p>
<hr />
<div>[[Category:Database management systems]]<br />
[[Category:Web Server]]<br />
[[it:PostgreSQL]]<br />
[[ja:PostgreSQL]]<br />
[[ru:PostgreSQL]]<br />
[[zh-CN:PostgreSQL]]<br />
{{Related articles start}}<br />
{{Related|PhpPgAdmin}}<br />
{{Related articles end}}<br />
[http://www.postgresql.org/ PostgreSQL] is an open source, community driven, standard compliant object-relational database system.<br />
<br />
This document describes how to set up PostgreSQL. It also describes how to configure PostgreSQL to be accessible from a remote client. If you need help setting up the rest of a web stack, see the [[LAMP]] page and follow all of the sections except the one related to [[MySQL]].<br />
<br />
== Before you start ==<br />
<br />
Several sections have instructions stating "become the ''postgres'' user". Commands that should be run as the ''postgres'' user are prefixed by {{ic|[postgres]$}} in this article.<br />
<br />
Execute the following as root to get a shell as the ''postgres'' user:<br />
# su - postgres<br />
<br />
If you use sudo, you can use the following:<br />
$ sudo -i -u postgres<br />
<br />
The ''postgres'' [[Users and groups|user]] will automatically be created by installing PostgreSQL. You will then need to specify the ''postgres'' user password.<br />
<br />
== Installing PostgreSQL ==<br />
<br />
[[Install]] {{Pkg|postgresql}} from the [[official repositories]].<br />
<br />
Before PostgreSQL can function correctly, the database cluster must be initialized by the ''postgres'' user. Become the ''postgres'' user and run the following command:<br />
<br />
[postgres]$ initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'<br />
<br />
Then [[start]] and enable {{ic|postgresql.service}}.<br />
<br />
{{Warning|If the database resides on a [[Btrfs]] file system, you should consider disabling [[Btrfs#Copy-On-Write_.28CoW.29|Copy-on-Write]] for the directory before creating any database.}}<br />
<br />
== Setup HHVM to work with PostgreSQL ==<br />
$ git clone https://github.com/PocketRent/hhvm-pgsql.git<br />
$ cd hhvm-pgsql<br />
If you do not use a nightly build, then run this command (verified on HHVM 3.6.1) to avoid compile errors:<br />
$ git checkout tags/3.6.0<br />
Then build the extension (if you do not need an improved support for Hack language, then remove -DHACK_FRIENDLY=ON):<br />
$ hphpize<br />
$ cmake -DHACK_FRIENDLY=ON .<br />
$ make<br />
Then copy the built extension:<br />
$ sudo cp pgsql.so /etc/hhvm/<br />
Add to /etc/hhvm/server.ini:<br />
<pre>extension_dir = /etc/hhvm<br />
hhvm.extensions[pgsql] = pgsql.so</pre><br />
<br />
== Create your first database/user ==<br />
<br />
{{Tip|If you create a PostgreSQL user with the same name as your Linux username, it allows you to access the PostgreSQL database shell without having to specify a user to login (which makes it quite convenient).}}<br />
<br />
Become the ''postgres'' user. Add a new database user using the [http://www.postgresql.org/docs/9.0/static/app-createuser.html createuser] command:<br />
[postgres]$ createuser --interactive<br />
<br />
Create a new database over which the above user has read/write privileges using the [http://www.postgresql.org/docs/9.0/static/app-createdb.html createdb] command (execute this command from your login shell if the database user has the same name as your Linux user, otherwise add {{ic|-U ''database-username''}} to the following command):<br />
$ createdb myDatabaseName<br />
<br />
<br />
<br />
== Familiarize with PostgreSQL ==<br />
<br />
=== Access the database shell ===<br />
<br />
Become the postgres user. Start the primary db shell, [http://www.postgresql.org/docs/8.3/static/app-psql.html psql], where you can do all your creation of databases/tables, deletion, set permissions, and run raw SQL commands. Use the "-d" option to connect to the database you created (without specifying a database, psql will try to access a database that matches your username)<br />
[postgres]$ psql -d myDatabaseName<br />
<br />
Some helpful commands:<br />
<br />
Get help<br />
=> \help<br />
Connect to a particular database<br />
=> \c <database><br />
List all users and their permission levels<br />
=> \du<br />
Shows summary information about all tables in the current database<br />
=> \dt<br />
exit/quit the psql shell<br />
=> \q or CTRL+d<br />
<br />
There are of course many more meta-commands, but these should help you get started.<br />
<br />
== Optional configuration ==<br />
<br />
=== Configure PostgreSQL to be accessible from remote hosts ===<br />
<br />
The PostgreSQL database server configuration file is {{ic|postgresql.conf}}. This file is located in the data directory of the server, typically {{ic|/var/lib/postgres/data}}. This folder also houses the other main config files, including the {{ic|pg_hba.conf}}.<br />
<br />
{{Note|By default this folder will not even be browseable (or searchable) by a regular user, if you are wondering why {{ic|find}} or {{ic|locate}} is not finding the conf files, this is the reason.}}<br />
<br />
Edit the file {{ic|/var/lib/postgres/data/postgresql.conf}}. In the connections and authentications section add the {{ic|listen_addresses}} line to your needs:<br />
listen_addresses = 'localhost,my_remote_ip_address'<br />
Take a careful look at the other lines.<br />
<br />
Host-based authentication is configured in {{ic|/var/lib/postgres/data/pg_hba.conf}}. This file controls which hosts are allowed to connect. Note that the defaults '''allow any local user to connect as any database user''' including the database superuser. Add a line like the following:<br />
# IPv4 local connections:<br />
host all all ''my_remote_ip_address''/32 md5<br />
where {{ic|your_desired_ip_address}} is the IP address of the client.<br />
<br />
See the documentation for [http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html pg_hba.conf].<br />
<br />
After this you should [[Systemd#Using units|restart]] the {{ic|postgresql}} daemon for the changes to take effect.<br />
<br />
{{Note|Postgresql uses port 5432 by default for remote connections. So make sure this port is open and able to receive incoming connections.}}<br />
<br />
For troubleshooting take a look in the server log file<br />
$ journalctl -u postgresql<br />
<br />
=== Change default data directory ===<br />
<br />
The default directory where all your newly created databases will be stored is {{ic|/var/lib/postgres/data}}. To change this, follow these steps:<br />
<br />
Create the new directory and make the ''postgres'' user its owner:<br />
# mkdir -p /pathto/pgroot/data<br />
# chown -R postgres:postgres /pathto/pgroot<br />
Become the ''postgres'' user, and initialize the new cluster:<br />
[postgres]$ initdb -D /pathto/pgroot/data<br />
If enabled, disable {{ic|postgres.service}}. Copy {{ic|/usr/lib/systemd/system/postgresql.service}} to {{ic|/etc/systemd/system/postgresql.service}} and edit it to change the default {{ic|PGROOT}} and {{ic|PIDFile}} paths.<br />
Environment=PGROOT=''/pathto/pgroot/''<br />
...<br />
PIDFile=''/pathto/pgroot/''data/postmaster.pid<br />
<br />
=== Change default encoding of new databases to UTF-8 ===<br />
{{Note|If you ran {{ic|initdb}} with {{ic|-E UTF8}} these steps are not required}}<br />
When creating a new database (e.g. with {{ic|createdb blog}}) PostgreSQL actually copies a template database. There are two predefined templates: template0 is vanilla, while template1 is meant as an on-site template changeable by the administrator and is used by default. In order to change the encoding of new database, one of the options is to change on-site template1. To do this, log into PostgresSQL shell (psql) and execute the following:<br />
<br />
First, we need to drop template1. Templates cannot be dropped, so we first modify it so it is an ordinary database:<br />
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';<br />
Now we can drop it:<br />
DROP DATABASE template1;<br />
The next step is to create a new database from template0, with a new default encoding:<br />
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';<br />
Now modify template1 so it is actually a template:<br />
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';<br />
(OPTIONAL) If you do not want anyone connecting to this template, set datallowconn to FALSE:<br />
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';<br />
<br />
{{Note|this last step can create problems when upgrading via {{ic|pg_upgrade}}.}}<br />
<br />
Now you can create a new database:<br />
[postgres]$ createdb blog<br />
<br />
If you log in back to psql and check the databases, you should see the proper encoding of your new database:<br />
\l<br />
returns<br />
List of databases<br />
Name | Owner | Encoding | Collation | Ctype | Access privileges<br />
-----------+----------+-----------+-----------+-------+----------------------<br />
blog | postgres | UTF8 | C | C |<br />
postgres | postgres | SQL_ASCII | C | C |<br />
template0 | postgres | SQL_ASCII | C | C | =c/postgres<br />
: postgres=CTc/postgres<br />
template1 | postgres | UTF8 | C | C |<br />
<br />
== Administration tools ==<br />
<br />
* {{App|[[phpPgAdmin]]|Web-based administration tool for PostgreSQL.|http://phppgadmin.sourceforge.net|{{Pkg|phppgadmin}}}}<br />
* {{App|pgAdmin|GUI-based administration tool for PostgreSQL.|http://www.pgadmin.org/|{{Pkg|pgadmin3}}}}<br />
<br />
== Upgrading PostgreSQL ==<br />
<br />
=== Quick guide ===<br />
<br />
This is for upgrading from 9.2 to 9.3, and also works from 9.3 to 9.4.<br />
<br />
{{Tip|If you already migrated from 9.2 to 9.3 and you want to migrate to 9.3 to 9.4, change versions before executing commands!<br />
<br />
If /var/lib/postgres/data-9.2 already exists and you just copy-paste all commands, pg_upgrade will complain about the wrong version of the database, because you 9.3's database will be stored in /var/lib/postgres/data-9.2/data/}}<br />
<br />
pacman -S --needed postgresql-old-upgrade<br />
su -<br />
su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/data-9.2'<br />
su - postgres -c 'mkdir /var/lib/postgres/data'<br />
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
If you had custom settings in configuration files like pg_hba.conf and postgresql.conf, merge them into the new ones. Then:<br />
<br />
su - postgres -c 'pg_upgrade -b /opt/pgsql-9.2/bin/ -B /usr/bin/ -d /var/lib/postgres/data-9.2 -D /var/lib/postgres/data'<br />
<br />
If the "pg_upgrade" step fails with:<br />
* ''cannot write to log file pg_upgrade_internal.log<br /> Failure, exiting'' <br />Make sure you are in a directory that the "postgres" user has enough rights to write the log file to ({{ic|/tmp}} for example). Or use "su - postgres" instead of "sudo -u postgres".<br />
* ''LC_COLLATE error that says that old and new values are different''<br />Figure out what the old locale was, C or en_US.UTF-8 for example, and force it when calling initdb.<br />
sudo -u postgres LC_ALL=C initdb -D /var/lib/postgres/data<br />
<br />
* ''There seems to be a postmaster servicing the old cluster.<br/>Please shutdown that postmaster and try again.''<br/>Make sure postgres is not running. If you still get the error then chances are there is an old PID file you need to clear out.<br />
> sudo -u postgres ls -l /var/lib/postgres/data-9.2<br />
total 88<br />
-rw------- 1 postgres postgres 4 Mar 25 2012 PG_VERSION<br />
drwx------ 8 postgres postgres 4096 Jul 17 00:36 base<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:38 global<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_clog<br />
-rw------- 1 postgres postgres 4476 Mar 25 2012 pg_hba.conf<br />
-rw------- 1 postgres postgres 1636 Mar 25 2012 pg_ident.conf<br />
drwx------ 4 postgres postgres 4096 Mar 25 2012 pg_multixact<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:05 pg_notify<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_serial<br />
drwx------ 2 postgres postgres 4096 Jul 17 00:53 pg_stat_tmp<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_subtrans<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_tblspc<br />
drwx------ 2 postgres postgres 4096 Mar 25 2012 pg_twophase<br />
drwx------ 3 postgres postgres 4096 Mar 25 2012 pg_xlog<br />
-rw------- 1 postgres postgres 19169 Mar 25 2012 postgresql.conf<br />
-rw------- 1 postgres postgres 48 Jul 17 00:05 postmaster.opts<br />
-rw------- 1 postgres postgres 80 Jul 17 00:05 postmaster.pid # <-- This is the problem<br />
<br />
> sudo -u postgres mv /var/lib/postgres/data-9.2/postmaster.pid /tmp<br />
* ''ERROR: could not access file "$libdir/postgis-2.0": No such file or directory'' <br> Retrieve postgis-2.0.so from postgis package for version postgresql 9.2 () and copy it to /opt/pgsql-9.2/lib (make sure the privileges are right)<br />
<br />
=== Detailed instructions ===<br />
<br />
{{Note|Official PostgreSQL [http://www.postgresql.org/docs/current/static/upgrading.html upgrade documentation] should be followed.}}<br />
<br />
Note that these instructions could cause data loss. '''Use at your own risk'''.<br />
<br />
It is recommended to add the following to your {{ic|/etc/pacman.conf}} file:<br />
IgnorePkg = postgresql postgresql-libs<br />
This will ensure you do not accidentally upgrade the database to an incompatible version. When an upgrade is available, pacman will notify you that it is skipping the upgrade because of the entry in pacman.conf. Minor version upgrades (e.g., 9.0.3 to 9.0.4) are safe to perform. However, if you do an accidental upgrade to a different major version (e.g., 9.0.X to 9.1.X), you might not be able to access any of your data. Always check the PostgreSQL home page (http://www.postgresql.org/) to be sure of what steps are required for each upgrade. For a bit about why this is the case see the [http://www.postgresql.org/support/versioning versioning policy].<br />
<br />
There are two main ways to upgrade your PostgreSQL database. Read the official documentation for details.<br />
<br />
For those wishing to use {{ic|pg_upgrade}}, a {{Pkg|postgresql-old-upgrade}} package is available in the repositories that will always run one major version behind the real PostgreSQL package. This can be installed side by side with the new version of PostgreSQL. When you are ready to perform the upgrade, you can do<br />
pacman -Syu postgresql postgresql-libs postgresql-old-upgrade<br />
Note also that the data directory does not change from version to version, so before running pg_upgrade it is necessary to rename your existing data directory and migrate into a new directory. The new database must be initialized, as described near the top of this page.<br />
<br />
# systemctl stop postgresql<br />
# su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata'<br />
# su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'<br />
<br />
Reference the [http://www.postgresql.org/docs/current/static/pgupgrade.html upstream pg_upgrade documentation] for details.<br />
<br />
The upgrade invocation will likely look something like the following (run as the postgres user). '''Do not run this command blindly without understanding what it does!'''<br />
<br />
# su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-8.4/bin/ -B /usr/bin/'<br />
<br />
==== Manual dump and reload ====<br />
<br />
You could also do something like this (after the upgrade and install of postgresql-old-upgrade) (NB: below is command for postgres8.4 update, you can find similar command in /opt/ for postgres 9.2 update. )<br />
<br />
# systemctl stop postgresql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ start<br />
# /opt/pgsql-8.4/bin/pg_dumpall >> old_backup.sql<br />
# /opt/pgsql-8.4/bin/pg_ctl -D /var/lib/postgres/olddata/ stop<br />
# systemctl start postgresql<br />
# psql -f old_backup.sql postgres<br />
<br />
== Troubleshooting ==<br />
<br />
=== Improve performance of small transactions ===<br />
<br />
If you are using PostgresSQL on a local machine for development and it seems slow, you could try turning [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT synchronous_commit off] in the configuration. Beware of the [http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT caveats], however.<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
synchronous_commit = off<br />
}}<br />
=== Prevent disk writes when idle ===<br />
<br />
PostgreSQL periodically updates its internal "statistics" file. By default, this file is stored on disk, which prevents disks spinning down on laptops and causes hard drive seek noise. It is simple and safe to relocate this file to a memory-only file system with the following configuration option:<br />
<br />
{{hc|1=/var/lib/postgres/data/postgresql.conf|2=<br />
stats_temp_directory = '/run/postgresql'<br />
}}<br />
<br />
=== Can't connect to database through pg_connect() ===<br />
<br />
Install {{Pkg|php-pgsql}} and edit the php.ini file uncommenting the lines {{ic|extension<nowiki>=</nowiki>pdo_pgsql.so}} and {{ic|extension<nowiki>=</nowiki>pgsql.so}} then restart httpd.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Modalias&diff=371641Modalias2015-04-28T09:42:36Z<p>Infiniteh: flagged for writing style</p>
<hr />
<div>[[Category:Kernel]]<br />
[[es:Modalias]]<br />
{{Style|Article needs to be more formal and not use first-person point-of-view. See [[Help:Style]].}}<br />
This document is an intro to how the Linux kernel and modules see and understand hardware, and how this translates into a sysfs 'modalias'<br />
<br />
==What is a 'modalias'==<br />
Modalias is a little sysfs trick that exports hardware information to a file named 'modalias'. This file simply contains a formatted form of the information normal hardware exposes. Let's look at a quick example before we continue:<br />
$ cat /sys/devices/pci0000:00/0000:00:1f.1/modalias<br />
pci:v00008086d000024DBsv0000103Csd0000006Abc01sc01i8A<br />
<br />
Don't worry, it will all become clear soon.<br />
<br />
==What is a 'modalias' file?==<br />
As described above, a modalias file simply exposes the information that a given piece of hardware already tells the kernel. This file simply specifies a structure for exposing this information. Let's return to the example above:<br />
$ cat /sys/devices/pci0000:00/0000:00:1f.1/modalias<br />
pci:v00008086d000024DBsv0000103Csd0000006Abc01sc01i8A<br />
Let's take it apart piece-by-piece. First, the file name.<br />
/sys/devices/pci0000:00/0000:00:1f.1/modalias<br />
* '''pci0000:00''' is the id for the first PCI bus. For most machines this will be the only PCI bus you have, but it's possible this can extend to '''pci0000:01''' or '''pci0000:02''' - the exacts are unimportant, as it's a good guess that you only have one PCI bus (''HINT:'' try ls /sys/devices/pci* to check)<br />
* '''0000:00:1f.1''' is the index of the given device on the PCI bus. Specifically, this is on bus 0000:00 and has index '''1f.1'''<br />
* All this is rather unimportant, unless you want to know where all these numbers come from. For completeness, if you check the output of ''lspci'' you will see the same information:<br />
$ lspci<br />
00:1f.1 IDE interface: Intel Corp.: Unknown device 24db (rev 02)<br />
<br />
Now, let's take a peek at the contents of this modalias file for device 00:1f.1:<br />
pci:v00008086d000024DBsv0000103Csd0000006Abc01sc01i8A<br />
Well, hey, I can see pci! I recognize that, but what's all this gibberish at the end?<br />
This gibberish is actually structured data. You will notice a repeating letter/number scheme. Let's split this apart to make it easier to read:<br />
v 00008086<br />
d 000024DB<br />
sv 0000103C<br />
sd 0000006A<br />
bc 01<br />
sc 01<br />
i 8A<br />
Each of these identifiers, and corresponding hex numbers represent some of the info that a given device exposes. For starters, '''v''' is the ''vendor id'' and '''d''' is the ''device id'' - these are very standard numbers, and are the same exact numbers that tools like '''hwd''' uses to lookup a device. You can even find websites to look up specific hardware identification based on the vendor and device ids, for instance, http://www.pcidatabase.com/<br />
<br />
We can also see these numbers here:<br />
$ lspci -n<br />
00:1f.1 Class 0101: 8086:24db (rev 02)<br />
See how the 8086:24db matches to the ''v'' and ''d'' tokens listed above?<br />
<br />
For the record, '''sv''' and '''sd''' are "subsystem" versions of both vendor and device. A majority of the time these are ignored. They are mainly used by the hardware developers to distinguish slight differences in the inner workings which do not change the device as a whole.<br />
<br />
'''bc''' (base class) and '''sc''' (sub class) are used to create the "Class" listed by lspci, in order "bcsc". This is the device class, which is fairly generic. In this case, the "class" is looked up in the normal lspci output. We can see that "Class 0101" maps to "IDE Interface" (lspci also looks up the vendor and device id's - 8086 maps to "Intel Corp." and 24DB maps to 'Unknown Device', hehe)<br />
<br />
'''i''' is the "Programming interface", which is only meaningful for a few devices classes.<br />
<br />
==How is this information used?==<br />
Ok, now we all know what this information is. A bunch of obscure numbers that each device exposes. Big deal. How does this matter when talking about modules?<br />
<br />
One thing which people tend to ignore, is all the work '''depmod''' does. When you run depmod, it builds a series of "map" files in /lib/modules/`uname -r` which tell modprobe how to handle certain things it needs to do. In this case we can ignore most of them. The important one is '''modules.alias'''. This file contains aliases, or secondary names for modules. Just for a demonstration, let's look at aliases for, say, snd_intel8x0m:<br />
<br />
$ grep snd_intel8x0m /lib/modules/`uname -r`/modules.alias<br />
alias pci:v00008086d00002416sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d00002426sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d00002446sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d00002486sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d000024C6sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d000024D6sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d0000266Dsv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d000027DDsv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00008086d00007196sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00001022d00007446sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v00001039d00007013sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v000010DEd000001C1sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v000010DEd00000069sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v000010DEd00000089sv*sd*bc*sc*i* snd_intel8x0m<br />
alias pci:v000010DEd000000D9sv*sd*bc*sc*i* snd_intel8x0m<br />
<br />
Hey, wait! I recognize that! That's the vendor/device id information from before!<br />
<br />
Yes, it is. It's a rather simple format of "alias <something> <actual module>". In fact, you can alias just about anything you want. I can add "alias boogabooga snd_intel8x0m" and then safely "modprobe boogabooga".<br />
<br />
The "*" indicates it will match anything, much like filesystem globbing (''ls somedir/*''). As stated before, most aliases ignore sv, sd, bc, sc, and i by way of the "*" matching.<br />
<br />
==Where does this modules.alias file come from?==<br />
Ok, now you may be thinking "Well, hwd used to look things up based on a device table, what makes this any different?"<br />
<br />
The difference is that this lookup table is not static. It is not maintained by hand. In fact, it is built dynamically whenever you run depmod. "Where does this information come from?", you ask? Why, from the '''modules themselves'''. When you think about it, each specific module should know what hardware it supports, as it's coded specifically for that hardware. I mean, the ''nvidia'' module developers know that their modules only works for Nvidia (vendor) Graphics Cards (class). In fact, the module actually exports this information. It says "Hey, I can support this:".<br />
$ modinfo nvidia<br />
filename: /lib/modules/2.6.14-ARCH/kernel/drivers/video/nvidia.ko<br />
license: NVIDIA<br />
alias: char-major-195-*<br />
vermagic: 2.6.14-ARCH SMP preempt 686 gcc-4.1<br />
depends: agpgart<br />
alias: pci:v000010DEd*sv*sd*bc03sc00i00*<br />
<br />
As you can see by the alias listed, it looks specifically for vendor "10DE" (Nvidia) and bc/sc 0300 (which is most likely 'graphics cards'). In fact, if you look at the modinfo for '''snd_intel8x0m''':<br />
$ modinfo snd_intel8x0m<br />
filename: /lib/modules/2.6.14-ARCH/kernel/sound/pci/snd-intel8x0m.ko<br />
author: Jaroslav Kysela <perex@suse.cz><br />
description: Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; SiS 7013; NVidia MCP/2/2S/3 modems<br />
license: GPL<br />
vermagic: 2.6.14-ARCH SMP preempt 686 gcc-4.1<br />
depends: snd-ac97-codec,snd-pcm,snd-page-alloc,snd<br />
alias: pci:v00008086d00002416sv*sd*bc*sc*i*<br />
alias: pci:v00008086d00002426sv*sd*bc*sc*i*<br />
alias: pci:v00008086d00002446sv*sd*bc*sc*i*<br />
alias: pci:v00008086d00002486sv*sd*bc*sc*i*<br />
alias: pci:v00008086d000024C6sv*sd*bc*sc*i*<br />
alias: pci:v00008086d000024D6sv*sd*bc*sc*i*<br />
alias: pci:v00008086d0000266Dsv*sd*bc*sc*i*<br />
alias: pci:v00008086d000027DDsv*sd*bc*sc*i*<br />
alias: pci:v00008086d00007196sv*sd*bc*sc*i*<br />
alias: pci:v00001022d00007446sv*sd*bc*sc*i*<br />
alias: pci:v00001039d00007013sv*sd*bc*sc*i*<br />
alias: pci:v000010DEd000001C1sv*sd*bc*sc*i*<br />
alias: pci:v000010DEd00000069sv*sd*bc*sc*i*<br />
alias: pci:v000010DEd00000089sv*sd*bc*sc*i*<br />
alias: pci:v000010DEd000000D9sv*sd*bc*sc*i*<br />
<br />
It matches the aliases found by 'grep'ing the alias file. These aliases exported by each module, are gathered by depmod and merged into the modules.alias file dynamically. There is no hand-changing of a lookup table, as it is built on-the-fly. Each module knows exactly what it supports, and therefore depmod can use that information to help load modules.<br />
<br />
==How does udev work?==<br />
udev is closely tied with sysfs (the filesystem which exposes the modalias in the firstplace). In fact, to load modules based on the modalias when a new device is added (or when udev is first started on boot), it's insanely simple:<br />
<br />
DRIVER!="?*", ENV{MODALIAS}=="?*", RUN{builtin}="kmod load $env{MODALIAS}"<br />
<br />
Yep, that's it. It's a one-liner. This simple line, which is part of the default udev rules replace hotplug. Amazing, isn't it?<br />
<br />
== See also ==<br />
This article shows others modalias templates, i.e. for usb, dmi and acpi subtypes<br />
*[http://people.skolelinux.org/pere/blog/Modalias_strings___a_practical_way_to_map__stuff__to_hardware.html Modalias strings - a practical way to map "stuff" to hardware] by Petter Reinholdtsen</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Chrome_OS_devices/Custom_firmware&diff=371640Chrome OS devices/Custom firmware2015-04-28T09:37:14Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>{{Related articles start}}<br />
{{Related|Chromebook}}<br />
{{Related articles end}}<br />
{{Warning|This article relies on third-party scripts and modifications, and may irreparably damage your hardware or data. Proceed at your own risk.}}<br />
<br />
{{Poor writing|This topic on this page were moved out from the Chromebook page as it was too bloated, hard to navigate and follow, the page here is still needs a little more work to stand by it own and we can probably move out a little more details from the Chromebook page to avoid duplicates, anyone who create hot links in other pages to specific topics in this page should be aware that some topics' headers might be change.}}<br />
<br />
== Introduction ==<br />
<br />
=== Why flash a custom firmware? ===<br />
<br />
==== Pros ====<br />
<br />
* Adds a much recent version of SeaBIOS<br />
* Adds SeaBIOS payload of coreboot to Chrome OS devices that did not shipped with SeaBIOS.<br />
* Reduce boot time.<br />
* Remove developer Mode screen.<br />
* Enables VMX.<br />
* Fixes some issues (like suspend) without further modifications.<br />
<br />
==== Cons ====<br />
<br />
* Dangerous, might brick your device.<br />
* Cannot boot stock Chrome OS (you can install [http://arnoldthebat.co.uk/wordpress/chromium-os/ Arnold the Bat’s Chromium OS build] and it should be possible upgrade it to full blown Chrome OS with a script).<br />
* It is possible that some quirks will be added, [https://bbs.archlinux.org/viewtopic.php?pid=1460520#p1460520].<br />
<br />
== Flashing the custom firmware ==<br />
<br />
There are several approaches for flashing a custom firmware:<br />
* Use John Lewis' script which will save you time finding the correct firmware.<br />
* Use Matt DeVillier's [http://forum.kodi.tv/showthread.php?tid=194362 ezScript] (currently supports only Chromeboxes).<br />
* Manually with {{ic|flashrom}}, in this case you will need to obtain the firmware by yourself or to compile it from the Coreboot sources ([http://www.coreboot.org/Download_coreboot official] or [https://chromium.googlesource.com/chromiumos/third_party/coreboot/ Chromium OS fork]).<br />
<br />
=== Disable the hardware write protection ===<br />
<br />
See the [[#Disabling the hardware write protection|Disabling the hardware write protection]] at the [[#Firmware write protection|Firmware write protection]].<br />
<br />
=== Flashing with John Lewis' script ===<br />
<br />
{{Warning|Do not run the script before disabling the hardware write protection.}}<br />
<br />
==== Understanding the script ====<br />
<br />
===== What John Lewis' {{ic|getnflash_johnlewis_rom.sh}} script does ? =====<br />
* Automatically downloads Chromium OS 32bit version of {{ic|flashrom}}.<br />
* Backup your current firmware.<br />
* Disables software write protection by running {{ic|# ./flashrom --wp-disable}}.<br />
* Checks the Chromebook product name with {{Pkg|dmidecode}} and download the proper custom firmware.<br />
* Writes the custom firmware.<br />
<br />
===== What the script does not do ? =====<br />
* Does not ask for confirmation.<br />
* Does not check if the hardware write protection is disabled.<br />
* Does not confirm the compatibility of a custom firmware to a specific Chromebook sub-model.<br />
<br />
===== Conclusions ===== <br />
* Make sure you disabled the hardware write protection.<br />
* Read the [https://johnlewis.ie/custom-chromebook-firmware/faq/ FAQ].<br />
* [https://johnlewis.ie/custom-chromebook-firmware/rom-download/ Confirm that your Chromebook model is supported], if your model is untested then visit the [https://plus.google.com/communities/112479827373921524726 coreboot on Chromebooks Google+ community] and ask for advice.<br />
<br />
{{Warning|If you are flashing a custom firmware be prepared to the possibility that you might brick your device and make yourself familiar with the [[#Unbricking_Your_Chromebook|unbricking methods]].}}<br />
<br />
==== Running the script in Chrome OS ====<br />
<br />
* Access your [[#Accessing_the_superuser_shell|superuser shell]].<br />
* Enter the command shown on the [https://johnlewis.ie/custom-chromebook-firmware/rom-download/ Download ROM page at John Lewis site].<br />
<br />
{{Note|The reason for not posting here is to force you to visit the site and read the page before proceeding.}}<br />
<br />
* After the script exited copy the backed up firmware to an external storage before rebooting the system.<br />
<br />
You should now have a custom firmware installed on your device, cross your fingers and reboot.<br />
<br />
If you flashed the firmware as part of the installation process then continue by following [[#Installing_Arch_Linux|Installing Arch Linux]], if the custom firmware boots the installation media correctly then you might want to enable back the hardware write protection.<br />
<br />
==== Running the script in Arch Linux ====<br />
<br />
* In Arch Linux on 64bit environment you will need to enable the Multilib repository (if it is not already enabled) in pacman.conf and install {{Pkg|lib32-glibc}}.<br />
# pacman -S lib32-glibc<br />
<br />
* Install {{Pkg|dmidecode}}.<br />
# pacman -S dmidecode<br />
<br />
* Enter the command shown on the [https://johnlewis.ie/custom-chromebook-firmware/rom-download/ Download ROM page at John Lewis site].<br />
<br />
{{Note|The reason for not posting here is to force you to visit the site and read the page before proceeding.}}<br />
<br />
* After the script exited copy the backed up firmware to an external storage before rebooting the system.<br />
<br />
You should now have a custom firmware installed on your device, cross you fingers and reboot.<br />
<br />
If the custom firmware boots Arch Linux correctly then you might want to enable back the hardware write protection, although [https://blogs.fsfe.org/the_unconventional/2014/09/19/c720-coreboot/ John Lewis states] that it's not necessary and will only make upgrading more difficult later. However, if you do not re-enable it you want to be careful not to use flashrom.<br />
<br />
=== Flashing with ezScript ===<br />
Currently ezScript supports only Intel based Chromeboxes.<br />
<br />
Before installing this custom firmware carefully read instructions at [http://forum.kodi.tv/showthread.php?tid=194362 ezScript official page]. To install firmware only use install option #5 ({{ic|Install/update: custom coreboot Firmware}}).<br />
<br />
=== Manually with flashrom ===<br />
<br />
The use of the upstream {{Pkg|flashrom}} package is discourage as it's missing operations like {{ic|--wp-disable}}, {{ic|--wp-status}} and it will not write firmware successfully to the ROM of the Chromebook unless it already been programmed externally (i.e. flashing by another device over SPI with SOIC clip), this is why it's recommended to use Chromium OS's {{ic|flashrom}}. <br />
<br />
==== Get flashrom for Arch Linux ====<br />
<br />
* Download a 32bit statically linked Chromium OS's {{ic|flashrom}} version, enable the Multilib repository in pacman.conf and install {{Pkg|lib32-glibc}}<br />
# pacman -S lib32-glibc<br />
# wget --no-check-certificate https://johnlewis.ie/flashrom<br />
# chmod +x flashrom<br />
Do not forget that {{ic|flashrom}}'s location is not in {{ic|$PATH}}, to execute it you will need to precede the command with {{ic|./}}, e.g. {{ic|# ./flashrom}}.<br />
<br />
==== Get flashrom for Chrome OS ====<br />
<br />
Chrome OS already includes {{ic|flashrom}}.<br />
<br />
==== Basic use of flashrom ====<br />
<br />
* Disable software write protection before writing to the firmware chip.<br />
# flashrom --wp-disable<br />
<br />
* Backup firmware from the firmware chip.<br />
# flashrom -r old_firmware.bin<br />
<br />
* Write firmware to the firmware chip.<br />
# flashrom -w new_firmware.bin<br />
<br />
{{Tip|Find your firmware chip by running the command {{ic|<nowiki>flashrom -V|grep 'Found' |grep 'flash chip'</nowiki>}}}}<br />
<br />
== Flashing back stock firmware ==<br />
<br />
{{Note|The following assumes that your device is not bricked, if it does bricked then jump to [[#Unbricking your Chrome OS device|Unbricking your Chrome OS device]]}}<br />
<br />
[[#Disabling the Hardware Write Protection|Disable the hardware write protection]] and follow the how to [[#Manually_With_flashrom|manually flash firmware with {{ic|flashrom}}]] to flash the backup of your stock firmware.<br />
<br />
== Unbricking your Chrome OS device ==<br />
<br />
{{Note|This does not intended to be a thorough guide but just give you a basic understanding of the process of flashing a firmware to a bricked Chromebook. The ArchWiki is not the place for detailed hardware hacking guides so there is no sense in expanding this topic.}}<br />
<br />
=== Required tools ===<br />
<br />
* Programmer, both the [http://flashrom.org/RaspberryPi Raspberry Pi] and the [http://flashrom.org/Bus_Pirate Bus Pirate] are mentioned as compatible devices on the [http://flashrom.org/ flashrom wiki]. The [http://flashrom.org/Bus_Pirate Bus Pirate] is preferable as it will allow you to use Chromium OS's version of {{ic|flashrom}} that supports {{ic|--wp-disable}} and {{ic|--wp-status}} flags.<br />
* SOIC clip is recommended, see [http://flashrom.org/ISP].<br />
* Female jumper wires.<br />
* If you want to use Chromium OS's {{ic|flashrom}} another Linux machine (32bit or 64bit) is required.<br />
<br />
=== General idea on the unbricking process ===<br />
<br />
* Connect the jumper wires to the programmer and the SOIC clip.<br />
* Connect the SOIC clip to the ROM chip.<br />
* If your programmer is running Linux (Raspberry Pi) then modprobe the spi modules.<br />
* If your programmer is not running Linux then connect it to your Linux machine.<br />
* Write the firmware with {{ic|flashrom}}, you might need to disable software write protection by running {{ic|flashrom}} with the {{ic|--wp-disable}} flag (this is why Chromium OS's {{ic|flashrom}} is handy).<br />
<br />
=== Recommended reading about unbricking ===<br />
<br />
* Flashrom's wiki pages on [http://flashrom.org/ISP ISP], [http://flashrom.org/Bus_Pirate Bus Pirate], [http://flashrom.org/RaspberryPi Raspberry Pi] and [http://flashrom.org/Technology#SO8.2FSOIC8:_Small-Outline_Integrated_Circuit.2C_8_pins SOIC8].<br />
* [http://www.coreboot.org/Chromebooks Coreboot's wiki page on Chromebooks].<br />
* Examples of unbricking the C720: [http://www.tnhh.net/2014/08/25/unbricking-chromebook-with-beaglebone.html guide], [https://drive.google.com/folderview?id=0B9f62MH0umbmRTA2Xzd5WHhjWEU&usp=sharing pictures].<br />
* Example of unbricking HP Chromebox: [https://pomozok.wordpress.com/2015/01/10/chromebook-vivisection-readingwriting-rom-chip-data/ guide]<br />
<br />
== Firmware write protection ==<br />
<br />
{{Note|The information on this topic only intended to give you the basic understanding on the write protection feature in your Chromebook. The ArchWiki is not the place for detailed hardware hacking guides so there is no sense in expanding this topic.}}<br />
<br />
The firmware (Coreboot and its payloads) stored on a SPI chip (usually SOIC8) that some of its storage is protected from writing (mostly Coreboot).<br />
<br />
As long as the write protection was not disabled or the protected range was not set to (0,0) any change made to the unprotected part of the firmware (mainly SeaBIOS) should be recoverable with Chrome OS recovery media.<br />
<br />
There are two parts of the write protection: hardware and software.<br />
<br />
=== Hardware write protection ===<br />
<br />
The hardware write protection is an electrical circuit that when it's closed or open it prevent writing to the software protection special registers, thus the hardware write protection only protect directly these special registers but indirectly also the data in the firmware chip.<br />
<br />
To disable the hardware write protection you may need to remove a screw, press a switch or short a jumper.<br />
<br />
=== Software write protection ===<br />
<br />
The software write protection are special registers which determining if the data stored in the firmware chip is protected and also holds the range of addresses of the protected data.<br />
<br />
=== Understanding the Process of Disabling the Write Protection ===<br />
<br />
To disable the write protection one would need to:<br />
* Disable the hardware write protection of the special software register.<br />
* Change the value of the special software register to disable software write protection or change the range of the protected addresses so no data will be protected (start and end at 0).<br />
Conclusion: If we will disable the software write protection and will not enable it back, then even if we will enable the hardware write protection the firmware chip will stay unprotected.<br />
<br />
==== Disabling the hardware write protection ====<br />
<br />
To find the location of the hardware write-protect screw/switch/jumper and how to disable it visit the ArchWiki page for your Chromebook model (see [[Chromebook#Chromebook_Models|Chromebook Models]]). If there is no information about your device on the ArchWiki then turn to [http://www.chromium.org/chromium-os/developer-information-for-chrome-os-devicesDeveloper Information for Chrome OS Devices] and [http://www.coreboot.org/Chromebooks Coreboot's Chromebooks page].<br />
<br />
==== Disabling the software write protection ====<br />
<br />
Chromium OS's {{ic|flashrom}} can manipulate the software write protection special registers.<br />
* Read the status of the software write protection special registers.<br />
# flashrom --wp-status<br />
* Disable or enable the software write protection.<br />
# flashrom --wp-disable<br />
* Change software write protection addresses range.<br />
# flashrom --wp-range 0 0<br />
<br />
For more details on Chromium OS's {{ic|flashrom}} and how to obtain it, see [[#Manually_With_flashrom|Manually Flash Custom Firmware with {{ic|flashrom}}]].</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Beets&diff=371639Beets2015-04-28T09:34:16Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Audio/Video]]<br />
[[ja:Beets]]<br />
[http://beets.radbox.org/ Beets] is a music tagger and library organizer using the [http://musicbrainz.org/ MusicBrainz] database.<br />
<br />
== Installation ==<br />
<br />
[[Pacman|Install]] the {{Pkg|beets}} package from the [[official repositories]] or {{AUR|beets-git}} from the [[AUR]].<br />
<br />
== Configuration ==<br />
<br />
{{Tip|Beets provides command for configuration manipulations. To edit the configuration file, use {{ic|beet config -e}} command. It will be opened with the text editor specified in the [[Environment variables|environment variable]] {{ic|EDITOR}}.}}<br />
User configuration are done in {{ic|~/.config/beets/config.yaml}} using [[Wikipedia:YAML|YAML]] syntax. For example:<br />
{{hc|~/.config/beets/config.yaml|<br />
directory: ~/Music # The default library root directory.<br />
library: ~/Music/library.db # The default library database file to use.<br />
color: yes # Using colors in the terminal<br />
}}<br />
<br />
== Usage ==<br />
<br />
=== Add music ===<br />
<br />
* Add music to your library and attempt to fix tags:<br />
$ beet import <path><br />
<br />
* Add the single track without an album:<br />
$ beet import -s <path><br />
<br />
=== List music ===<br />
<br />
* List all music in your library:<br />
$ beet ls<br />
<br />
* List all albums in your library:<br />
$ beet ls -a<br />
<br />
=== Remove music ===<br />
<br />
{{Tip|If remove music from your filesystem or do any changes to the files without using {{ic|beet}}, do not forget to run {{ic|beet upd}} command to update your library database.}}<br />
<br />
* Remove track(s) from your library:<br />
$ beet rm <part of name><br />
<br />
* Remove album(s) from your library:<br />
$ beet rm -a <part of name><br />
<br />
== Tips and Tricks ==<br />
<br />
=== Enabling Tab-completion in Bash ===<br />
<br />
Beets includes support for Bash shell [[Bash#Tab completion|command completion]]. To enable completion put the following line into your {{ic|.bashrc}}:<br />
{{hc|~/.bashrc|eval "$(beet completion)"}}<br />
You will also need to [[Pacman|install]] {{Pkg|bash-completion}} for this to work.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Logitech_Gaming_Keyboards&diff=371638Logitech Gaming Keyboards2015-04-28T09:33:49Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Keyboards]]<br />
Some Logitech Gaming Keyboards can work on Linux through Unofficial drivers. The options are the python based [http://www.russo79.com/gnome15 Gnome15 project] and the C based [http://sourceforge.net/projects/g15daemon/ g15daemon project].<br />
<br />
== Install ==<br />
<br />
{{Pkg|g15daemon}} and its dependencies are available in the community repository. G15daemon drivers still work for the keyboards they supported, but their development was mostly dropped in 2008, the source is still available for anyone to pick up and continue their development, there are a few bugs in them that were never solved. These drivers use the {{AUR|g15macro}} to interact with the G keys. There is also a {{AUR|g15stats}} plugin to show system information on the LCD display.<br />
<br />
{{AUR|gnome15}} is available in AUR. The source site has been down since mid November. The AUR package cannot be built.<br />
<br />
=== Supported Models ===<br />
<br />
'''g15daemon''' supports:<br />
<br />
*G15 (Orange and Blue)<br />
*G11<br />
*Gamepad<br />
*G510 (Requires Patching; Read below)<br />
<br />
[http://www.russo79.com/gnome15 Gnome15] has a list of supported devices on its front page. The keyboards are:<br />
<br />
*G19<br />
*G19s<br />
*G15 (Orange and Blue)<br />
*G13<br />
*G110<br />
*G510 and G510s (Partial)<br />
<br />
== G510 on g15daemon ==<br />
<br />
[https://bbs.archlinux.org/viewtopic.php?pid=1421825 Forum Thread] (This thread has more detailed instructions and might be helpful for readers from other distributions or less advanced users, it also contains a list of known issues.)<br />
<br />
{{Note|This has not been tested with the G510s, if you want to try then find line 23 and 24 in the libg15.patch linked below and replace the device ID with the appropriate values for G510s which can be found with '''lsusb''' command from the {{Pkg|usbutils}} package}}<br />
<br />
A patch was written to make the G510 keyboard fully compatible with the g15daemon drivers. It is however not compatible with g15macro and as such an alternative approach was needed (which involved heavy modifications of the original code) the result yields much better performance for than using the gnome15 drivers which can currently result in severe input lag for this keyboard.<br />
<br />
To apply the patch you must download the g15daemon and libg15 sources with {{Pkg|abs}} and edit their PKGBUILDs. <br />
{{Note|I would recommend that you instead follow the forum thread linked to at the start of this section, it is going to be a lot easier.}}<br />
<br />
To download the sources to a folder directory called "community" (the folder will be dropped into whichever directory the terminal is in) run the two following commands:<br />
ABSROOT=. abs community/g15daemon<br />
ABSROOT=. abs community/libg15<br />
<br />
Now enter the folders and fetch the sources for them. (Make sure to remember to download the soures for both of them)<br />
makepkg -S<br />
<br />
The patch already applies the patches from the arch community repository, so remove all patches that came with g15daemon by running:<br />
rm community/g15daemon/*.patch<br />
<br />
Then download the [http://pastebin.com/5VQixu64 libg15] and [http://pastebin.com/0HBfp7XY g15daemon] patches and modify to your will. The color profiles per M-Led settings are hard coded into the libg15 patch at line 341, 344, 347 and 350 in R,G,B color code.<br />
<br />
Then place the files (libg15.patch and g15daemon.patch) into the folders that your packages were downloaded into, after this you must replace the PKGBUILDS with the new ones: [http://pastebin.com/Ff2vAEkd g15daemon], [http://pastebin.com/56a3cHhf libg15]<br />
These new PKGBUILDS refer to local sources only, this means they do not fetch sources from the net if they are not present so make sure you hold on to your tar.bz2 files. If you want them to fetch these from the net you can refer to the original PKGBUILDs.<br />
<br />
Now install the packages, libg15 comes first, {{Pkg|libg15render}} is required as well before you install g15daemon.<br />
makepkg -fic<br />
<br />
This will compile, install and clean up the extracted sources afterwards to avoid cluttering the folder. I also recommend installing [https://aur.archlinux.org/packages/g15stats/ g15stats] from AUR next. For fluff.<br />
<br />
After the installation you need to [http://www.mediafire.com/download/s24d6gjnzm4w34w/macros..rar download] or create the macro script files, and place them into /usr/share/g15daemon/macros. If you want to create them yourself the files need to be executable and the filenames are corresponding to the label on each key (so for the G1 key use /usr/share/g15daemon/macros/G1). Normally these files should use the bash script syntax.<br />
<br />
{{Note|You will need to have sudo installed and configure it so that g15daemon can be run without a password. The sleep command is to give g15daemon time to launch before g15stats is loaded into it}}<br />
For commands on the G keys to work with graphical applications g15daemon must be started after the X11 session. To do this you must add these commands to your autostart/xinitrc.<br />
sudo g15daemon && sleep 3 && g15stats<br />
<br />
<br />
And congratulations! you have a working G510 keyboard on Linux :) With a few issues of course (known issues are in the forum thread linked to at the start of this section)</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Network_bridge&diff=371637Network bridge2015-04-28T09:32:37Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Networking]]<br />
[[ja:ネットワークブリッジ]]<br />
{{Related articles start}}<br />
{{Related|Bridge with netctl}}<br />
{{Related articles end}}<br />
A bridge is a piece of software used to unite two or more network segments. A bridge behaves like a virtual network switch, working transparently (the other machines do not need to know or care about its existence). Any real devices (e.g. {{ic|eth0}}) and virtual devices (e.g. {{ic|tap0}}) can be connected to it.<br />
<br />
This article explains how to create a bridge that contains at least an ethernet device. This is useful for things like the bridge mode of [[QEMU]], setting a software based access point, etc.<br />
<br />
== Creating a bridge ==<br />
<br />
There are a number of ways to create a bridge.<br />
<br />
=== With bridge-utils ===<br />
<br />
This section describes the management of a network bridge using the ''brctl'' tool from the {{Pkg|bridge-utils}} package, which is available in the [[official repositories]]. See {{ic|man brctl}} for full listing of options.<br />
<br />
Create a new bridge:<br />
<br />
# brctl addbr ''bridge_name''<br />
<br />
Add a device to a bridge, for example {{ic|eth0}}:<br />
<br />
# brctl addif ''bridge_name'' eth0<br />
<br />
Show current bridges and what interfaces they are connected to:<br />
<br />
$ brctl show<br />
<br />
Set the bridge device up:<br />
<br />
# ip link set up dev ''bridge_name''<br />
<br />
Delete a bridge, you need to first set it to ''down'':<br />
<br />
# ip link set dev ''bridge_name'' down<br />
# brctl delbr ''bridge_name''<br />
<br />
=== With iproute2 ===<br />
<br />
This sections describes the management of a network bridge using the ''ip'' tool from the {{Pkg|iproute2}} package, which is included in the {{Grp|base}} group.<br />
<br />
Create a new bridge and change its state to up:<br />
<br />
# ip link add name ''bridge_name'' type bridge<br />
# ip link set dev ''bridge_name'' up<br />
<br />
To add an interface (e.g. eth0) into the bridge, it must be first set to ''promiscuous'' mode and its state must be up:<br />
<br />
# ip link set dev eth0 promisc on<br />
# ip link set dev eth0 up<br />
<br />
Adding the interface into the bridge is done by setting its master to {{ic|''bridge_name''}}:<br />
<br />
# ip link set dev eth0 master ''bridge_name''<br />
<br />
To show the existing bridges and associated interfaces, use the ''bridge'' utility (also part of {{Pkg|iproute2}}). See {{ic|man bridge}} for details.<br />
<br />
# bridge link show<br />
<br />
When the bridge is to be deleted, all interfaces should be removed first. Also turn off promiscuous mode and set it down to restore the original state.<br />
<br />
# ip link set eth0 promisc off<br />
# ip link set eth0 down<br />
# ip link set dev eth0 nomaster<br />
<br />
When the bridge is empty, it can be deleted:<br />
<br />
# ip link delete ''bridge_name'' type bridge<br />
<br />
=== With netctl ===<br />
<br />
See [[Bridge with netctl]].<br />
<br />
=== With systemd-networkd ===<br />
<br />
See [[systemd-networkd#Bridge interface]].<br />
<br />
=== With NetworkManager ===<br />
<br />
Gnome's NetworkManager can create bridges, but currently will not auto-connect to them. Open Network Settings, add a new interface of type Bridge, add a new bridged connection, and select the MAC address of the device to attach to the bridge.<br />
<br />
Now, find the UUID of the attached device (by default named "bridge0 slave 1"):<br />
<br />
$ nmcli connection<br />
<br />
Finally, enable that connection:<br />
<br />
$ nmcli con up <UUID><br />
<br />
If NetworkManager's default interface for the device you added to the bridge connects automatically, you may want to disable that by clicking the gear next to it in Network Settings, and unchecking "Connect automatically" under "Identity."<br />
<br />
== Assigning an IP address ==<br />
<br />
When the bridge is fully set up, it can be assigned an IP address:<br />
<br />
# ip addr add dev ''bridge_name'' 192.168.66.66/24<br />
<br />
{{Expansion|This section needs to be connected to the link-level part described in [[QEMU#Tap networking with QEMU]]. For now, see the instructions given there.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Wireless interface on a bridge ===<br />
<br />
To add a wireless interface to a bridge, you first have to assign the wireless interface to an access point or start an access point with [[Software_access_point|hostapd]]. Otherwise the wireless interface will not be added to the bridge.<br />
<br />
See also [https://wiki.debian.org/BridgeNetworkConnections#Bridging_with_a_wireless_NIC Bridging with a wireless NIC] on Debian wiki.<br />
<br />
== See also ==<br />
<br />
* [http://www.linuxfoundation.org/collaborate/workgroups/networking/bridge Official documentation for bridge-utils]<br />
* [http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 Official documentation for iproute2]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=TunnelBear&diff=371636TunnelBear2015-04-28T09:31:42Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Virtual Private Network]]<br />
{{Stub|Instructions to copy 3rd party configs into {{ic|/etc/openvpn/}} is not the ArchWiki way.}}<br />
<br />
[https://www.tunnelbear.com TunnelBear] is a VPN provider that utilizes OpenVPN protocol.<br />
<br />
In order to use this tutorial, one must have Giant or Grizzly subscription.<br />
<br />
{{Note|There is an [https://www.tunnelbear.com/updates/linux_support/ easier] method to use TunnelBear service for Gnome users.}}<br />
<br />
== Walkthrough ==<br />
<br />
Install '''openvpn''' from the official repository.<br />
<br />
Download [https://s3.amazonaws.com/tunnelbear/linux/openvpn.zip TunnelBear OpenVPN config files].<br />
<br />
Unzip the folder, and copy all the files to<br />
<br />
$ /etc/openvpn/<br />
<br />
Do not forget to change the permission<br />
<br />
$ sudo chmod 600 /etc/openvpn/*<br />
<br />
Pick the corresponding '''.ovpn''' that will be used (TunnelBear Japan is used as an example)<br />
<br />
Rename the extension & remove the space<br />
<br />
$ mv /etc/openvpn/TunnelBear\ Japan.ovpn /etc/openvpn/TunnelBearJapan.conf<br />
<br />
Edit the '''.conf''' file<br />
<br />
{{hc|/etc/openvpn/TunnelBearJapan.conf|<br />
.<br />
.<br />
keepalive 10 30<br />
auth-user-pass login.key<br />
.<br />
.<br />
}}<br />
<br />
Create '''login.key'''<br />
<br />
{{hc|/etc/openvpn/login.key|<br />
<br />
yourtunnelbearusername<br />
yourtunnelbearpassword<br />
<br />
}}<br />
<br />
Start & add it to systemd boot process<br />
<br />
$ sudo systemctl start openvpn@TunnelBearJapan.service<br />
$ sudo systemctl enable openvpn@TunnelBearJapan.service<br />
<br />
== References ==<br />
<br />
* [https://github.com/JenniferMack/TunnelBear-Helper TunnelBear Helper]<br />
* [https://wiki.archlinux.org/index.php/OpenVPN Arch Wiki OpenVPN]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PulseAudio/Configuration&diff=371635PulseAudio/Configuration2015-04-28T09:31:14Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register, spelling</p>
<hr />
<div>[[Category:Audio/Video]]<br />
[[Category:Sound]]<br />
{{Merge|PulseAudio|Most of valuable informations have been merged; when it is done completely, please [[Help:Editing#Redirects|redirect]] this page to [[PulseAudio#Configuration]].}}<br />
<br />
[[Wikipedia:PulseAudio|PulseAudio]] PulseAudio is a general purpose sound server intended to run as a middleware between your applications and your hardware devices, either using [[ALSA]] or [[OSS]]. In its default configuration, PulseAudio attemps to make controlling and routing audio streams to the correct place easier with its own graphical configuration tools and deep integration in some desktop environments, like the sound applet in [[Gnome]] or veromix in [[KDE]]. It also offers easy network streaming accross local devices using [[Avahi]] if enabled. While its main purpose is to ease audio configuration, its modular design allows more advanced users to configure the daemon precisely to best suit their needs.<br />
<br />
== Installation ==<br />
<br />
<br />
PulseAudio only requires the {{Pkg|pulseaudio}} package to run, but you may also want to install various other tools to help you configure it and integrate better with your desktop environment.<br />
<br />
{| class="wikitable"<br />
|+ PulseAudio packages<br />
! Package || Usage<br />
|+<br />
| {{Pkg|pulseaudio}} (required) || The main daemon, commandline tools and libraries.<br />
|+<br />
| {{Pkg|pulseaudio-alsa}} || Provides an {{ic|/etc/asound.conf}} configuration file that sets the [[ALSA]] default plugin to pulse, thus redirecting playback and capture to PulseAudio. Highly recommended to avoid conflicts between ALSA applications and PulseAudio if you intend to run PulseAudio all the time and use the default configuration.<br />
|+<br />
| {{Pkg|paprefs}} || A GUI for general daemon configuration. <br />
|+<br />
| {{Pkg|pavucontrol}} || An advanced volume control GUI: allows to change the volume of individual streams and configure the ports of all sound cards.<br />
|+<br />
| {{Pkg|ponymix}} and {{AUR|pamixer-git}} || CLI mixers similar to pavucontrol.<br />
|+<br />
| [https://github.com/Siot/PaWebControl PaWebControl] || A web GUI similar to {{Pkg|pavucontrol}} to remotely control volumes (like from a mobile device).<br />
|+<br />
| {{AUR|pasystray-git}} || A system tray for volume adjustment as well as a few basic operations like switching sinks and sources.<br />
|+ <br />
| {{Pkg|kdemultimedia-kmix}} || KDE's default volume control applet with similar functions to pavucontrol.<br />
|+<br />
| {{AUR|kdeplasma-applets-veromix}} || An advanced PulseAudio applet for KDE.<br />
|}<br />
<br />
== Easy configuration ==<br />
<br />
By default, PulseAudio is configured to automatically detect all sound cards and manage them. It takes control of all detected ALSA devices and redirect all audio streams to itself, making the PulseAudio daemon the central configuration point. The daemon should work mostly out of the box, only requiring a few minor tweaks using the GUI configuration tools. All settings are saved in {{ic|~/.config/pulse}} and automatically restored when the daemon starts. Use the following tools to configure the daemon to your taste:<br />
<br />
=== {{Pkg|paprefs}} ===<br />
* Simultaneous output to all sound cards<br />
* Network device streaming and discovery (requires [[Avahi]] daemon to be installed and running): play sound on any computer on your network from any computer.<br />
<br />
=== {{Pkg|pavucontrol}} ===<br />
* Per-application volume control<br />
* Manage input and output devices volumes and outputs<br />
* Sound card configuration to select input/output ports to use and enable/disable devices<br />
<br />
{{Warning|Do '''not''' attempt to change the ALSA configuration files while using the default PulseAudio configuration. The default configuration grabs the hardware devices directly in order to allow all the on-the-fly configurations using the GUIs. Changes to the ALSA configurations will very likely be ignored by PulseAudio and ALSA applications will break randomly while trying to access an ALSA device already used by PulseAudio. If you intend to change the ALSA configurations, also configure PulseAudio manually to output to your own ALSA device and play nice with your configuration.}}<br />
<br />
== Advanced configuration ==<br />
While PulseAudio usually runs fine out of the box and requires only minimal configuration, advanced users can change almost every aspect of the daemon by either altering the default configuration file to disable modules or writing your own from scratch. PulseAudio runs as a server daemon that can run either system-wide or on per-user basis using a client/server architecture. The daemon by itself does nothing without its modules except to provide an API and host dynamically loaded modules. The audio routing and processing tasks are all handled by various modules, including Pulse's native protocol itself (provided by [http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#index22h3 module-native-protocol-unix]). Clients reach the server through one of many protocol modules that will accept audio from external sources, route it through PulseAudio and eventually have it go out through a final other module. The output module does not have to be an actual sound output: it can dump the stream into a file, stream it to a broadcasting server such as [[Icecast]], or even just discard it.<br />
<br />
=== Configuration files ===<br />
PulseAudio can be configured in multiple ways depending on your needs and uses multiple different configuration files. Configuration files are read from {{ic|~/.pulse/}} first, then from {{ic|/etc/pulse/}} for system-wide defaults. People usually change the system-wide version unless they intend to have multiple users with different configurations.<br />
<br />
==== {{ic|daemon.conf}} ====<br />
This is the main configuration file to configure the daemon itself. It defines base settings like the default sample rates used by modules, resampling methods, realtime scheduling and various other settings related to the server process. These can not be changed at runtime without restarting the PulseAudio daemon. Most defaults make sense here and are self-explaining, see the {{ic|pulse-daemon.conf}} [[man]] page for additional information. Boolean options accepts any of these: {{ic|true}}, {{ic|yes}}, {{ic|on}} and {{ic|1}} as well as {{ic|false}}, {{ic|no}}, {{ic|off}} and {{ic|0}}. <br />
<br />
{| class="wikitable"<br />
|+ Notable configuration options<br />
! Option || Description<br />
|+<br />
| system-instance || If set to {{ic|yes}}, the daemon will run as a system-wide instance. Highly discouraged as it can introduce security issues. Can be used when multiple users will use sound at the same time, either remotely or locally using [[Xorg_multiseat]]. Defaults to {{ic|no}}.<br />
|+<br />
| realtime-scheduling || If your kernel supports realtime scheduling (for instance, [[Kernels#-rt]] or [[Kernels#-ck]]), set this to {{ic|yes}} to ensure PulseAudio can deliver low-latency glitch-free playback. You can adjust {{ic|realtime-priority}} as well to have it use the correct priority, especially when [[JACK]] is also running on the system.<br />
|+<br />
| exit-idle-time || If you want to run PulseAudio only when needed and use ALSA otherwise, you can set a delay in seconds after which the daemon will automatically shutdown after all clients are disconnected. Set it to -1 to disable this feature.<br />
|+<br />
| resample-method || When PulseAudio needs to pass audio from one module to another using incompatible sample-rate (for example, playback at 96kHz to a card that only supports a maximum of 48kHz), specifies which resampler to use. You can use the command {{ic|$ pulseaudio --dump-resample-methods}} to list all available resamplers and choose the best tradeoff between CPU usage and audio quality for your taste. {{Tip|One of the major complaint about PulseAudio is its high CPU usage in some use cases. A lot of these cases happens when pulse needs to resample multiple streams (individually). If you intend to mix multiple sample rates often, consider creating an additional sink at the correct sample rate which you can then feed back to your main sink, resampling only once.}}<br />
|+<br />
| enable-remixing || When the input and output have a different channel count (for example, outputting a 6 channel movie into a stereo sink), pulse can either remix all the channels (default, {{ic|yes}}) or just trivially map the channels by their name (left goes to left, right to right, all others ignored) when {{ic|no}}<br />
|+<br />
| flat-volumes || If {{ic|yes}} (default), all input sources have their volume relative to the maximum volume of the entire sound card. This allows each application to individually adjust their volume so for example, raising your VoIP call volume will raise the hardware volume and adjust your music player volume so it stays where it was, avoiding confusion by having to lower manually the music player then raise the global volume. {{Warning|Sometimes this can be more confusing than what it solves and some applications unaware of this feature can set their volume at 100% at startup, potentially blowing your speakers or your ears. If unsure, prefer to set this to {{ic|no}} so pulse will use the classic ALSA behavior instead.}}<br />
|+<br />
| default-fragments || Audio samples are splitted into multiple fragments of {{ic|default-fragment-size-msec}} each. The larger the buffer is, the less likely audio will skip when the system is overloaded, but will also increase the overall latency. Increase this value if you have issues.<br />
|+<br />
| default-fragment-size-msec || The size in milliseconds of each fragment. This is the amount of data that will be processed at once by the daemon. TODO: Verify<br />
|}<br />
<br />
<br />
==== {{ic|default.pa}} ====<br />
This file is a startup script and is used to configure modules. It is actually parsed and read after the daemon has finished initializing and additional commands can be sent at runtime using {{ic|$ pactl}} or {{ic|$ pacmd}}. The startup script can also be provided on the command line by starting PulseAudio in a terminal using {{ic|$ pulseaudio -nC}}. This will make the daemon load the CLI module and will accept the configuration directly from the command line, and output resulting information or error messages on the same terminal. This can be useful when debugging the daemon or just to test various modules before setting them permanently on disk. The manual page is quite self explaining, please consult {{ic|man pulse-cli-syntax}} for the details of the syntax.<br />
<br />
In order to configure the daemon, you will mostly only need the very basic commands:<br />
<br />
{| class="wikitable"<br />
|+ Basic PA commands<br />
! Command || Action<br />
|+<br />
| {{ic|1=load-module module-name option1=value1 option2=value2}} || Loads a module called {{ic|module-name}} with two options called {{ic|option1}} and {{ic|option2}}<br />
|+<br />
| {{ic|unload-module 42}} or {{ic|unload-module module-alsa-sink}} || Unloads a module by its index (returned by the load-module command) or all modules by name.<br />
|+<br />
| {{ic|.fail}} || Allows all commands after this statement to fail without interrupting the script and shutting down the daemon. This is useful when you know some commands could fail and would not affect overall operation, like loading modules for removable devices or network devices that can potentially get unreachable.<br />
|+<br />
| {{ic|.nofail}} || Reverse of .fail: failing commands after this statement will interrupt the script and will cause the daemon to return an error. <br />
|}<br />
<br />
There are plenty more commands available that are useful at runtime to control the daemon, see the {{ic|pactl}} manpage for more details. Everything that an be made in {{ic|pavucontrol}} can also be made on the command line, useful for bash scripts.<br />
<br />
<br />
==== {{ic|client.conf}} ====<br />
This is the configuration file read by every PulseAudio client applications. It is used to configure runtime options for individual clients. It can be used to set the configure the default sink and source statically as well as allowing (or disallowing) clients to automatically start the server if not currently running.<br />
<br />
{| class="wikitable"<br />
|+ Useful client.conf options<br />
! Option || Description<br />
|+<br />
| autospawn || If enabled, clients will automatically start PulseAudio if it is not already running when a client attempts to connect to it. This can be useful if you do not want PulseAudio to always be running to conserve system resources. Otherwise, you really should have it start with your X11 session.<br />
|}<br />
<br />
<br />
<br />
=== Connection & authentication ===<br />
Since PulseAudio runs as a daemon as the current user, clients needs to know where to find the daemon socket to connect to it as well as a shared random cookie file clients use to authenticate with it. By default, clients should be able to locate the daemon without problem using environment variables, X11 root window properties and finally by trying the default location ({{ic|unix:/run/user/$ID/pulse/native}}). However, if you have clients that needs to access PulseAudio outside of your X11 session like [[mpd]] running as a different user, you will need to tell it how to connect to your PulseAudio instance. See [[PulseAudio/Examples#TODO]] for a complete example. An authentication cookie containing random bytes is enabled by default to ensure audio does not leak from one user to another on a multi-user system. If you already control who can access the server using user/group permissions, you can disable the cookie by passing {{ic|1=auth-cookie-enabled=0}} to {{ic|module-native-protocol-unix}}.<br />
<br />
==== Environment variables ====<br />
These two variables are the important ones in order for libpulse clients to locate PulseAudio if you moved its socket to somewhere else. See {{ic|man pulseaudio}} for more details and other useful environment variables clients will read.<br />
<br />
{| class="wikitable"<br />
! Variable || Definition<br />
|+<br />
| {{ic|PULSE_SERVER}} || Defines where the server is. It takes a protocol prefix like {{ic|unix:}} or {{ic|tcp}} followed by the path or IP of the server. Example: {{ic|unix:/home/pulse/native-sock}}.<br />
|+<br />
| {{ic|PULSE_COOKIE}} || Point this to the location of a file that contains the random cookie generated by PulseAudio. This file will be read by clients and its content sent to the server, thus the file has to be readable by all audio clients. It does not need to be the same file, as long as its content matches the one the daemon uses.<br />
|}<br />
<br />
==== X11 properties ====<br />
PulseAudio also uses window properties on the root window of the X11 server to help find the daemon. Since environment variables cannot be modified after child processes are started , X11 properties are more flexible because they are more easily changed because they are globally shared. As long as applications receive a {{ic|1=DISPLAY=}} environment variable, it can read the most up-to-date values. X11 properties can be queried using {{ic|xprop -root}}, or with {{ic|pax11publish -d}} to read pulse-specific properties. {{ic|pax11publish}} can also be used to update the properties from environment variables ({{ic|pax11publish -e}} or remove them entirely {{ic||pax11publish -r}}. If possible, it is recommended to let PulseAudio do it my itself using the module-x11-publish module or the {{ic|start-pulseaudio-x11}} command. The following table is there only for completeness, you should not ever need to manually set these variables by hand.<br />
<br />
{| class="wikitable"<br />
! Variable || Definition<br />
|+<br />
| {{ic|PULSE_SERVER}} || String value ({{ic|xprop -root -f PULSE_SERVER 8s -set PULSE_SERVER "unix:/tmp/pulse-sock"}}), works the same as the environment variable of the same name.<br />
|+<br />
| {{ic|PULSE_COOKIE}} || String value that contains the hexadecimal representation of the authentication cookie.<br />
|}<br />
<br />
<br />
== Modules ==<br />
=== Protocols ===<br />
{{Stub|Local sound, network sound, file sounds, streaming servers}}<br />
=== ALSA ===<br />
{{Stub|TODO: Explain both static ALSA configuration and automatic detection. How to use ALSA plugins. Mention that PulseAudio likes real hardware way better than plugins for latency and power-saving controls}}<br />
=== JACK ===<br />
{{Stub|Jack auto-detection or static Jack client}}<br />
=== Filters & Routing ===<br />
{{Stub|Collection of useful modules for audio processing (EQ) and routing (combining card, splitting cards, imitating JACK features}}<br />
<br />
<br />
== Further resources ==<br />
{{Stub|Links to useful documentation, official PA wiki, manual pages, etc.}}</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Vim/YouCompleteMe&diff=371634Vim/YouCompleteMe2015-04-28T09:29:27Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Development]]<br />
[[Category:Text editors]]<br />
[https://github.com/Valloric/YouCompleteMe YouCompleteMe] (shortened as YCM) is a code-completion engine for [[Vim]]. It supports the following languages:<br />
<br />
* C/C++<br />
* Python<br />
* Java<br />
* Ruby<br />
* C#<br />
<br />
== Installation ==<br />
<br />
Install {{AUR|vim-youcompleteme-git}} package from [[AUR]]. For an alternative manual way of installing YouCompleteMe see [https://github.com/Valloric/YouCompleteMe#full-installation-guide upstream instructions].<br />
<br />
== Configuration ==<br />
<br />
=== C/C++ ===<br />
<br />
YCM uses a python script called {{ic|.ycm_extra_conf.py}} to set project wide settings, needed to provide completion and syntax check. A brief introduction to essential configuration follows, for details and advanced options see the [https://github.com/Valloric/YouCompleteMe#options upstream documentation].<br />
<br />
==== Extra conf structure ====<br />
<br />
A sample {{ic|.ycm_extra_conf.py}} may be found [https://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py here]. You should save a copy of this file in your project folder and customize it with adequate settings for your source files. The most important settings (which usually suffices for a minimal configuration) are the {{ic|-x}} and {{ic|--std}} options, which respectively tell to the sintax checker the language used in the project and the [https://en.wikipedia.org/wiki/ISO/IEC_JTC_1/SC_22 standard] followed. The {{ic|-x}} value may be set to {{ic|c}} or {{ic|c++}}, while common values for the {{ic|--std}} are {{ic|1=--std=c89}}, {{ic|1=--std=c99}}, {{ic|1=--std=c11}}, {{ic|1=--std=c14}} and their respective c++ version. The standard parameter will determine the warning and the errors in the syntax check (e.g., a line commented with {{ic|//}} will be marked as unallowed in C89, but not under following versions of the standard).<br />
<br />
A third party script and vim plugin for the automatic generation of the {{ic|.ycm_extra_conf.py}} is avaible on [https://github.com/rdnetto/YCM-Generator this repo].<br />
<br />
==== Extra conf location ====<br />
<br />
The program searches for the {{ic|.ycm_extra_conf.py}} file on startup in the current source file directory and in its parent folders. If the file is not found, YCM features are not avaible. A global file (used as fallback when a local extra conf file is not found) may be set adding the following to {{ic|~/.vimrc}}:<br />
<br />
{{hc|1=~/.vimrc|2=<br />
let g:ycm_global_ycm_extra_conf = '/path/to/the/file'<br />
}}<br />
<br />
Being the extra conf file a python script, when a file is found a confirmation is asked for security reason before to load it. This behaviour may be disabled adding the following to {{ic|~/.vimrc}}:<br />
<br />
{{hc|1=~/.vimrc|2=<br />
let g:ycm_confirm_extra_conf = 0<br />
}}<br />
<br />
For a less unsecure solution, when the confirmation is enabled an extra conf file blacklist/whitelist may be set assigning a list of patterns to the {{ic|ycm_extra_conf_globlist}} variable. A file matching one pattern is blacklisted if the pattern begins with {{ic|!}}, whitelisted otherwise, confirmation is asked if the file does not match any pattern. Rule precedence is determined by the order, and the first match is applied. Some glob pattern rules are avaible:<br />
* * matches everything<br />
* ? matches any single character<br />
* [seq] matches any character in seq<br />
* [!seq] matches any char not in seq<br />
<br />
In example, with the following setting<br />
<br />
{{hc|1=~/.vimrc|2=<br />
let g:ycm_extra_conf_globlist = ['~/dev/*','!~/*']<br />
}}<br />
<br />
any file in {{ic|~/dev}} will be whitelisted, any in {{ic|~/}} will be blacklisted, and due to order precedence any file in {{ic|~/}} excepted the {{ic|~/dev}} folder will be blacklisted.<br />
<br />
=== Java ===<br />
<br />
For Java completion, a project file should be present and Eclim headless server must be running.<br />
<br />
<ol><br />
<li><br />
Install {{AUR|eclim}} or {{AUR|eclim-git}} from [[AUR]].<br />
</li><br />
<li><br />
Put this in your [[Vim/.vimrc|.vimrc]]:<br />
<br />
{{hc|1=~/.vimrc|2=<br />
let g:EclimCompletionMethod = 'omnifunc'}}<br />
</li><br />
<li><br />
Start {{ic|eclimd}} script in a separate terminal:<br />
<br />
{{bc|$ /usr/share/eclipse/eclimd}}<br />
</li><br />
<li><br />
Create a file named {{ic|.project}} in the same directory as your Java files:<br />
<br />
{{hc|.project|<br />
<projectDescription><br />
<name>''PROJECTNAME''</name><br />
</projectDescription><br />
}}<br />
</li><br />
<li><br />
Open your Java file in Vim and run:<br />
<br />
{{bc|:ProjectCreate . -n java}}<br />
<br />
</li><br />
</ol><br />
<br />
To compile the project:<br />
<br />
:ProjectBuild<br />
<br />
To run the project:<br />
<br />
:Java<br />
<br />
To run only current file:<br />
<br />
:Java %<br />
<br />
A list of avaible commands may be found [http://eclim.org/cheatsheet.html here].<br />
<br />
=== C# ===<br />
<br />
{{Note|For C# completion to "just work" simply create an empty {{ic|.sln}} file in current or parent directory. The rest of this section explains how to manually create a full working C# project.}}<br />
<br />
The easiest way to create a project is to use {{Pkg|monodevelop}}. The rest of this section explains how to manually create a C# project which can also be built from command line with {{ic|xbuild}}.<br />
<br />
First create a solution file. Replace '''''bold-italic''''' names appropriately.<br />
<br />
{{hc|'''''SOLUTION'''''.sln|<nowiki><br />
<br />
Microsoft Visual Studio Solution File, Format Version 11.00<br />
# Visual Studio 2010<br />
Project("{00000000-0000-0000-0000-000000000000}") = "</nowiki>'''''PROJECT'''''", "'''''PROJECT'''''\'''''PROJECT'''''<nowiki>.csproj", "{11111111-1111-1111-1111-111111111111}"<br />
EndProject<br />
EndProject<br />
Global<br />
GlobalSection(SolutionConfigurationPlatforms) = preSolution<br />
Debug|x86 = Debug|x86<br />
Release|x86 = Release|x86<br />
EndGlobalSection<br />
GlobalSection(ProjectConfigurationPlatforms) = postSolution<br />
{11111111-1111-1111-1111-111111111111}.Debug|x86.ActiveCfg = Debug|x86<br />
{11111111-1111-1111-1111-111111111111}.Debug|x86.Build.0 = Debug|x86<br />
{11111111-1111-1111-1111-111111111111}.Release|x86.ActiveCfg = Release|x86<br />
{11111111-1111-1111-1111-111111111111}.Release|x86.Build.0 = Release|x86<br />
EndGlobalSection<br />
EndGlobal</nowiki>}}<br />
<br />
Then create a directory named {{ic|PROJECT}} and in it a file named {{ic|PROJECT.csproj}}:<br />
<br />
{{hc|1='''''PROJECT'''''/'''''PROJECT'''''.csproj|2=<nowiki><br />
<?xml version="1.0" encoding="utf-8"?><br />
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><br />
<PropertyGroup><br />
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration><br />
<Platform Condition=" '$(Platform)' == '' ">x86</Platform><br />
<ProductVersion>10.0.0</ProductVersion><br />
<SchemaVersion>2.0</SchemaVersion><br />
<ProjectGuid>{11111111-1111-1111-1111-111111111111}</ProjectGuid><br />
<OutputType>Exe</OutputType><br />
<RootNamespace></nowiki>'''''PROJECT'''''<nowiki></RootNamespace><br />
<AssemblyName></nowiki>'''''PROJECT'''''<nowiki></AssemblyName><br />
</PropertyGroup><br />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "><br />
<DebugSymbols>true</DebugSymbols><br />
<DebugType>full</DebugType><br />
<Optimize>false</Optimize><br />
<OutputPath>bin\Debug</OutputPath><br />
<DefineConstants>DEBUG;</DefineConstants><br />
<ErrorReport>prompt</ErrorReport><br />
<WarningLevel>4</WarningLevel><br />
<ConsolePause>false</ConsolePause><br />
<PlatformTarget>x86</PlatformTarget><br />
</PropertyGroup><br />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "><br />
<DebugType>full</DebugType><br />
<Optimize>true</Optimize><br />
<OutputPath>bin\Release</OutputPath><br />
<ErrorReport>prompt</ErrorReport><br />
<WarningLevel>4</WarningLevel><br />
<ConsolePause>false</ConsolePause><br />
<PlatformTarget>x86</PlatformTarget><br />
</PropertyGroup><br />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /><br />
<ItemGroup></nowiki><br />
<Compile Include="'''''HelloWorld.cs'''''" /><br />
<Compile Include="'''''CSharpFile1.cs'''''" /><br />
<Compile Include="'''''CSharpFile2.cs'''''" /><br />
</ItemGroup><br />
</Project><br />
}}<br />
<br />
Place your C# files in {{ic|PROJECT}} directory and do not forget to manually add them at the bottom of {{ic|PROJECT/PROJECT.csproj}}.<br />
<br />
Now YouCompleteMe should work for C# files in that directory and you can build the project. To compile the project from inside Vim:<br />
:!xbuild<br />
<br />
== Troubleshooting ==<br />
<br />
Remember that it might take some time for YouCompleteMe to generate a list of completion strings.<br />
<br />
The following commands are available for diagnostics:<br />
* {{ic|:messages}} - show previous errors or messages from Vim<br />
* {{ic|:YcmDiags}}<br />
* {{ic|:YcmDebugInfo}}<br />
<br />
=== E764: Option 'omnifunc' is not set ===<br />
<br />
If this happens for Java files, you forgot to put this in your ''.vimrc'':<br />
<br />
{{hc|1=~/.vimrc|2=<br />
let g:EclimCompletionMethod = 'omnifunc'<br />
}}<br />
<br />
=== No completion in Java files ===<br />
<br />
Make sure {{ic|eclimd}} daemon is running:<br />
$ ps -ax|grep eclimd<br />
<br />
and that you have first generated project files.<br />
<br />
=== URLError: <urlopen error [Errno 111] Connection refused> ===<br />
<br />
This error appears when you do not have a {{ic|.sln}} file in current or parent directory.<br />
<br />
=== RuntimeError: Error starting OmniSharp server: no solutionfile found ===<br />
<br />
Same as above.<br />
<br />
=== Ctrl+space does not trigger the completion anymore in terminal vim ===<br />
<br />
Due to [https://bugs.kde.org/show_bug.cgi?id=341157 a bug] in KDE Framework5/Qt5, the {{ic|Ctrl+space}} key combination is not recognized by Konsole5. A temporary workaround may be to set another trigger for YouCompleteMe completion, changing the value of the variable {{ic|ycm_key_invoke_completion}}, e.g. to use {{ic|Ctrl-b}} instead of {{ic|Ctrl-space}} add the following to the {{ic|~/.vimrc}} config file:<br />
<br />
{{hc|1=~/.vimrc|2=<br />
let g:ycm_key_invoke_completion = '<C-b>'<br />
}}<br />
<br />
== See also ==<br />
<br />
* [https://github.com/Valloric/YouCompleteMe GitHub page]<br />
* [http://valloric.github.io/YouCompleteMe/ Project homepage]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Systemd-networkd&diff=371633Systemd-networkd2015-04-28T09:29:00Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Network managers]]<br />
[[Category:Virtualization]]<br />
[[fr:systemd-networkd]]<br />
[[ja:systemd-networkd]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|systemd-nspawn}}<br />
{{Related|Network bridge}}<br />
{{Related|Network configuration}}<br />
{{Related|Wireless network configuration}}<br />
{{Related|:Category:Network managers}}<br />
{{Related articles end}}<br />
<br />
''systemd-networkd'' is a system daemon that manages network configuration. It detects and configures network devices as they appear, as well as creates virtual network devices. This service can especially be very useful to setup basic or more complex network settings for a container managed by [[systemd-nspawn]] such as VMs or containers. Again, but also works fine on simple connections.<br />
<br />
== Basic usage ==<br />
The {{Pkg|systemd}} package is part of the default Arch install and contains all needed files to operate a wired network. Wireless adapters can be setup by other services such as [[wpa_supplicant]] which is covered later in this article.<br />
<br />
=== Required services and setup ===<br />
<br />
To use systemd-networkd, one needs to [[start]] the following two services and [[enable]] them to run on a system boot:<br />
<br />
* {{ic|systemd-networkd.service}}<br />
* {{ic|systemd-resolved.service}}<br />
<br />
For compability with [[resolv.conf]], delete or rename the existing file and create the following symbolic link:<br />
<br />
# ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf<br />
<br />
See {{ic|man systemd-resolved}}.<br />
<br />
=== Configuration examples ===<br />
All configurations in this section are stored as {{ic|foo.network}} in {{ic|/etc/systemd/network}}. For a full listing of options and processing order, see [[#Configuration files]] and the {{ic|systemd.network}} man page.<br />
<br />
One needs to know the name of the devices on the system. In days past, {{ic|eth0}} was the generic first NIC on the system, udev now defaults to a non-persistent naming scheme. Use {{ic|networkctl list}} to list the devices on the system.<br />
<br />
{{Note|In the examples below, '''enp1s0''' is the wired adapter and '''wlp0s20u3u1''' is the wireless adapter. These names can be different on different systems.}}<br />
<br />
==== Wired adapter using DHCP ====<br />
{{hc|/etc/systemd/network/''wired''.network|<nowiki><br />
[Match]<br />
Name=enp1s0<br />
<br />
[Network]<br />
DHCP=ipv4</nowiki><br />
}}<br />
<br />
==== Wired adapter using a static IP ====<br />
{{hc|/etc/systemd/network/''wired''.network|<nowiki><br />
[Match]<br />
Name=enp1s0<br />
<br />
[Network]<br />
DNS=10.1.10.1<br />
<br />
[Address]<br />
Address=10.1.10.9/24<br />
<br />
[Route]<br />
Gateway=10.1.10.1</nowiki><br />
}}<br />
<br />
==== Wireless adapter ====<br />
As stated earlier, one needs to have configured a wireless adapter with another service such as [[wpa_supplicant]] and the corresponding service is required to be enabled. In this example, that would be {{ic|wpa_supplicant@wlp0s20u3u1.service}}.<br />
<br />
{{hc|/etc/systemd/network/''wireless''.network|<nowiki><br />
[Match]<br />
Name=wlp0s20u3u1<br />
<br />
[Network]<br />
DHCP=ipv4<br />
</nowiki>}}<br />
<br />
==== Wired and wireless adapters on the same machine ====<br />
<br />
This set up will enable a DHCP IP for both a wired and wireless connection making use of the metric directive to allow the kernel the decide on-the-fly which one to use. This way, no connection downtime is observed when the wired connection is unplugged.<br />
<br />
The kernel's route metric (same as configured with ''ip'') decides which route to use for outgoing packets, in cases when several match. This will be the case when both wireless and wired devices on the system have active connections. To break the tie, the kernel uses the metric. The nice thing about this is that if one of them goes away, the other automatically wins without there being a gap with nothing configured (ongoing transfers may still not deal with this nicely but that is at a different OSI layer).<br />
<br />
{{Note|The '''Metric''' option is for static routes while the '''RouteMetric''' option is for setups not using static routes.}}<br />
<br />
{{hc|/etc/systemd/network/''wired''.network|<nowiki><br />
[Match]<br />
Name=enp1s0<br />
<br />
[Network]<br />
DHCP=ipv4<br />
<br />
[DHCP]<br />
RouteMetric=10<br />
</nowiki>}}<br />
<br />
{{hc|/etc/systemd/network/''wireless''.network|<nowiki><br />
[Match]<br />
Name=wlp0s20u3u1<br />
<br />
[Network]<br />
DHCP=ipv4<br />
<br />
[DHCP]<br />
RouteMetric=20<br />
</nowiki>}}<br />
<br />
== Configuration files ==<br />
<br />
Configuration files will be read from {{ic|/usr/lib/systemd/network}}, the volatile runtime network directory {{ic|/run/systemd/network}} and the local administration network directory {{ic|/etc/systemd/network}}. Files in {{ic|/etc/systemd/network}} have the highest priority.<br />
<br />
There are three types of configuration files. <br />
<br />
* '''.network''' files. They will apply a network configuration for a ''matching'' device<br />
* '''.netdev''' files. They will create a ''virtual network device'' for a ''matching'' environment<br />
* '''.link''' files. When a network device appears, [[udev]] will look for the first ''matching'' '''.link''' file<br />
<br />
They all follow the same rules: <br />
<br />
* If '''all''' conditions in the {{ic|[Match]}} section are matched, the profile will be activated<br />
* an empty {{ic|[Match]}} section means the profile will apply in any case (can be compared to the {{ic|*}} joker)<br />
* each entry is a key with the {{ic|1=NAME=VALUE}} syntax <br />
* all configuration files are collectively sorted and processed in lexical order, regardless of the directory in which they live<br />
* files with identical name replace each other<br />
<br />
{{Tip|<br />
* to override a system-supplied file in {{ic|/usr/lib/systemd/network}} in a permanent manner (i.e even after upgrade), place a file with same name in {{ic|/etc/systemd/network}} and symlink it to {{ic|/dev/null}}<br />
* the {{ic|*}} joker can be used in {{ic|VALUE}} (e.g {{ic|en*}} will match any Ethernet device)<br />
* following this [https://mailman.archlinux.org/pipermail/arch-general/2014-March/035381.html Arch-general thread], the best practice is to setup specific container network settings ''inside the container'' with '''networkd''' configuration files.<br />
}}<br />
<br />
=== network files ===<br />
<br />
These files are aimed at setting network configuration variables, especially for servers and containers.<br />
<br />
Below is a basic structure of a ''MyProfile''.network file:<br />
<br />
{{hc|/etc/systemd/network/''MyProfile''.network|<br />
[Match]<br />
''a vertical list of keys''<br />
<br />
[Network]<br />
''a vertical list of keys''<br />
<br />
[Address]<br />
''a vertical list of keys''<br />
<br />
[Route]<br />
''a vertical list of keys''<br />
}}<br />
<br />
==== [Match] section ====<br />
<br />
Most common keys are:<br />
<br />
* {{ic|1=Name=}} the device name (e.g Br0, enp4s0)<br />
* {{ic|1=Host=}} the machine hostname<br />
* {{ic|1=Virtualization=}} check whether the system is executed in a virtualized environment or not. A {{ic|1=Virtualization=no}} key will only apply on your host machine, while {{ic|1=Virtualization=yes}} apply to any container or VM.<br />
<br />
==== [Network] section ====<br />
<br />
Most common keys are:<br />
<br />
* {{ic|1=DHCP=}} enables [[Wikipedia:Dynamic Host Configuration Protocol|DHCPv4]] and/or DHCPv6 support. Accepts {{ic|yes}}, {{ic|no}}, {{ic|ipv4}} or {{ic|ipv6}}<br />
* {{ic|1=DNS=}} is a [[Wikipedia:Domain Name System|DNS]] server address. You can specify this option more than once<br />
* {{ic|1=Bridge=}} is the name of the bridge to add the link to<br />
<br />
==== [Address] section ====<br />
Most common key in the {{ic|[Address]}} section is:<br />
<br />
* {{ic|1=Address=}} is a static '''IPv4''' or '''IPv6''' address and its prefix length, separated by a {{ic|/}} character (e.g {{ic|192.168.1.90/24}}). This option is '''mandatory''' unless DHCP is used.<br />
<br />
==== [Route] section ====<br />
Most common key in the {{ic|[Route]}} section is:<br />
<br />
* {{ic|1=Gateway=}} is the address of your machine gateway. This option is '''mandatory''' unless DHCP is used.<br />
For an exhaustive key list, please refer to {{ic|systemd.network(5)}}<br />
<br />
{{Tip|you can put the {{ic|1=Address=}} and {{ic|1=Gateway=}} keys in the {{ic|[Network]}} section as a short-hand if {{ic|1=Address=}} contains only an Address key and {{ic|1=Gateway=}} section contains only a Gateway key<br />
}}<br />
<br />
=== netdev files ===<br />
<br />
These files will create virtual network devices.<br />
<br />
Below is a basic structure of a ''Mydevice''.netdev file:<br />
<br />
{{hc|/etc/systemd/network/''MyDevice''.netdev|<br />
[Match]<br />
''a vertical list of keys''<br />
<br />
[Netdev]<br />
''a vertical list of keys''<br />
}}<br />
<br />
==== [Match] section ====<br />
<br />
Most common keys are {{ic|1=Host=}} and {{ic|1=Virtualization=}}<br />
<br />
==== [Netdev] section ====<br />
<br />
Most common keys are:<br />
<br />
* {{ic|1=Name=}} is the interface name used when creating the netdev. This option is '''compulsory'''<br />
* {{ic|1=Kind=}} is the netdev kind. Currently, ''bridge'', ''bond'', ''vlan'' and ''macvlan'' are supported. This option is '''compulsory'''<br />
<br />
For an exhaustive key list, please refer to {{ic|systemd.netdev(5)}}<br />
<br />
=== link files ===<br />
<br />
These files are an alternative to custom udev rules and will be applied by [[udev]] as the device appears.<br />
<br />
Below is a basic structure of a ''Mydevice''.link file:<br />
<br />
{{hc|/etc/systemd/network/''MyDevice''.link|<br />
[Match]<br />
''a vertical list of keys''<br />
<br />
[Link]<br />
''a vertical list of keys''<br />
}}<br />
<br />
The {{ic|[Match]}} section will determine if a given link file may be applied to a given device, when the {{ic|[Link]}} section specifies the device configuration.<br />
<br />
==== [Match] section ====<br />
<br />
Most common keys are {{ic|1=MACAddress=}}, {{ic|1=Host=}} and {{ic|1=Virtualization=}}.<br />
<br />
{{ic|1=Type=}} is the device type (e.g. vlan)<br />
<br />
==== [Link] section ====<br />
<br />
Most common keys are:<br />
<br />
{{ic|1=MACAddressPolicy=}} is either ''persistent'' when the hardware has a persistent MAC address (as most hardware should) or ''random'' , which allows to give a random MAC address when the device appears.<br />
<br />
{{ic|1=MACAddress=}} shall be used when no {{ic|1=MACAddressPolicy=}} is specified.<br />
<br />
{{Note|the system {{ic|/usr/lib/systemd/network/99-default.link}} is generally sufficient for most of the basic cases.}}<br />
<br />
== Usage with containers ==<br />
<br />
The service is available with {{Pkg|systemd}} >= 210. You will want to [[systemd#Basic systemctl usage|enable and start]] the {{ic|systemd-networkd.service}} on the host and container.<br />
<br />
For debugging purposes, it is strongly advised to [[pacman|install]] the {{Pkg|bridge-utils}}, {{Pkg|net-tools}} and {{Pkg|iproute2}} packages.<br />
<br />
If you are using ''systemd-nspawn'', you may need to modify the {{ic|systemd-nspawn@.service}} and append boot options to the {{ic|ExecStart}} line. Please refer to {{ic|man 1 systemd-nspawn}} for an exhaustive list of options.<br />
<br />
Note that if you want to take advantage of automatic DNS configuration from DHCP, you need to enable {{ic|systemd-resolved}} and symlink {{ic|/run/systemd/resolve/resolv.conf}} to {{ic|/etc/resolv.conf}}. See {{ic|systemd-resolved.service(8)}} for more details.<br />
<br />
{{Tip|Before you start to configure your container network, it is useful to:<br />
* disable all your [[netctl]] services. This will avoid any potential conflicts with '''systemd-networkd''' and make all your configurations easier to test. Furthermore, odds are high you will end with few or even no [[netctl]] activated profiles. The {{ic|netctl list}} command will output a list of all your profiles, with the activated one being starred.<br />
* disable the {{ic|systemd-nspawn@.service}} and use the {{ic|systemd-nspawn -bD /path_to/your_container/}} command as root to boot the container. To log off and shutdown inside the container {{ic|systemctl poweroff}} is used as root. Once the network setting meets your requirements, [[systemd#Basic systemctl usage|enable and start]] {{ic|systemd-nspawn@.service}}<br />
* disable the {{ic|dhcpcd.service}} if enabled on your system, since it activates ''dhcpcd'' on '''all''' interfaces<br />
* make sure you have no [[netctl]] profiles activated in the container, and ensure that {{ic|systemd-networkd.service}} is neither enabled nor started<br />
* make sure you do not have any [[iptables]] rules which can block traffic<br />
* make sure ''packet forwarding'' is [[Internet sharing|enabled]] if you plan to set up a ''private network'' on your container<br />
* after any configuration files, reload the networkd daemon when running {{ic|systemctl restart systemd-networkd}} as root <br />
* when the daemon is started the systemd {{ic|networkctl}} command displays the status of network interfaces.<br />
}}<br />
<br />
{{Note|For the set-up described below, <br />
* we will limit the output of the {{ic|ip a}} command to the concerned interfaces<br />
* we assume the ''host'' is your main OS you are booting to and the ''container'' is your guest virtual machine<br />
* all interface names and IP addresses are only examples<br />
}}<br />
<br />
=== Basic DHCP network ===<br />
<br />
This set up will enable a DHCP IP for host and container. In this case, both systems will share the same IP as they share the same interfaces.<br />
<br />
{{hc|/etc/systemd/network/''MyDhcp''.network|<nowiki><br />
[Match]<br />
Name=en*<br />
<br />
[Network]<br />
DHCP=ipv4<br />
</nowiki>}}<br />
<br />
Then, [[enable]] and start {{ic|systemd-networkd.service}} on your container.<br />
<br />
You can of course replace {{ic|en*}} by the full name of your ethernet device given by the output of the {{ic|ip link}} command.<br />
<br />
* on host and container:<br />
<br />
{{hc|$ ip a|<br />
2: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000<br />
link/ether 14:da:e9:b5:7a:88 brd ff:ff:ff:ff:ff:ff<br />
inet 192.168.1.72/24 brd 192.168.1.255 scope global enp7s0<br />
valid_lft forever preferred_lft forever<br />
inet6 fe80::16da:e9ff:feb5:7a88/64 scope link <br />
valid_lft forever preferred_lft forever<br />
}}<br />
<br />
By default hostname received from the DHCP server will be used as the transient hostname.<br />
<br />
To change it add {{ic|1=UseHostname=false}} in section {{ic|[DHCPv4]}}<br />
{{hc|/etc/systemd/network/''MyDhcp''.network|<nowiki><br />
[DHCPv4]<br />
UseHostname=false<br />
</nowiki>}}<br />
<br />
If you did not want configure a DNS in {{ic|/etc/resolv.conf}} and want to rely on DHCP for setting it up, you need to enable {{ic|systemd-resolved}} and symlink {{ic|/run/systemd/resolve/resolv.conf}} to {{ic|/etc/resolv.conf}}. See {{ic|systemd-resolved.service(8)}} for more details.<br />
<br />
$ systemctl enable systemd-resolved<br />
$ ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf<br />
<br />
=== DHCP with two distinct IP ===<br />
<br />
==== Bridge interface ====<br />
<br />
Create a virtual bridge interface <br />
<br />
{{hc|/etc/systemd/network/''MyBridge''.netdev|<nowiki><br />
[NetDev]<br />
Name=br0<br />
Kind=bridge<br />
</nowiki>}}<br />
<br />
* on host and container:<br />
<br />
{{hc|$ ip a|<br />
3: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default <br />
link/ether ae:bd:35:ea:0c:c9 brd ff:ff:ff:ff:ff:ff<br />
}}<br />
<br />
Note that the interface br0 is listed but is DOWN.<br />
<br />
==== Bind ethernet to bridge ====<br />
<br />
Modify the {{ic|/etc/systemd/network/''MyDhcp''.network}} to remove the DHCP, as the bridge requires an interface to bind to with no IP, and add a key to bind this device to br0. Let us change its name to a more relevant one.<br />
<br />
{{hc|/etc/systemd/network/''MyEth''.network|<nowiki><br />
[Match]<br />
Name=en*<br />
<br />
[Network]<br />
Bridge=br0<br />
</nowiki>}}<br />
<br />
==== Bridge network ====<br />
<br />
Create a network profile for the Bridge<br />
<br />
{{hc|/etc/systemd/network/''MyBridge''.network|<nowiki><br />
[Match]<br />
Name=br0<br />
<br />
[Network]<br />
DHCP=ipv4<br />
</nowiki>}}<br />
<br />
==== Add option to boot the container ====<br />
<br />
As we want to give a separate IP for host and container, we need to ''Disconnect'' networking of the container from the host. To do this, add this option {{ic|1=--network-bridge=br0}} to your container boot command.<br />
<br />
# systemd-nspawn --network-bridge&#61;br0 -bD /path_to/my_container<br />
<br />
==== Result ====<br />
<br />
* on host<br />
<br />
{{hc|$ ip a|<br />
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default <br />
link/ether 14:da:e9:b5:7a:88 brd ff:ff:ff:ff:ff:ff<br />
inet 192.168.1.87/24 brd 192.168.1.255 scope global br0<br />
valid_lft forever preferred_lft forever<br />
inet6 fe80::16da:e9ff:feb5:7a88/64 scope link <br />
valid_lft forever preferred_lft forever<br />
6: vb-''MyContainer'': <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000<br />
link/ether d2:7c:97:97:37:25 brd ff:ff:ff:ff:ff:ff<br />
inet6 fe80::d07c:97ff:fe97:3725/64 scope link <br />
valid_lft forever preferred_lft forever<br />
}}<br />
<br />
* on container<br />
<br />
{{hc|$ ip a|<br />
2: host0: <BROADCAST,MULTICAST,ALLMULTI,AUTOMEDIA,NOTRAILERS,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000<br />
link/ether 5e:96:85:83:a8:5d brd ff:ff:ff:ff:ff:ff<br />
inet 192.168.1.73/24 brd 192.168.1.255 scope global host0<br />
valid_lft forever preferred_lft forever<br />
inet6 fe80::5c96:85ff:fe83:a85d/64 scope link <br />
valid_lft forever preferred_lft forever<br />
}}<br />
<br />
==== Notice ====<br />
<br />
* we have now one IP address for Br0 on the host, and one for host0 in the container<br />
* two new interfaces have appeared: {{ic|vb-''MyContainer''}} in the host and {{ic|host0}} in the container. This comes as a result of the {{ic|1=--network-bridge=br0}} option. This option ''implies'' another option, {{ic|--network-veth}}. This means a ''virtual Ethernet link'' has been created between host and container.<br />
* the DHCP address on {{ic|host0}} comes from the system {{ic|/usr/lib/systemd/network/80-container-host0.network}} file.<br />
* on host<br />
<br />
{{hc|$ brctl show|<br />
bridge name bridge id STP enabled interfaces<br />
br0 8000.14dae9b57a88 no enp7s0<br />
vb-''MyContainer''<br />
}}<br />
<br />
the above command output confirms we have a bridge with two interfaces binded to.<br />
<br />
* on host<br />
<br />
{{hc|$ ip route|<br />
default via 192.168.1.254 dev br0 <br />
192.168.1.0/24 dev br0 proto kernel scope link src 192.168.1.87<br />
}}<br />
<br />
* on container<br />
<br />
{{hc|$ ip route|<br />
default via 192.168.1.254 dev host0 <br />
192.168.1.0/24 dev host0 proto kernel scope link src 192.168.1.73<br />
}}<br />
<br />
the above command outputs confirm we have activated {{ic|br0}} and {{ic|host0}} interfaces with an IP address and Gateway 192.168.1.254. The gateway address has been automatically grabbed by ''systemd-networkd''<br />
<br />
{{hc|$ cat /run/systemd/resolve/resolv.conf|<br />
nameserver 192.168.1.254<br />
}}<br />
<br />
=== Static IP network ===<br />
<br />
Setting a static IP for each device can be helpful in case of deployed web services (e.g FTP, http, SSH). Each device will keep the same MAC address across reboots if your system {{ic|/usr/lib/systemd/network/99-default.link}} file has the {{ic|1=MACAddressPolicy=persistent}} option (it has by default). Thus, you will easily route any service on your Gateway to the desired device.<br />
First, we shall get rid of the system {{ic|/usr/lib/systemd/network/80-container-host0.network}} file. To do it in a permanent way (e.g even after upgrades), do the following on '''both''' host and container. This will mask the file {{ic|/usr/lib/systemd/network/80-container-host0.network}} since files of the same name in {{ic|/etc/systemd/network}} take priority over {{ic|/usr/lib/systemd/network}}.<br />
<br />
# ln -sf /dev/null /etc/systemd/network/80-container-host0.network<br />
<br />
Then, [[systemd#Basic systemctl usage|enable and start]] {{ic|systemd-networkd}} on your container.<br />
<br />
The needed configuration files:<br />
<br />
* on host <br />
<br />
/etc/systemd/network/''MyBridge''.netdev<br />
/etc/systemd/network/''MyEth''.network<br />
<br />
A modified ''MyBridge''.network<br />
<br />
{{hc|/etc/systemd/network/''MyBridge''.network|<nowiki><br />
[Match]<br />
Name=br0<br />
<br />
[Network]<br />
DNS=192.168.1.254<br />
Address=192.168.1.87/24<br />
Gateway=192.168.1.254<br />
</nowiki>}}<br />
<br />
* on container<br />
<br />
{{hc|/etc/systemd/network/''MyVeth''.network|<nowiki><br />
[Match]<br />
Name=host0<br />
<br />
[Network]<br />
DNS=192.168.1.254<br />
Address=192.168.1.94/24<br />
Gateway=192.168.1.254<br />
</nowiki>}}<br />
<br />
== See also ==<br />
<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html systemd.networkd man page]<br />
* [https://plus.google.com/u/0/+TomGundersen/posts Tom Gundersen, main systemd-networkd developer, G+ home page]<br />
* [https://coreos.com/blog/intro-to-systemd-networkd/ Tom Gundersen posts on Core OS blog]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=REFInd&diff=371632REFInd2015-04-28T09:27:42Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Boot loaders]]<br />
[[ja:REFInd]]<br />
[[ru:REFInd]]<br />
[[zh-CN:REFInd]]<br />
{{Related articles start}}<br />
{{Related|Arch boot process}}<br />
{{Related|Boot loaders}}<br />
{{Related|Unified Extensible Firmware Interface}}<br />
{{Related|EFISTUB}}<br />
{{Related articles end}}<br />
{{Lowercase title}}<br />
rEFInd is a [[UEFI]] boot manager. It is a fork of the no-longer-maintained [http://refit.sourceforge.net/ rEFIt] and fixes many issues with respect to non-Mac UEFI booting. It is designed to be platform-neutral and to simplify booting multiple OSes.<br />
<br />
{{Note|In the entire article {{ic|$esp}} denotes the mountpoint of the [[UEFI#EFI System Partition|EFI System Partition]] aka ESP.}}<br />
<br />
== Installation ==<br />
<br />
[[Install]] {{pkg|refind-efi}} from the [[Official repositories]].<br />
<br />
=== Scripted configuration ===<br />
<br />
rEFInd package includes the {{ic|/usr/bin/refind-install}} script to simplify the process of setting rEFInd as your default EFI boot entry. The script has several options for handling differing setups and UEFI implementations, but for many systems it should be sufficient to simply run<br />
<br />
# refind-install<br />
<br />
This will attempt to find and mount your [[UEFI#EFI System Partition|ESP]], copy rEFInd's files to {{ic|/EFI/refind/}} on the ESP, and add rEFInd as the default EFI boot entry using [[UEFI#efibootmgr]].<br />
<br />
{{Note|By default {{ic|refind-install}} installs only the driver for your root file system, if you want addition drivers see [[#File system drivers]].}}<br />
<br />
You can also install rEFInd to the default/fallback boot path {{ic|/EFI/BOOT/BOOT*.EFI}}. This is helpful for bootable USB flash drives or on systems that have issues with the NVRAM changes made by efibootmgr:<br />
<br />
# refind-install --usedefault '''/dev/sdXY'''<br />
<br />
Where '''/dev/sdXY''' is the partition of your ESP.<br />
Read the comments in the install script for an explanation of each option.<br />
<br />
After installing rEFInd's files to the ESP, verify that rEFInd has created {{ic|refind_linux.conf}} containing the required [[kernel parameters]] (e.g. {{ic|1=root=}}) in the same directory as your kernel. If it has not created this file, you will need to set up [[#Passing kernel parameters]] manually or you will most likely get a kernel panic on your next boot.<br />
<br />
By default, rEFInd will scan all of your drives (that it has drivers for) and add a boot entry for each EFI bootloader it finds, which should include your kernel (since Arch enables [[EFISTUB]] by default). So you may have a bootable system at this point.<br />
<br />
{{Tip|It is always a good idea to edit the default config {{ic|/EFI/refind/refind.conf}} on the ESP to ensure that the default options work for you.}}<br />
<br />
=== Manual configuration ===<br />
<br />
{{Tip|rEFInd can boot Linux in many ways. See [http://www.rodsbooks.com/refind/linux.html The rEFInd Boot Manager: Methods of Booting Linux] for coverage of the various approaches.}}<br />
{{Note|For 32-bit EFI, replace '''x64''' with '''ia32''' in the commands below.}}<br />
<br />
If the {{ic|refind-install}} script does not work for you, rEFInd can be set up manually.<br />
<br />
First, copy the executable to the ESP:<br />
<br />
# cp /usr/share/refind/refind_x64.efi $esp/EFI/refind/<br />
<br />
Then use [[UEFI#efibootmgr]] to create a boot entry in the UEFI NVRAM (change X and Y to match the device and partition of your ESP). If you are installing rEFInd to the default UEFI path {{ic|/EFI/BOOT/BOOTX64.EFI}}, you can probably skip this step.<br />
<br />
# efibootmgr -c -d /dev/sdX -p Y -l /EFI/refind/refind_x64.efi -L "rEFInd Boot Manager"<br />
<br />
At this point, you should be able to reboot into rEFInd but it will not be able to boot your kernel. If your kernel does not reside on your ESP, rEFInd can mount your partitions to find it - provided it has the right drivers:<br />
<br />
# mkdir $esp/EFI/refind/drivers<br />
# cp /usr/share/refind/drivers_x64/myrootfs_x64.efi $esp/EFI/refind/drivers<br />
<br />
Now rEFInd should have a boot entry for your kernel, but it will not pass the correct kernel parameters. Set up [[#Passing kernel parameters]]. You should now be able to boot your kernel using rEFInd. If you are still unable to boot or if you want to tweak rEFInd's settings, many options can be changed with a config file:<br />
<br />
# cp /usr/share/refind/refind.conf-sample $esp/EFI/refind/refind.conf<br />
<br />
The sample config is well commented and self-explanatory.<br />
<br />
Unless you have set {{ic|textonly}} in the config file, you should copy rEFInd's icons to get rid of the ugly placeholders:<br />
<br />
# cp -r /usr/share/refind/icons $esp/EFI/refind/<br />
<br />
You can try out different fonts by copying them and changing the {{ic|font}} setting in {{ic|refind.conf}}:<br />
<br />
# cp -r /usr/share/refind/fonts $esp/EFI/refind/<br />
<br />
{{Tip|Pressing F10 in rEFInd will save a screenshot to the top level directory of the ESP.}}<br />
<br />
=== File system drivers ===<br />
<br />
{{Note|rEFInd does not require ESP to be mounted in a specific place, but if it does not mount it at {{ic|/boot}} you will need to use file sytem drivers.}}<br />
<br />
==== Supported drivers ====<br />
<br />
rEFInd currently has '''read-only''' drivers for these file systems:<br />
* ReiserFS<br />
* Ext2<br />
* [[Ext4]]<br />
* [[Btrfs]]<br />
* ISO-9660<br />
* HFS+<br />
* [[NTFS]]<br />
{{Tip|To find additional drivers see [http://www.rodsbooks.com/refind/drivers.html#finding The rEFInd Boot Manager: Using EFI Drivers: Finding Additional EFI Drivers].}}<br />
<br />
==== Using drivers in rEFInd ====<br />
<br />
rEFInd will automatically load all drivers from subdirectories {{ic|drivers}} and {{ic|<nowiki>drivers_{arch}</nowiki>}} in its install directory.<br />
To allow rEFInd to use a driver, copy it to {{ic|$esp/EFI/refind/drivers_x64/}}.<br />
<br />
# cp /usr/share/refind/drivers_x64/'''drivername'''_x64.efi $esp/EFI/refind/drivers_x64/<br />
<br />
{{Tip| If installing to a bootable USB flash drive use {{ic|--alldrivers}} option of {{ic|refind-install}} to install all drivers.<br />
# refind-install --usedefault /dev/sdXY --alldrivers<br />
}}<br />
<br />
==== Using drivers in UEFI shell ====<br />
<br />
To use rEFInd's drivers in UEFI shell load them using command {{ic|load}} and refresh mapped drives with {{ic|map -r}}.<br />
<br />
# load FS0:\EFI\refind\drivers\ext4_x64.efi<br />
# map -r<br />
<br />
Now you can access your file system from UEFI shell.<br />
<br />
== Passing kernel parameters ==<br />
<br />
There are two methods for setting the [[kernel parameters]] that rEFInd will pass to the kernel.<br />
<br />
=== For kernels automatically detected by rEFInd ===<br />
<br />
If rEFInd automatically detects your kernel, you can place a {{ic|refind_linux.conf}} file containing the kernel parameters in the same directory as your kernel. You can use {{ic|/usr/share/refind/refind_linux.conf-sample}} as a starting point. The first uncommented line of {{ic|refind_linux.conf}} will be the default parameters for the kernel. Subsequent lines will create entries in a submenu accessible using {{ic|+}}, {{ic|F2}}, or {{ic|Insert}}.<br />
<br />
Alternatively, try running:<br />
<br />
# refind-mkrlconf<br />
<br />
Which will attempt to find your kernel in {{ic|/boot}} and automatically generate {{ic|refind_linux.conf}}. The script will only set up the most basic kernel parameters, so be sure to check the file it created for correctness.<br />
<br />
If you do not specify an {{ic|1=initrd=}} parameter, rEFInd will automatically add it by searching for common RAM disk filenames in the same directory as the kernel. If you need multiple {{ic|1=initrd=}} parameters (e.g. for [[Microcode]]) you must specify them manually in {{ic|refind_linux.conf}}.<br />
<br />
=== Manual boot stanzas ===<br />
<br />
If your kernel is not autodetected, or if you simply want more control over the options for a menu entry, you can manually create boot entries using stanzas in {{ic|refind.conf}}. Ensure that {{ic|scanfor}} includes {{ic|manual}} or these entries will not appear in rEFInd's menu. Kernel parameters are set with the {{ic|options}} keyword. rEFInd will append the {{ic|1=initrd=}} parameter using the file specified by the {{ic|initrd}} keyword in the stanza. If you need additional initrds (e.g. for [[Microcode]]), you can specify them in {{ic|options}} (and the one specified by the {{ic|initrd}} keyword will be added to the end).<br />
<br />
{{hc|$esp/EFI/refind/refind.conf|<nowiki><br />
...<br />
<br />
menuentry "Arch Linux" {<br />
icon /EFI/refind/icons/os_arch.png<br />
volume Boot<br />
loader /boot/vmlinuz-linux<br />
initrd /boot/initramfs-linux.img<br />
options "root=PARTUUID=XXXXXXXX rootfstype=XXXX rw add_efi_memmap"<br />
submenuentry "Boot using fallback initramfs" {<br />
initrd /boot/initramfs-linux-fallback.img<br />
}<br />
}<br />
</nowiki>}}<br />
<br />
It is likely that you will need to change {{ic|volume}} to match either a filesystem's LABEL, a PARTLABEL, a PARTUUID, or a volume number (e.g. {{ic|0:}}) of the partition where the kernel image resides. See [[Ext3#Assigning a label]] as an example of assigning a volume label.<br />
<br />
== Using rEFInd with an existing UEFI Windows installation ==<br />
<br />
{{Note|The usual caveats of [[Windows and Arch dual boot]] apply.}}<br />
<br />
rEFInd is compatible with the EFI system partition created by a UEFI Windows installation, so there is no need to create or format another FAT32 partition when installing Arch alongside Windows. Simply mount Windows' ESP and install rEFInd as usual. By default, rEFInd's autodetection feature should recognize any existing Windows/recovery bootloaders.<br />
<br />
== Upgrading rEFInd ==<br />
<br />
Pacman updates the rEFInd files in {{ic|/usr/share/refind}} and will not copy new files to the ESP for you. If {{ic|refind-install}} worked for your original installation of rEFInd, you can rerun it to copy the updated files. The new config file will be copied as {{ic|refind.conf-sample}} so that you can integrate changes into your config file using a diff tool. If your rEFInd required [[#Manual configuration]], you will need to copy the new files yourself.<br />
<br />
=== Systemd automation ===<br />
<br />
To automate this process, you need a .path file for watching for rEFInd updates and a .service file for copying the new files and updating the nvram.<br />
<br />
{{hc|/etc/systemd/system/refind_update.path|<nowiki><br />
[Unit]<br />
Description=path monitor for rEFInd updates<br />
<br />
[Path]<br />
PathChanged=/usr/share/refind<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
{{hc|/etc/systemd/system/refind_update.service|<nowiki><br />
[Unit]<br />
Description=rEFInd boot manager update<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/refind-install<br />
</nowiki>}}<br />
<br />
Then [[enable]] {{ic|refind_update.path}}.<br />
<br />
== Apple Macs ==<br />
<br />
{{AUR|mactel-boot}} from the [[AUR]] is an experimental "bless" utility for Linux. If that does not work, use "bless" from within OSX to set rEFInd as the default boot entry. Assuming your UEFISYS partition is mounted at {{ic|/mnt/efi}} within OSX, do:<br />
<br />
# bless --setBoot --folder /mnt/efi/EFI/refind --file /mnt/efi/EFI/refind/refind_x64.efi<br />
<br />
== VirtualBox ==<br />
<br />
Currently, VirtualBox will only boot the default {{ic|/EFI/BOOT/BOOT*.EFI}} path, so {{ic|refind-install}} needs to be used with at least the {{ic|--usedefault}} option. See [[VirtualBox#Installation in EFI mode]] for more information.<br />
<br />
== Tools ==<br />
<br />
rEFInd supports running various 3rd-party tools. Tools need to be installed separately. Edit {{ic|showtools}} in {{ic|refind.conf}} to choose which ones to show.<br />
{{hc|$esp/EFI/refind/refind.conf|<br />
...<br />
# Which non-bootloader tools to show on the tools line, and in what<br />
# order to display them:<br />
# shell - the EFI shell (requires external program; see rEFInd<br />
# documentation for details)<br />
# memtest - the memtest86 program, in EFI/tools, EFI/memtest86,<br />
# EFI/memtest, EFI/tools/memtest86, or EFI/tools/memtest<br />
# gptsync - the (dangerous) gptsync.efi utility (requires external<br />
# program; see rEFInd documentation for details)<br />
# gdisk - the gdisk partitioning program<br />
# apple_recovery - boots the Apple Recovery HD partition, if present<br />
# windows_recovery - boots an OEM Windows recovery tool, if present<br />
# (see also the windows_recovery_files option)<br />
# mok_tool - makes available the Machine Owner Key (MOK) maintenance<br />
# tool, MokManager.efi, used on Secure Boot systems<br />
# about - an "about this program" option<br />
# exit - a tag to exit from rEFInd<br />
# shutdown - shuts down the computer (a bug causes this to reboot<br />
# many UEFI systems)<br />
# reboot - a tag to reboot the computer<br />
# firmware - a tag to reboot the computer into the firmware's<br />
# user interface (ignored on older computers)<br />
# netboot - launch the ipxe.efi tool for network (PXE) booting<br />
# Default is shell,memtest,gdisk,apple_recovery,windows_recovery,mok_tool,about,shutdown,reboot,firmware<br />
#<br />
'''showtools''' '''shell''', '''memtest''', '''netboot''', about, reboot, firmware<br />
...<br />
}}<br />
<br />
=== UEFI shell ===<br />
See [[Unified_Extensible_Firmware_Interface#UEFI_Shell|UEFI shell]].<br />
<br />
Copy {{ic|shellx64.efi}} to the root of [[Unified_Extensible_Firmware_Interface#EFI_System_Partition|EFI System Partition]]<br />
<br />
=== Memtest86 ===<br />
Install {{AUR|memtest86-efi}} from [[AUR]] and copy it to {{ic|$esp/EFI/tools/}}.<br />
# cp /usr/share/memtest86-efi/bootx64.efi $esp/EFI/tools/memtest86.efi<br />
<br />
=== iPXE ===<br />
{{Note|PXE support in rEFInd is '''experimental'''.}}<br />
{{pkg|refind-efi}} contains the iPXE UEFI binaries, you just need to copy them to {{ic|$esp/EFI/tools/}}.<br />
# cp /usr/share/refind/tools_x64/ipxe_discovery_x64.efi $esp/EFI/tools/ipxe_discovery.efi<br />
# cp /usr/share/refind/tools_x64/ipxe_x64.efi $esp/EFI/tools/ipxe.efi<br />
<br />
== See also ==<br />
<br />
* [http://www.rodsbooks.com/refind/ The rEFInd Boot Manager] by Roderick W. Smith.<br />
* {{ic|/usr/share/refind/docs/README.txt}}</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Quassel&diff=371630Quassel2015-04-28T09:24:47Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Internet Relay Chat]]<br />
Quassel (sometimes referred to as Quassel IRC) is a cross-platform IRC client introduced in 2008. It is dual-licensed under GPLv2 and GPLv3, while most graphical data is licensed under the LGPL and provided by the [http://www.oxygen-icons.org/ Oxygen Team]. The client part of Quassel uses the Qt framework for its user interface.<br />
<br />
== Structure ==<br />
<br />
Quassel is split up into two parts by a server-client model; a client and a core. There is also a monolithic version of the official client that does not require a core. The core(server) is the application that actually does the communication with IRC networks, while the client(s) only communicates with the core. This gives the user a flexibility of having the same instance to IRC networks on different clients (e.g. mobile, desktop at the same time).<br />
<br />
{{Note|Arch Linux used to have two packages, where quassel-monolighic was part of quassel-client, this was fixed in {{Bug|39756}} but if you used to run the monolithic version, you might run into problems after the update. You could try by just installing quassel-monolithic or if that does not help see troubleshooting below.}}<br />
<br />
== Installation ==<br />
<br />
=== Basic usage ===<br />
<br />
Just install the {{Pkg|quassel-monolithic}} package if you only want to use Quassel from a single computer.<br />
<br />
=== Setting up multiple clients to connect through the same core ===<br />
<br />
Install {{Pkg|quassel-core}} and {{Pkg|quassel-client}}.<br />
<br />
Generate a certificate (this will be valid for 4 years, after which it needs to be reissued, just change the -days to another value if you so desire):<br />
{{bc|# openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /var/lib/quassel/quasselCert.pem -out /var/lib/quassel/quasselCert.pem}}<br />
As this is a self-signed certificate, you can type whatever you want in the fields.<br />
<br />
Open port 4242 in your firewall.<br />
<br />
Start core:<br />
{{bc|# systemctl start quassel}}<br />
<br />
Start the client and connect to core:<br />
{{bc|$ quasselclient}}<br />
<br />
Accept your self-created certificate.<br />
<br />
Now set up your IRC-servers and IRC-nicknames on the core.<br />
<br />
{{Note|As this is the first time you connected to the core, you should see a wizard where you can set up the first user-account. If you do not get this wizard, your settings might be messed up, see troubleshooting below.}}<br />
<br />
Once it all works, you can set it up to start automatically through on system boot:<br />
<br />
{{bc|# systemctl enable quassel}}<br />
<br />
This is supposed to work but does not because of a bug {{Bug|38950}} but it is easy to work around:<br />
<br />
Copy the system service file to make a override in /etc/systemd/system/ (then when the bug is fixed you can just remove this file)<br />
{{bc|# cp /usr/lib/systemd/system/quassel.service /etc/systemd/system/}}<br />
<br />
Then edit the file /etc/systemd/system/quassel.service and remove --listen=${LISTEN} from ExecStart.<br />
<br />
== Troubleshooting ==<br />
<br />
If you were previously using quassel-monolithic, your settings might be messed up.<br />
Close quasselcore.<br />
Move your settings database to a backup copy:<br />
{{bc|$ mv /~/.config/quassel-irc.org/quassel-storage.sqlite /~/.config/quassel-irc.org/quassel-storage.sqlite.bak}}<br />
<br />
Then start quasselcore again and connect from your client, you should now get the wizard to show, however, all settings will have to be re-entered.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=H2status&diff=371628H2status2015-04-28T09:23:28Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Tiling WMs]]<br />
[[Category:Dynamic WMs]]<br />
{{AUR|h2status}} is a trivial (about 60 LOC) bash wrapper to i3status that nevertheless allows<br />
to conveniently:<br />
<br />
* Write custom modules in bash to add full-fledged json entries to the status bar.<br />
* Write mouse event handlers in bash with access to the full set of event parameters as bash variables.<br />
* Arbitrarily transform the final output to change formatting, order of entries, etc.<br />
* Compute and cache expensive status entries asynchronously, updating them only at desired frequencies.<br />
<br />
Besides reading the documentation below it is recommended that you take a look at the code in [https://gist.github.com/memeplex/8115385] as it can be more eloquent than the following wording.<br />
<br />
== Configuration ==<br />
<br />
The configuration is done in ~/.h2statusrc by (optionally) defining the following bash functions:<br />
<br />
1. {{ic|status() -> json}}<br />
<br />
This outputs the status entries to be concatenated to the beginning of the original i3status output. As a convenience for outputting json status entries, the function {{ic|entry(module,text[,other])}} is provided. For example:<br />
<br />
function status {<br />
...<br />
entry random $RANDOM '"color":"$00FF00"'<br />
...<br />
}<br />
<br />
2. {{ic|on_event()}}<br />
<br />
This handles mouse events. The execution environment of this function is augmented with the variables {{ic|name, instance, button, x, y}} described at the end of [http://i3wm.org/docs/i3bar-protocol.html].<br />
<br />
3. {{ic|transform(json) -> json}}<br />
<br />
This is intended for simple sed style hackish manipulations that change order and format of the final json line to be consumed by i3bar. Use it as a last resort.<br />
<br />
An example configuration is provided in /usr/share/h2status/h2statusrc (you can also browse it online at [https://gist.github.com/memeplex/8115385]). Use this as a template to write your own stuff.<br />
<br />
== Store ==<br />
<br />
h2status allows for module status storage and retrieval in a concurrent-safe way through the file system. The purpose of this is two-folded:<br />
<br />
* To implement a basic IPC mechanism that supports communication with external scripts that need to update the status.<br />
* To implement a basic cache mechanism that supports asynchronous status updating.<br />
<br />
The interface to the store consists of three functions:<br />
<br />
1. {{ic|write_status(module,value)}}<br />
<br />
2. {{ic|read_status(module) -> value}}<br />
<br />
3. {{ic|cached_status(module,interval,command) -> value}}<br />
<br />
The first two are self-explanatory but the third one requires some motivation and explanation. i3status implements a simple model of status updating: each time an update event happens (every n seconds or after receiving an USR1 signal) the entire status line is recomputed. This is fine for fast/cheap status computations but makes it difficult to integrate relatively long/expensive computations that could delay the update for a perceptible amount of time or overload the cpu when frequently called. To support this kind of status computations while keeping i3status as h2status workhorse, {{ic|cached_status()}} implements a basic cache mechanism that allows to asynchronously update status values. For example, if you want to check the folders "inbox" and "work" in your IMAP account every 60 seconds you could add this line to {{ic|status()}}:<br />
<br />
function status {<br />
...<br />
entry mail "Mail: $(cached_status mail 60 'checkmail inbox work')"<br />
...<br />
}<br />
<br />
Here {{ic|mail}} is the module name, {{ic|60}} is the update interval and {{ic|checkmail inbox work}} is the command implementing the update logic which would be evaluated in background every 60 seconds (this is not exactly true, as the cache is only read/updated at points in time when i3status itself gets updated, according to the interval setting in i3status configuration).<br />
<br />
Then, if you wanted to force an update by clicking on the mail status entry, you could also implement an event handler like this one:<br />
<br />
function on_event {<br />
case $name in<br />
...<br />
mail) <nowiki>[[</nowiki> $button == 1 ]] && write_status mail "$(checkmail inbox work)" ;;<br />
...<br />
esac<br />
}<br />
<br />
== CLI ==<br />
<br />
Most of the status computing and updating logic is implemented inside 13status and h2status, but sometimes you need an external script to force a status update or to write some specific value to the status store. To support these cases, h2status provides an elementary command line interface consisting of two commands:<br />
<br />
1. {{ic|h2status update}}<br />
<br />
This calls {{ic|update()}}, which immediately updates the status line (similar to, and based upon, {{ic|pkill -USR1 i3status}}).<br />
<br />
2. {{ic|h2status write <module> <value>}}<br />
<br />
This calls {{ic|write_status()}} passing {{ic|<module>}} and {{ic|<value>}} as arguments. After writing the new value to the store the status line is updated, but this is just what {{ic|write_status()}} always does.<br />
<br />
Of course, both {{ic|update()}} and {{ic|write_status()}} can also be directly called as functions from inside h2status. The usual use case is to invoke these functions when reacting to click events in {{ic|on_event()}}.<br />
<br />
== Examples ==<br />
<br />
=== Check gmail folders ===<br />
<br />
This will check gmail folders {{ic|MAIL_INBOXES}} for unread messages every {{ic|MAIL_INTERVAL}} seconds using the external script {{ic|checkmail}}. A version of this script that works with firefox cookies database is given here [https://gist.github.com/memeplex/8117142].<br />
<br />
MAIL_INTERVAL=60<br />
MAIL_INBOXES=("" livra jampp)<br />
function status {<br />
local unread_list=$(cached_status mail $MAIL_INTERVAL 'checkmail "${MAIL_INBOXES[@]}"')<br />
local -i total_unread=$((${unread_list// /+}))<br />
((total_unread)) && entry mail "Mail: $unread_list" '"color":"$00FF00"'<br />
}<br />
<br />
=== Switch keyboard layout ===<br />
<br />
The following makes for a nice solution to keyboard layout switching between multiple languages. Left-button clicking on the keyboard status entry switches to the default (first) layout. Right-button clicking iterates over all configured layouts. The layouts are configured in ~/.xinitrc using setxkbmap, v.g. {{ic|setxkbmap "us,es,fr"}}. You must install {{AUR|xkblayout-state}} from the AUR.<br />
<br />
function status {<br />
entry lang $(xkblayout-state print "%s")<br />
}<br />
<br />
function on_event {<br />
case $name in<br />
lang) <nowiki>[[ $button == 1 ]]</nowiki> && xkblayout-state set 0 || xkblayout-state set +1; update ;;<br />
esac<br />
}<br />
<br />
=== Application launchers ===<br />
<br />
Just:<br />
<br />
* Add a status entry consisting only of an iconic font glyph (read this [https://wiki.archlinux.org/index.php/I3#Iconic_fonts_in_the_status_bar] if you do not know what I'm talking about), and<br />
* Add a handler to {{ic|on_event()}} in order to launch the application when the icon is clicked upon. Remember to launch it in background to avoid blocking the event cycle.<br />
<br />
=== Dynamic icons ===<br />
<br />
You can show different iconic font glyphs (read this [https://wiki.archlinux.org/index.php/I3#Iconic_fonts_in_the_status_bar] if you do not know what I'm talking about) according to the current status of some modules. For example, different battery icons corresponding to different charge levels or different volume icons corresponding to different volume levels. Just write your own transformation hook and add it to the {{ic|transform()}} function in ~/.h2statusrc.<br />
<br />
== Dependencies ==<br />
<br />
flock (in {{Pkg|util-linux}}) for safe concurrent cache read/write.<br />
<br />
{{Pkg|i3status}} configured with output_format="i3bar".</div>Infinitehhttps://wiki.archlinux.org/index.php?title=NSD&diff=371627NSD2015-04-28T09:22:22Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Domain Name System]]<br />
Nsd is an authoritative DNS resolver.<br />
<br />
==Installation==<br />
<br />
Install {{Pkg|nsd}}:<br />
pacman -S nsd<br />
<br />
==Migration to nsd for bind users==<br />
<br />
Once the package is installed there are useful migration notes for users who currently run bind as their dns server in the file:<br />
<br />
/usr/share/doc/nsd/NSD-FOR-BIND-USERS<br />
<br />
Many users will wish to run nsd as their authoritative dns server concurrently with unbound as the validating, recursive, caching dns server on a single machine. It may be useful to refer to the wiki page for [[unbound]].<br />
<br />
==Initial Setup==<br />
<br />
More often than not nsd will be running concurrently with a recursive, caching dns server such as unbound. Usually dns servers will be listening on port 53 but the two services would conflict if they were listening to the same port. Hence if unbound was the main server answering dns queries on port 53 then it is sensible for added security to select a high private port number for nsd to listen on. Also if the only direct access to nsd will be from queries forwarded from unbound, then nsd can be configured to listen only to the localhost machine on the private port chosen, and is not then directly accessible from outside. This gives added security to the authoritative server. In the examples of configuration files here port 53530 is chosen as the listening port number for nsd.<br />
<br />
If any firewall running on the machine blocks private port 53530 then this adds to security. The only port that then needs to be open for dns queries coming from external machines (or other machines on the same local network) is port 53.<br />
<br />
It is perfectly possible to put the nsd.conf file as well as any zone files into /etc/nsd/ but it is also possible to place the zone files in a separate directory. So for the purpose of this wiki page assume that the zone files are in /etc/nsd3/ and if you have already been running bind previously then copying the zone files that worked with bind into /etc/nsd3/ should work without adjustment. There are sample configuration files in the web page at https://calomel.org/nsd_dns.html but the example here is for a single master zone only.<br />
<br />
A sample nsd.conf is given here where the forward and reverse zone files are presumed to be in /etc/nsd3/ and named myhomenet.com.zone and 0.0.10.in-addr.arpa.zone '''(Note that in nsd version 4 the sample file has new features enabled, but a pre-existing nsd.conf from version 3 should still work, but it is best to merge changes with the new config file)''':<br />
<br />
## NSD authoritative only DNS<br />
## nsd.conf .:. https://calomel.org<br />
## Primary or "Master" NSD server<br />
#<br />
# The directives "notify" and "provide-xfr" are only needed if you are also going to setup <br />
# a secondary NSD server. Uncomment out these lines to use them.<br />
server:<br />
# uncomment to specify specific interfaces to bind (default all).<br />
ip-address: 127.0.0.1<br />
# port to answer queries on. default is 53.<br />
# port: 53<br />
port: 53530<br />
# Number of NSD servers to fork.<br />
server-count: 1<br />
# listen only on IPv4 connections<br />
ip4-only: yes<br />
# do not answer VERSION.BIND and VERSION.SERVER CHAOS class queries<br />
hide-version: yes<br />
# identify the server (CH TXT ID.SERVER entry).<br />
identity: "Home network authoritative DNS"<br />
# The directory for zonefile: files.<br />
zonesdir: "/etc/nsd3"<br />
key:<br />
name: "sec_key"<br />
algorithm: hmac-md5<br />
secret: "6KM6qiKfwfEpamEq72HQdA=="<br />
zone:<br />
name: myhomenet.com<br />
zonefile: myhomenet.com.zone<br />
# notify: 10.0.0.222@53 sec_key<br />
# provide-xfr: 10.0.0.222 sec_key<br />
zone:<br />
name: 0.0.10.in-addr.arpa<br />
zonefile: 0.0.10.in-addr.arpa.zone<br />
# notify: 10.0.0.222@53 sec_key<br />
# provide-xfr: 10.0.0.222 sec_key<br />
# Logging<br />
#logfile: "/etc/nsd/nsd.log"<br />
# Do not uncomment these lines as logging in nsd is not currently implemented<br />
#<br />
## NSD authoritative only DNS<br />
## nsd.conf .:. https://calomel.org<br />
## Primary or "Master" NSD server<br />
<br />
==Starting and running nsd==<br />
<br />
Before starting up nsd you can check the zone files using the nsd-checkconf command with the zone file name as a parameter.<br />
<br />
In version 3 in order to build the zone database that makes nsd run exceptionally quickly the database file must be rebuilt each time a zone or config file is changed, and the following command is executed as the '''nsd''' user (the daemon runs as ''nsd'' and that user must be able to read {{ic|/var/db/nsd/nsd.db}}):<br />
<br />
nsdc rebuild<br />
<br />
'''However in nsd version 4 nsdc has been removed and a new command nsd-control replaces it. Refer to the doc file at {{ic|/usr/share/doc/nsd/UPGRADING}})'''<br />
<br />
In order to start nsd then type as root:<br />
<br />
systemctl start nsd<br />
<br />
Once nsd has been tested then make nsd start at boot by typing:<br />
<br />
systemctl enable nsd<br />
<br />
If you were already running bind listening on port 53 and are moving over to unbound, then it is important to stop bind before starting unbound to avoid conflicts:<br />
<br />
systemctl stop named<br />
systemctl start unbound<br />
<br />
and to make the correct services start at boot:<br />
systemctl disable named<br />
systemctl enable unbound<br />
<br />
==Testing nsd==<br />
<br />
nsd can be run concurrently with bind during the testing phase. You can check forward and reverse local lookups on the port at 53530 using:<br />
<br />
drill @127.0.0.1 -p 53530 mylocalmachine1.myhomenet.com<br />
drill @127.0.0.1 -p 53530 -x w.x.y.z<br />
<br />
where w.x.y.z is a local address within the LAN.<br />
<br />
Once this is working then if you are running unbound as the caching recursive server then you can switch the unbound config to forward queries from local machines on the same network to query nsd by using the following structure in unbound.conf (and see [[unbound]]), where it is assumed that nsd is listening to port 53530:<br />
<br />
local-zone: "10.in-addr.arpa." nodefault<br />
<br />
stub-zone:<br />
name: "mdylocalnet.com"<br />
stub-addr: 127.0.0.1@53530<br />
<br />
stub-zone:<br />
name: "10.in-addr.arpa"<br />
stub-addr: 127.0.0.1@53530<br />
<br />
Once the unbound.conf contains the above then restart unbound and check that local queries for the nsd zone entries works. Once it is all tested then you can switch unbound to listen on both 127.0.0.1 as well as on the external interface for the local network by having the lines in unbound.conf including:<br />
<br />
interface: 127.0.0.1<br />
interface: 10.0.0.1<br />
<br />
where 10.0.0.1 is the ip address of the dns server running both nsd and unbound and providing local dns for other machines on the 10.x.x.x network.<br />
<br />
The examples here all assume that only ipv4 is being used. Corresponding configurations for ipv6 should be included where necessary, and further details on the parameters for that can be found in the man files for the two packages as well as examples that can be found with web searches.<br />
<br />
==WAN facing dns==<br />
<br />
It is also possible to change the configuration files and interfaces on which the server is listening so that dns queries from machines outside of the local network can access specific machines within the LAN. This is useful for web and mail servers which are accessible from anywhere, and the same techniques can be employed as has been achieved using bind for many years, in combination with appropriate port forwarding in the network firewall machines, to allow incoming requests to access the correct machine.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Bcache&diff=371626Bcache2015-04-28T09:21:57Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register, spelling</p>
<hr />
<div>[[Category:File systems]]<br />
{{Style|Some first-person comments, see [[Help:Style]].}}<br />
<br />
Bcache allows one to use an SSD as a read/write cache (in writeback mode) or read cache (writethrough or writearound) for another blockdevice (generally a rotating HDD or array). This article will show how to install arch using Bcache as the root partition. For an intro to bcache itself, see [http://bcache.evilpiepirate.org/ the bcache homepage]. Be sure to read and reference [http://atlas.evilpiepirate.org/git/linux-bcache.git/tree/Documentation/bcache.txt the bcache manual]. Bcache is in the mainline kernel since 3.10. The kernel on the arch install disk includes the bcache module since 2013.08.01.<br />
<br />
An alternative to Bcache is Facebook's [[Flashcache]] and its offspring [[Enhanceio]]. Another alternative - {{AUR|btier-dkms}}.<br />
<br />
{{Accuracy|Backwards incompatible changes to on-disk format for linux 3.18 appears to be false. bcache on-disk format changes have not yet landed upstream yet as of 3.19}}<br />
<br />
Bcache needs the backing device to be formatted as a bcache block device. In most cases, [https://github.com/g2p/blocks blocks to-bcache] can do an in-place conversion.<br />
{{Warning|<br />
* Be sure you back up any important data first.<br />
* The on-disk format has undergone changes in 3.18 which are not backwards compatible with previous formats.<br />
* Bcache and [[btrfs]] can leave you with a corrupted filesystem. Please visit [https://www.hdevalence.ca/blog/2013-09-21-notes-on-my-archlinux-install this post] for more information.<br />
}}<br />
<br />
== Setting up a bcache device on an existing system ==<br />
<br />
1. Install the {{AUR|bcache-tools}} package from [[AUR]].<br />
<br />
2. Create a backing device (This will typically be your mechanical drive). The backing device can be a whole device, a partition or any other standard block device. This will create /dev/bcache0<br />
# make-bcache -B /dev/sdx1<br />
<br />
3. Create a cache device (This will typically be your SSD). The cache device can be a whole device, a partition or any other standard block device<br />
# make-bcache -C /dev/sdy2<br />
In this example the default block and bucket sizes of 512B and 128kB are used. The block size should match the backing devices sector size which will usually be either 512 or 4k. The bucket size should match the erase block size of the caching device with the intent of reducing write amplification. For example, using a HDD with 4k sectors and an SSD with an erase block size of 2MB this command would look like<br />
# make-bcache --block 4k --bucket 2M -C /dev/sdy2<br />
<br />
4. Register the cache device against your backing device. To find its ''cache set UUID'', run {{ic|# bcache-super-show /dev/sdy2 &#124; grep cset.uuid}} and then add it to the bcache device initially. Udev rules will take care of this on reboot and will only need to be done once.<br />
# echo '''cset.uuid''' > /sys/block/bcache0/bcache/attach<br />
<br />
5. Change your cache mode (if you want to cache writes as well as reads):<br />
# echo writeback > /sys/block/bcache0/bcache/cache_mode<br />
<br />
6. If you want to have this partition available during the initcpio (i.e. you require it at some point in the boot process) you need to add 'bcache' to your modules array in /etc/mkinitcpio.conf as well as adding the 'bcache' hook in your list between block and filesystems. You must then rebuild the initramfs image. This is typically done with<br />
<br />
# mkinitcpio -p linux<br />
<br />
=== Bcache management ===<br />
1. Check that everything has been correctly setup <br />
<br />
# cat /sys/block/bcache0/bcache/state<br />
<br />
The output can be:<br />
* '''no cache''': this means you have not attached a caching device to your backing bcache device<br />
* '''clean''': this means everything is ok. The cache is clean.<br />
* '''dirty''': this means everything is setup fine and that you have enabled ''writeback'' and that the cache is dirty.<br />
* '''inconsistent''': you are in trouble because the backing device is not in sync with the caching device<br />
<br />
You can have a {{ic|/dev/bcache0}} device associated with a backing device with no caching device attached. This means that all I/O (read/write) are passed directly to the backing device (pass-through mode)<br />
<br />
2. See what caching mode is in use<br />
{{bc|# cat /sys/block/bcache0/bcache/cache_mode <br />
[writethrough] writeback writearound none<br />
}}<br />
In the above example, the ''writethrough'' mode is enabled.<br />
<br />
3. Show info about a bcached device:<br />
<br />
# bcache-super-show /dev/sdXY<br />
<br />
4. Stop the backing device:<br />
<br />
# echo 1 > /sys/block/sdX/sdX[Y]/bcache/stop<br />
<br />
5. Detach a caching device:<br />
<br />
# echo 1 > /sys/block/sdX/sdX[Y]/bcache/detach<br />
<br />
6. Safely remove the cache device<br />
# echo <cache-set-uuid> > /sys/block/bcache0/bcache/detach<br />
<br />
7. Release attached devices<br />
# echo 1 > /sys/fs/bcache/<cache-set-uuid>/stop<br />
<br />
=== Bcache on top of another block layer ===<br />
{{Accuracy| it is strongly advises to make Bcache first, underneath any other block layer}}<br />
{{Warning|<br />
* it is widely recommended to use Bcache underneath any other block layer.<br />
* the '''blocks''' package is broken with Python3. Please visit [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug&#61;769737 this thread] for a workaround, or use [[Python VirtualEnv]].<br />
* when on top of a '''LVM2''' layer, the ''discard'' mount option may not be handled well.<br />
}}<br />
With {{ic|blocks}}, you can add a Bcache layer on a device with an existing filesystem or layer (normal partition, LUKS partition, logical volume).<br />
<br />
First, install the {{AUR|blocks-git}} package from [[AUR]].<br />
<br />
''blocks'' needs to add the '''bcache''' metadata at the start of the targeted partition, here {{ic|/dev/sdz4}}; to be able to do so, it will resize the partition just before the targeted one ({{ic|/dev/sdz3}}) to make necessary room, typically 2048 bits (2k). It will ask for your passphrase if the partition({{ic|/dev/sdz3}}) is an LUKS partition. Then it will recreate another partition with the start just lower of 2048 bits and run ''make-bcache'', so you do not need to run it yourself.<br />
<br />
# blocks to-bcache /dev/sdz4<br />
<br />
You can check that everything is ok by running:<br />
<br />
# bcache-super-show /dev/sdz4<br />
<br />
which should output metadata about the new backing '''bcache''' device<br />
<br />
You can proceed to create the caching device and attach it to the backing device.<br />
<br />
==== Troubleshooting ====<br />
If {{ic|blocks}} complains complains about ''overlapping metadata'' when running {{ic|blocks to-bcache}}, you will need to shrink by 100Mb the partition you want to cache and create a new 100Mb free partition.<br />
<br />
== Installation to a bcache device ==<br />
<br />
1. Boot on the install disk (2013.08.01 minimum).<br />
<br />
2. Install the {{AUR|bcache-tools}} package from [[AUR]].<br />
<br />
3. Partition your hdd<br />
<br />
{{Note|While it may be true that Grub2 does not offer support for bcache as noted below, it does, however, fully support UEFI. It follows then, that so long as the necessary modules for the linux kernel to properly handle your boot device are either compiled into the kernel or are included in an initramfs, and you can include these files on it, the separate boot partition described below may be omitted in favor of the FAT EFI system partition. See [[GRUB]] and/or [[UEFI]] for more.}}<br />
grub cannot handle bcache, so you will need at least 2 partitions (boot and one for the bcache backing device). If you are doing UEFI, you will need an EFI System Partition (ESP) as well. E.g.:<br />
1 2048 22527 10.0 MiB EF00 EFI System<br />
2 22528 432127 200.0 MiB 8300 arch_boot<br />
3 432128 625142414 297.9 GiB 8300 bcache_backing<br />
<br />
{{Note|This example has no swapfile/partition. For a swap partition on the cache, use LVM in step 7. For a swap partition outside the cache, be sure to make a swap partition now.}}<br />
<br />
4. Configure your HDD as a bcache backing device.<br />
<br />
# make-bcache -B /dev/sda3<br />
<br />
{{Note|<br />
* When preparing any boot disk it is important to know the ramifications of any decision you may make. Please review and review again the documentation for your chosen boot-loader/-manager and consider seriously how it might relate to bcache.<br />
* If all associated disks are partitioned at once as below bcache will automatically attach "-B backing stores" to the "-C ssd cache" and step 6 is unnecessary.<br />
}}<br />
<br />
# make-bcache -B /dev/sd? /dev/sd? -C /dev/sd?<br />
<br />
You now have a {{ic|/dev/bcache0}} device.<br />
<br />
5. Configure your SSD<br />
<br />
Format the SSD as a caching device and link it to the backing device<br />
<br />
# make-bcache -C /dev/sdb<br />
# echo /dev/sdb > /sys/fs/bcache/register <br />
# echo ''UUID__from_previous_command'' > /sys/block/bcache0/bcache/attach<br />
<br />
{{Note|If the UUID is forgotten, it can be found with {{ic|ls /sys/fs/bcache/}} after the cache device has been registered.}}<br />
<br />
6. Format the bcache device. Use LVM or btrfs subvolumes if you want to divide up the {{ic|/dev/bcache0}} device how you like (ex for separate {{ic|/}}, {{ic|/home}}, {{ic|/var}}, etc):<br />
<br />
# mkfs.btrfs /dev/bcache0<br />
# mount /dev/bcache0 /mnt/<br />
# btrfs subvolume create /mnt/root<br />
# btrfs subvolume create /mnt/home<br />
# umount /mnt<br />
<br />
7. Prepare the installation mount point:<br />
<br />
# mkfs.ext4 /dev/sda2<br />
# mkfs.msdos /dev/sda1 (if your ESP is at least 500MB, use mkfs.vfat to make a FAT32 partition instead)<br />
# pacman -S arch-install-scripts<br />
# mount /dev/bcache0 -o subvol=root,compress=lzo /mnt/<br />
# mkdir /mnt/boot /mnt/home<br />
# mount /dev/bcache0 -o subvol=home,compress=lzo /mnt/home<br />
# mount /dev/sda2 /mnt/boot<br />
# mkdir /boot/efi<br />
# mount /dev/sda1 /mnt/boot/efi/<br />
<br />
8. Install the system as per the [[Installation guide#Connect to the Internet|Installation Guide]] as normal except this:<br />
<br />
Before you edit {{ic|/etc/mkinitcpio.conf}} and run {{ic|mkinitcpio -p linux}}:<br />
<br />
* install {{AUR|bcache-tools}} package from the [[AUR]].<br />
* Edit {{ic|/etc/mkinitcpio.conf}}:<br />
** add the "bcache" module<br />
** add the "bcache" hook between block and filesystem hooks<br />
<br />
== Configuring ==<br />
<br />
There are many options that can be configured (such as cache mode, cache flush interval, sequential write heuristic, etc.) This is currently done by writing to files in {{ic|/sys}}. See the [http://atlas.evilpiepirate.org/git/linux-bcache.git/tree/Documentation/bcache.txt bcache user documentation].<br />
<br />
Changing the cache mode is done by echoing one of 'writethrough', 'writeback', 'writearound' or 'none' to /sys/block/bcache[0-9]/bcache/cache_mode.<br />
<br />
Note that changes to /sys are temporary, and will revert back after a reboot. To set custom configurations at boot create a .conf file in {{ic|/etc/tmpfile.d}}. To set, in a persistent fashion, the sequential cutoff for bcache0 to 1 MB and write back you could create a file {{ic|/etc/tmpfile.d/my-bcache.conf}} with the contents<br />
<br />
w /sys/block/bcache0/bcache/sequential_cutoff - - - - 1M<br />
w /sys/block/bcache0/bcache/cache_mode - - - - writeback<br />
<br />
== Advanced operations ==<br />
<br />
=== Resize backing device ===<br />
<br />
It is possible to resize the backing device so long as you do not move the partition start. This process is described on [http://comments.gmane.org/gmane.linux.kernel.bcache.devel/249 the mailing list]. Here is an example using btrfs volume directly on bcache0. For LVM containers or for other filesystems, procedure will differ.<br />
<br />
==== Example of growing ====<br />
<br />
In this example, I grow the filesystem by 4GB. <br />
<br />
1. Reboot to a live CD/USB Drive (need not be bcache enabled) and use fdisk, gdisk, parted, or your other favorite tool to delete the backing partition and recreate it with the same start and a total size 4G larger. <br />
<br />
{{Warning|Do not use a tool like GParted that might perform filesystem operations! It will not recognize the bcache partition and might overwrite part of it!!}}<br />
<br />
2. Reboot to your normal install. Your filesystem will be currently mounted. That is fine. Issue the command to resize the partition to its maximum. For btrfs, that is<br />
<br />
# btrfs filesystem resize max /<br />
<br />
For ext3/4, that is:<br />
<br />
# resize2fs /dev/bcache0<br />
<br />
==== Example of shrinking ====<br />
<br />
In this example, I shrink the filesystem by 4GB.<br />
<br />
1. Disable writeback cache (switch to writethrough cache) and wait for the disk to flush.<br />
<br />
# echo writethrough > /sys/block/bcache0/bcache/cache_mode<br />
$ watch cat /sys/block/bcache0/bcache/state<br />
<br />
wait until state reports "clean". This might take a while.<br />
<br />
2. Shrink the mounted filesystem by something more than the desired amount, to ensure we do not accidentally clip it later. For btrfs, that is:<br />
<br />
# btrfs filesystem resize -5G /<br />
<br />
For ext3/4 you can use ''resize2fs'', but only if the partition is unmounted<br />
<br />
$ df -h /home<br />
/dev/bcache0 290G 20G 270G 1% /home<br />
# umount /home<br />
# resize2fs /dev/bcache0 283G<br />
<br />
3. Reboot to a LiveCD/USB drive (does not need to support bcache) and use fdisk, gdisk, parted, or your other favorite tool to delete the backing partition and recreate it with the same start and a total size 4G smaller.<br />
<br />
{{Warning|Do not use a tool like GParted that might perform filesystem operations! It will not recognize the bcache partition and might overwrite part of it!!}}<br />
<br />
4. Reboot to your normal install. Your filesystem will be currently mounted. That is fine. Issue the command to resize the partition to its maximum (that is, the size we shrunk the actual partition to in step 3). For btrfs, that is:<br />
<br />
# btrfs filesystem resize max /<br />
<br />
For ext3/4, that is:<br />
<br />
# resize2fs /dev/bcache0<br />
<br />
5. Re-enable writeback cache if you want that enabled:<br />
<br />
# echo writeback > /sys/block/bcache0/bcache/cache_mode<br />
<br />
{{Note|If you are very careful you can shrink the filesystem to the exact size in step 2 and avoid step 4. Be careful, though, many partition tools do not do exactly what you want, but instead adjust the requested partition start/end points to end on sector boundaries. This may be difficult to calculate ahead of time}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== /dev/bcache device does not exist on bootup ===<br />
<br />
If you are sent to a busy box shell with an error:<br />
<br />
{{bc|1=<br />
ERROR: Unable to find root device 'UUID=b6b2d82b-f87e-44d5-bbc5-c51dd7aace15'.<br />
You are being dropped to a recovery shell<br />
Type 'exit' to try and continue booting<br />
}}<br />
<br />
This might happen if the backing device is configured for "writeback" mode (default is writearound). When in "writeback" mode, the /dev/bcache0 device is not started until the cache device is both registered and attached. Registering is something that needs to happen every bootup, but attaching should only have to be done once. <br />
<br />
To continue booting, try one of the following:<br />
<br />
* Register both the backing device and the caching device<br />
<br />
# echo /dev/sda3 > /sys/fs/bcache/register<br />
# echo /dev/sdb > /sys/fs/bcache/register<br />
<br />
If the /dev/bcache0 device now exists, type exit and continue booting. You will need to fix your initcpio to ensure devices are registered before mounting the root device.<br />
<br />
{{Note|<br />
* An error of "sh: echo: write error: Invalid argument" means the device was already registered or is not recognized as either a bcache backing device or cache. If using the udev rule on boot it should only attempt to register a device if it finds a bcache superblock<br />
* This can also happen if using udev's 69-bcache.rules in Installation's step 7 and blkid and bcache-probe "disagree" due to rogue superblocks. See [http://bcache.evilpiepirate.org/#index6h1 bcache's wiki] for a possible explanation/resolution.<br />
}}<br />
<br />
* Re-attach the cache to the backing device:<br />
<br />
If the cache device was registered, a folder with the UUID of the cache should exist in {{ic|/sys/fs/bcache}}. Use that UUID when following the example below:<br />
<br />
# ls /sys/fs/bcache/<br />
b6b2d82b-f87e-44d5-bbc5-c51dd7aace15 register register_quiet<br />
# echo b6b2d82b-f87e-44d5-bbc5-c51dd7aace15 > /sys/block/sda/sda3/bcache/attach<br />
<br />
If the {{ic|/dev/bcache0}} device now exists, type exit and continue booting. You should not have to do this again. If it persists, ask on the bcache mailing list.<br />
<br />
{{Note|An error of {{ic|sh: echo: write error: Invalid argument}} means the device was already attached. An error of {{ic|sh: echo: write error: No such file or directory}} means the UUID is not a valid cache (make sure you typed it correctly).}}<br />
<br />
* Invalidate the cache and force the backing device to run without it. You might want to check some stats, such as "dirty_data" so you have some idea of how much data will be lost.<br />
<br />
# cat /sys/block/sda/sda3/bcache/dirty_data<br />
-3.9M<br />
<br />
dirty data is data in the cache that has not been written to the backing device. If you force the backing device to run, this data will be lost, even if you later re-attach the cache.<br />
<br />
# cat /sys/block/sda/sda3/bcache/running<br />
0<br />
# echo 1 > /sys/block/sda/sda3/bcache/running<br />
<br />
The {{ic|/dev/bcache0}} device will now exist. Type exit and continue booting. You might want to unregister the cache device and run make-bcache again. An fsck on {{ic|/dev/bcache0}} would also be wise. See the [http://atlas.evilpiepirate.org/git/linux-bcache.git/tree/Documentation/bcache.txt?h=bcache bcache user documentation].<br />
<br />
{{Warning|Only invalidate the cache if one of the two options above did not work.}}<br />
<br />
=== /sys/fs/bcache/ does not exist ===<br />
<br />
The kernel you booted is not bcache enabled.<br />
<br />
== See also ==<br />
<br />
* [http://bcache.evilpiepirate.org Bcache Homepage] <br />
* [https://www.kernel.org/doc/Documentation/bcache.txt Bcache Manual]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Guild_Wars_2&diff=371625Guild Wars 22015-04-28T09:19:28Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Gaming]]<br />
''Guild Wars 2'' is a game developed by NC Soft. Currently a native client is only available for Windows and Mac systems. It is runnable through wine though.<br />
<br />
== Installation ==<br />
<br />
Install {{Pkg|wine}} and {{Pkg|mpg123}}.<br />
Download the GW2 client from their [http://cloudfront.guildwars2.com/client/Gw2.exe website], and run it like this:<br />
wine ./Gw2.exe<br />
Alternatively you can use [http://boxedfox.org/projects/winegw2/ WineGW2] which is a fork of wine that fixes some issues and provides better performance. You may still want to install {{Pkg|wine}} package to get the dependencies right.<br />
<br />
== Known issues ==<br />
<br />
'''1. Patcher/launcher window is invisible/flickering.'''<br />
<br />
Run it with -dx9single like so:<br />
wine ./Gw2.exe -dx9single<br />
<br />
'''2. Patcher/launcher crashes with assertion failed on "m_ioCount"'''<br />
<br />
The best known "fix" for this is to just let it crash and restart it, it should continue on where it left off. Some people reports that the installer crashes when approximately 1 GB has been downloaded but some other people reports crashes every few minutes. This however is rarely a problem when installing patches and only the initial installation poses a challenge, reason why some people just copy the Gw2 installation directory or the Gw2.dat from a Windows installation into the GW2 installation directory in Linux (/wineprefix/GuildWars2/drive_c/Program Files/ArenaNet/Guild Wars 2/) when installing the game.<br />
<br />
The percent of the download resets every time the launcher is started, but the amount that has already downloaded is not accounted into this number; just what remains is. The best number correlates with the total download progress is the '''Files Remaining'''.<br />
<br />
If you have only one file remaining, switch to a language other than english or spanish, let it download that information, and then switch back to English.<br />
<br />
'''3. Ingame Bazaar (Black Lion's Trade) does not work ("Awesomium patch")'''<br />
<br />
Fixed in Wine 1.7.5.<br />
<br />
For more info see: [http://bugs.winehq.org/show_bug.cgi?id=27168 Wine bug #27168]<br />
<br />
'''4. Make "Garbage" when take screenshots in JPEG mode'''<br />
<br />
Fixed in wine 1.7.4.<br />
<br />
To take screenshot in BMP, add flag -bmp in command line:<br />
wine ./Gw2.exe -bmp<br />
<br />
For more info see: [http://bugs.winehq.org/show_bug.cgi?id=31557 Wine bug #31557] <br />
<br />
'''5. The camera movement is stopped when the mouse reaches the edge of window'''<br />
<br />
When click MOUSE1 and move to rotate the camera , this stops when it reaches the edge of the window, this fixed in 1.5.14, but broken again in 1.5.29.<br />
<br />
Need Download Wine sources from GIT and revert a certain commit with:<br />
<br />
git revert --no-edit 76bbf106a28c4caa82873e8450bde7d4adc765bf<br />
<br />
or download sources tarball, and apply (revert in this case, patch -R) this patch:<br />
<br />
http://source.winehq.org/git/wine.git/patch/76bbf106a28c4caa82873e8450bde7d4adc765bf<br />
<br />
For more info see: [http://bugs.winehq.org/show_bug.cgi?id=33479 Wine bug #33479]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=St&diff=371624St2015-04-28T09:18:29Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Terminal emulators]]<br />
[http://st.suckless.org/ st] is a simple terminal implementation for [[X]] by [http://suckless.org suckless]. It is intended to serve as a lightweight replacement for [[xterm]] or [[rxvt-unicode|urxvt]]. It currently supports 256 colors, most VT10X escape sequences, UTF-8, X11 copy/paste, anti-aliased fonts (using fontconfig), fallback fonts, resizing, shortcuts via config.h, and line drawing.<br />
<br />
== Installation ==<br />
[[pacman|Install]] the package {{AUR|st}} or {{AUR|st-git}} from the [[Arch User Repository]].<br />
<br />
Install {{AUR|st-git-zsh}} package for a ''zsh'' preconfigured ''st''. <br />
<br />
== Configuration ==<br />
''st'' is configured through its {{ic|config.h}} file, which is copied over from {{ic|config.h}} at compile time. A default {{ic|config.def.h}} is included with the source. <br />
<br />
Consider maintaining your own [[PKGBUILD]] with your {{ic|config.h}}.<br />
<br />
=== Shell ===<br />
<br />
To change the default shell for ''st'', edit this line:<br />
<br />
static char shell[] = "/bin/sh";<br />
<br />
=== Term ===<br />
<br />
To change the terminal type, edit this line:<br />
<br />
static char termname[] = "st-256color";<br />
<br />
''st'' will set the {{ic|TERM}} variable with the value of {{ic|termname}}.<br />
<br />
{{note|If you experience trouble with ''st'', you can try to set {{ic|termname}} to {{ic|xterm}} or {{ic|xterm-256color}} }}<br />
<br />
=== Font ===<br />
<br />
Edit the following line as you prefer:<br />
<br />
static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=false";<br />
<br />
You can also pass the value of the font in the command line:<br />
<br />
st -f "Liberation Mono:size=12"<br />
<br />
=== Colors ===<br />
<br />
Edit the following line to set ''foreground'', ''background'' and ''cursor'' colors:<br />
<br />
static unsigned int defaultfg = 7;<br />
static unsigned int defaultbg = 0;<br />
static unsigned int defaultcs = 256;<br />
<br />
The values refer to the {{ic|*colorname[]}} array in the same file, you can use default color or add yours in {{ic|#rrggbb}}, for example:<br />
<br />
static const char *colorname[] = {<br />
/* 8 normal colors */<br />
"black",<br />
"red3",<br />
"green3",<br />
"yellow3",<br />
"blue2",<br />
"magenta3",<br />
"cyan3",<br />
"gray90",<br />
<br />
/* 8 bright colors */<br />
"gray50",<br />
"red",<br />
"green",<br />
"yellow",<br />
"#5c5cff",<br />
"magenta",<br />
"cyan",<br />
"white",<br />
<br />
[255] = 0,<br />
<br />
/* more colors can be added after 255 to use with DefaultXX */<br />
"#cccccc",<br />
"#eeeeee",<br />
"#111111",<br />
};<br />
<br />
/*<br />
* Default colors (colorname index)<br />
* foreground, background, cursor<br />
*/<br />
static unsigned int defaultfg = 257;<br />
static unsigned int defaultbg = 258;<br />
static unsigned int defaultcs = 256;<br />
<br />
== Troubleshooting ==<br />
<br />
=== Keyboard ===<br />
==== Backspace not working properly ====<br />
<br />
While virtual terminal and most popular terminal emulator for X bind {{ic|backscape}} key to {{ic|^?}} escape sequence, {{ic|st}} bind it to {{ic|^H}}, as explained in the FAQ.<br />
<br />
If hitting the {{ic|backspace}} key while typing on standard input of some programs (like {{ic|read}}) prints {{ic|^H}} instead of erasing, you can fix that with:<br />
<br />
stty erase '^H'<br />
<br />
This will make the terminal interprets {{ic|^H}} as an erase command. <br />
<br />
If you want to put the above command in a shell profile, you should consider checking the {{ic|$TERM}} before launch it.<br />
<br />
=== Vim ===<br />
==== The background colour of text in ''vim'' will not fill in anything that is not a character ====<br />
Try setting the value of {{ic|termname}} in your {{ic|config.h}} to {{ic|st-256color}} and recompiling. And do not set the {{ic|TERM}} var in your shell, at least not to {{ic|st-256color}} as this seems to cause the issue.<br />
<br />
Another solution, perhaps a better one, is to have the following lines in your {{ic|.vimrc}} file:<br />
<br />
if &term =~ '256color'<br />
" disable Background Color Erase (BCE) so that color schemes<br />
" render properly when inside 256-color tmux and GNU screen.<br />
" see also http://sunaku.github.io/vim-256color-bce.html<br />
set t_ut=<br />
endif<br />
<br />
== See also ==<br />
*[http://st.suckless.org/ Homepage]<br />
*[http://git.suckless.org/st/plain/FAQ Frequently asked questions]<br />
*[http://git.suckless.org/st/ Official git repository]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Scanner_Button_Daemon&diff=371623Scanner Button Daemon2015-04-28T09:17:59Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Imaging]]<br />
== Introduction ==<br />
<br />
=== What is scanbd good for ===<br />
<br />
The majority of the desktop scanners are more or less "passive" devices, say they can be queried from a suitable application but they do not do anything themselves.<br />
<br />
[http://sourceforge.net/projects/scanbd/ scanbd] tries to solve the problem with managing such scanners to make use of the scanner-buttons they have ''(only when the buttons are supported by sane)''.<br />
<br />
=== How does it work ===<br />
<br />
scanbd (the scanner button daemon) opens and polls the scanner and therefore locks the device. So no other application can access the device directly (open the /dev/..., or via libusb, etc).<br />
<br />
To solve this, a second daemon is used (in the so called "manager-mode" of scanbd): scanbm is configured as a "proxy" to access the scanner and, if another application tries to use the scanner, the polling daemon is ordered to disable polling for the time the other scan-application wants to use the scanner.<br />
<br />
To make this happen, scanbm is configured instead of [[Sane#Network_scanning|saned]] as the network scanning daemon. If a scan request arrives to scanbm on the sane-port, scanbm stops the polling by sending a dbus-signal to the polling scanbd-daemon. Then it starts the real saned which scans and sends the data back to the requesting application. Afterwards the scanbd-manager scanbm restarts the polling by sending another dbus-signal to scanbd.<br />
<br />
Due to the above, the set up of the scanbd requires changes in default configuration of sane and also definition of own action scripts (defining what should be done when a button on the scanner is pressed).<br />
<br />
There are also alternatives to scanbd, eg. [http://scanbuttond.sourceforge.net/ scanbuttond], however these seem to be unmaintained nowadays.<br />
<br />
== Installation ==<br />
<br />
As of version 1.3, scanbd is fully compatible with [[systemd]] service activation and does not require '''inet''' neither '''xinetd''' to start scanbm (manager mode of scanbd), though these remain as an alternative (not described here).<br />
<br />
{{AUR|scanbd}} is available from the [[AUR]].<br />
<br />
=== Sane configuration ===<br />
<br />
Since scanbd and saned are running on the same machine as the scanner is connected to, we need to have two sets of saned configurations - one in the default location (/etc/sane.d/), which would redirect local applications to a network socket, that systemd is listening on, and another one (e.g. /etc/scandb/sane.d/), which will be actually used by sane backend to access the attached scanner.<br />
<br />
First, copy all config files from {{ic|/etc/sane.d/}} to {{ic|/etc/scandb/sane.d/}} (these will be needed later):<br />
<br />
# cp /etc/sane.d/* /etc/scanbd/sane.d/<br />
<br />
Modify /etc/sane.d/dll.conf so that it includes ''only'' the "net" directive (either delete the other directives (printers), or comment them with # symbol):<br />
<br />
{{hc|/etc/sane.d/dll.conf|<br />
net}}<br />
<br />
Modify the net-backend configuration file (see scanbd's README.txt for more complicated setups):<br />
<br />
{{hc|/etc/sane.d/net.conf|2=<br />
connect_timeout = 3<br />
localhost # scanbm is listening on localhost}}<br />
<br />
Now the desktop applications (which use libsane) are forced (by the above dll.conf) to use the net-backend only. This prevents them from using the locally attached scanners directly (and blocking them).<br />
<br />
Whenever there is a connection to the standard sane network socket, systemd starts scanbm ("manager mode" of scanbd), which in turn tells (the already running) scanbd to stop polling the scanner and then it starts saned with the alternative configuration directory.<br />
<br />
The last step is to modify the alternative configuration of sane in {{ic|/etc/scandb/sane.d/dll.conf}}: just make sure that the "net" directive is commented and the corresponding scanner-backends are uncommented:<br />
<br />
{{hc|/etc/scanbd/sane.d/dll.conf|<br />
#net<br />
pixma<br />
epson2<br />
#... whatever other scanner backend needed ...}}<br />
<br />
Now it is time to enable and start the systemd units of scanbm:<br />
<br />
# systemctl enable scanbd.service<br />
# systemctl start scanbd.service<br />
# systemctl start scanbm.socket<br />
<br />
You can check {{ic|/var/log/everything}} to see if the scanbd service and scanbm socket were started. To increase debugging verbosity, change {{ic|1=debug-level = 7}} in {{ic|/etc/scanbd/scanbd.conf}} and restart the scanbd service.<br />
<br />
=== scanbd configuration ===<br />
<br />
If you are lucky, your scanner might work almost out of the box and you would only want to modify the action scripts, which define what is done when a particular button is pressed.<br />
<br />
scanbm listens to scanner's status and on the basis of messages received, it decides what to do. The standard behaviour is defined in {{ic|/etc/scanbd/scanbd.conf}}. E.g. the action scan:<br />
<br />
action scan {<br />
filter = "^scan.*"<br />
numerical-trigger {<br />
from-value = 1<br />
to-value = 0<br />
}<br />
desc = "Scan to file"<br />
script = "test.script"<br />
}<br />
<br />
Whenever the message from the scanner includes word "scan" (see reg-exp for more details on filters) and the value changes from 1 to 0, then it runs script {{ic|/etc/scanbd/test.script}}.<br />
<br />
{{ic|/etc/scanbd/test.script}} does not do anything but sends a message to syslog:<br />
<br />
{{hc|/etc/scanbd/test.script|<br />
#!/bin/bash<br />
# look in scanbd.conf for environment variables<br />
<br />
logger -t "scanbd: $0" "Begin of $SCANBD_ACTION for device $SCANBD_DEVICE"<br />
<br />
# printout all env-variables<br />
/usr/bin/printenv > /tmp/scanbd.script.env<br />
<br />
logger -t "scanbd: $0" "End of $SCANBD_ACTION for device $SCANBD_DEVICE"}}<br />
<br />
There are a few other scripts available in {{ic|/etc/scanbd/}} that actually do something - have a look yourself.<br />
<br />
Also, {{ic|/etc/scanbd/scanbd.conf}} has "include" directives at the end, which refer to preconfigured button definitions of a few printers.<br />
<br />
$ cat /etc/scanbd/scanbd.conf | grep include\(<br />
# include("scanner.d/myscanner.conf")<br />
# include("/my/long/path/myscanner.conf")<br />
include(scanner.d/avision.conf)<br />
include(scanner.d/fujitsu.conf)<br />
include(scanner.d/hp.conf)<br />
include(scanner.d/pixma.conf)<br />
include(scanner.d/snapscan.conf)</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Netctl&diff=371622Netctl2015-04-28T09:17:13Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register, spelling</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Network managers]]<br />
[[cs:Netctl]]<br />
[[es:Netctl]]<br />
[[fr:Netctl]]<br />
[[ja:Netctl]]<br />
[[ru:Netctl]]<br />
[[zh-CN:Netctl]]<br />
{{Related articles start}}<br />
{{Related|Bridge with netctl}}<br />
{{Related|Network configuration}}<br />
{{Related|Wireless network configuration}}<br />
{{Related|:Category:Network managers}}<br />
{{Related articles end}}<br />
'''netctl''' is a CLI-based tool used to configure and manage network connections via profiles. It is a native Arch Linux project for network configuration.<br />
<br />
== Installation ==<br />
<br />
[[Install]] {{Pkg|netctl}} from the [[official repositories]].<br />
<br />
Optional dependencies are shown in the table below.<br />
<br />
{| class="wikitable"<br />
! Feature<br />
! Dependency<br />
! netctl program <br /> (if relevant)<br />
|-<br />
| Automatic wireless connections || {{Pkg|wpa_actiond}} || {{ic|netctl-auto}}<br />
|-<br />
| Automatic wired connections || {{Pkg|ifplugd}} || {{ic|netctl-ifplugd}}<br />
|-<br />
| WPA || {{Pkg|wpa_supplicant}} ||<br />
|-<br />
| DHCP || {{Pkg|dhcpcd}} or {{Pkg|dhclient}} ||<br />
|-<br />
| Wifi menus || {{Pkg|dialog}} ||<br />
|-<br />
| PPPoE || {{Pkg|ppp}} ||<br />
|-<br />
|}<br />
<br />
{{Warning|Do not enable concurrent, conflicting network service. Use {{ic|1=systemctl --type=service}} to ensure that no other network service is running before enabling a ''netctl'' profile/service.}}<br />
<br />
== Usage ==<br />
<br />
It is advisable to read the following man pages before using netctl:<br />
<br />
* [https://github.com/joukewitteveen/netctl/blob/master/docs/netctl.1.txt netctl]<br />
* [https://github.com/joukewitteveen/netctl/blob/master/docs/netctl.profile.5.txt netctl.profile]<br />
* [https://github.com/joukewitteveen/netctl/blob/master/docs/netctl.special.7.txt netctl.special]<br />
<br />
== Configuration ==<br />
<br />
''netctl'' uses profiles to manage network connections and different modes of operation to start profiles automatically or manually on demand. <br />
<br />
=== Profile configuration ===<br />
<br />
The ''netctl'' profile files are stored in {{ic|/etc/netctl/}} and example configuration files are available in {{ic|/etc/netctl/examples/}}. Common configurations include:<br />
<br />
* ethernet-dhcp<br />
* ethernet-static<br />
* wireless-wpa<br />
* wireless-wpa-static<br />
<br />
To use an example profile, simply copy it from {{ic|/etc/netctl/examples/}} to {{ic|/etc/netctl/}} and configure it to your needs; see basic [[#Example profiles]] below. The first parameter you need to create a profile is the network {{ic|Interface}}, see [[Network configuration#Device names]] for details.<br />
<br />
{{Tip|<br />
* For wireless settings, you can use {{ic|wifi-menu -o}} as root to generate the profile file in {{ic|/etc/netctl/}}.<br />
* To enable a static IP profile on wired interface no matter if the cable is connected or not, use {{ic|1=SkipNoCarrier=yes}} in your profile.<br />
}}<br />
<br />
Once you have created your profile, attempt to establish a connection (use only the profile name, not the full path):<br />
<br />
# netctl start ''profile''<br />
<br />
If the above command results in a failure, then use {{ic|journalctl -xn}} and {{ic|netctl status ''profile''}} to obtain a more in depth explanation of the failure.<br />
<br />
=== Automatic operation ===<br />
<br />
If you use only one profile (per interface) or want to switch profiles manually, the [[#Basic method|Basic method]] will do. Most common examples are servers, workstations, routers etc.<br />
<br />
If you need to switch multiple profiles frequently, use [[#Automatic switching of profiles|Automatic switching of profiles]]. Most common examples are laptops.<br />
<br />
==== Basic method ====<br />
<br />
With this method, you can statically start only one profile per interface. First manually check that the profile can be started successfully with: <br />
<br />
# netctl start ''profile'' <br />
<br />
then it can be enabled using:<br />
<br />
# netctl enable ''profile''<br />
<br />
This will create and enable a [[systemd]] service that will start when the computer boots. Changes to the profile file will not propagate to the service file automatically. After such changes, it is necessary to reenable the profile:<br />
<br />
# netctl reenable ''profile''<br />
<br />
After enabling a profile, it will be started at next boot. Obviously this can only be successful, if the network cable for a wired connection is plugged in, or the wireless access point used in a profile is in range respectively.<br />
<br />
==== Automatic switching of profiles ====<br />
<br />
''netctl'' provides two special [[systemd]] services for automatic switching of profiles:<br />
<br />
* Package {{Pkg|ifplugd}} for wired interfaces: After [[Start|starting and enabling]] {{ic|netctl-ifplugd@''interface''.service}} DHCP profiles are started/stopped when the network cable is plugged in and out. To include a static IP profile the option {{ic|1=ExcludeAuto=no}} needs to be set in it. <br />
* Package {{Pkg|wpa_actiond}} for wireless interfaces: After [[Start|starting and enabling]] {{ic|netctl-auto@''interface''.service}} profiles are started/stopped automatically as you move from the range of one network into the range of another network (roaming).<br />
<br />
Note that ''interface'' is not literal, but to be substituted by the name of your device's interface, e.g. {{ic|netctl-auto@wlp4s0.service}}.<br />
<br />
The following options can be used: <br />
<br />
* If you want some wireless profile '''not''' to be started automatically by {{ic|netctl-auto@''interface''.service}}, you have to explicitly add {{ic|1=ExcludeAuto=yes}} to that profile. <br />
* The {{ic|netctl-ifplugd@''interface''.service}} will prefer profiles which use [[Wikipedia:DHCP|DHCP]]. To prefer a profile with a static IP, you can set {{ic|1=Priority=2}}, which is higher than the default priority given to DHCP profiles of {{ic|1=Priority=1}}. Do not forget to also set {{ic|1=ExcludeAuto=no}} as mentioned above. See {{ic|netctl.profile(5)}} for details.<br />
* You can use {{ic|1=Priority=}} in the ''WPAConfigSection'' (see {{ic|/etc/netctl/examples/wireless-wpa-configsection}}) to set priority of a profile when multiple wireless access points are available. Note that automatic selection of a WPA profile by ''netctl-auto'' is not possible with option {{ic|1=Security=wpa-config}}, use {{ic|1=Security=wpa-configsection}} instead.<br />
<br />
{{Warning|<br />
* If any of the profiles contain errors, such as an empty or misquoted {{ic|1=Key=}} variable, the unit will fail to load with the message {{ic|"Failed to read or parse configuration '/run/network/wpa_supplicant_wlan0.conf'}}, even when that profile is not being used.<br />
* This method conflicts with the [[#Basic method|Basic method]]. If you have previously enabled a profile through ''netctl'', run {{ic|netctl disable ''profile''}} to prevent the profile from starting twice at boot.<br />
}}<br />
<br />
Since netctl 1.3 it is possible to manually control an interface otherwise managed by ''netctl-auto'' without having to stop {{ic|netctl-auto.service}}. This is done using the ''netctl-auto'' command. For a list of available actions run:<br />
# netctl-auto --help<br />
<br />
=== Example profiles ===<br />
<br />
==== Wired ====<br />
<br />
For a DHCP connection, only the {{ic|Interface}} has to be configured after copying the {{ic|/etc/netctl/examples/ethernet-dhcp}} example profile to {{ic|/etc/netctl}}. <br />
<br />
For example:<br />
{{hc|/etc/netctl/''my_dhcp_rofile''|<nowiki><br />
Interface=enp1s0<br />
IP=dhcp</nowiki><br />
}}<br />
<br />
For a static IP configuration copy the {{ic|/etc/netctl/examples/ethernet-static}} example profile to {{ic|/etc/netctl}} and modify {{ic|Interface}}, {{ic|Address}}, {{ic|Gateway}} and {{ic|DNS}}) as needed. <br />
<br />
For example:<br />
{{hc|/etc/netctl/''my_static_profile''|<nowiki><br />
Interface=enp1s0<br />
Connection-ethernet<br />
IP=static<br />
Address=('10.1.10.2/24')<br />
Gateway='10.1.10.1'<br />
DNS=('10.1.10.1')</nowiki><br />
}}<br />
<br />
For the {{ic|Address}} take care to include the correct netmask (the {{ic|/24}} in the sample profile equates to a netmask of {{ic|255.255.255.0}}) or the profile will fail to start. See also [[wikipedia:Classless Inter-Domain Routing#CIDR notation|CIDR notation]].<br />
<br />
==== Wireless (WPA-PSK) ====<br />
<br />
The following applies for the standard wireless connections using a pre-shared key (WPA-PSK). See [[WPA2 Enterprise#netctl]] for example profiles with other authentication methods. <br />
<br />
The standard ''netctl'' tool to connect to a wireless network (WPA-PSK, WEP) interactively is ''wifi-menu''; used with the {{ic|-o}} option: <br />
<br />
wifi-menu -o <br />
<br />
it generates the configuration file in {{ic|/etc/netctl/}} for the network to use for [[#Automatic operation]] at the same time. <br />
<br />
Alternatively, the profile may also be configured manually, as follows: <br />
<br />
Copy the example file {{ic|wireless-wpa}} from {{ic|/etc/netctl/examples}} to {{ic|/etc/netctl}} (name of your choice):<br />
<br />
# cp /etc/netctl/examples/wireless-wpa /etc/netctl/.<br />
<br />
Edit the profile as needed (modifying {{ic|Interface}}, {{ic|ESSID}} and {{ic|Key}}) and it is done. <br />
<br />
At this step you may want to re-confirm the new profile you created is {{ic|chmod 600}} and confirm it works by starting it: <br />
<br />
netctl start wireless-wpa<br />
<br />
before configuring any [[#Automatic operation]].<br />
<br />
Optionally you can also follow the following step to obfuscate the wireless passphrase (''wifi-menu'' does it automatically): <br />
<br />
Users '''not''' wishing to have the passphrase to their wireless network stored in ''plain text'' have the option of storing the corresponding 256-bit pre-shared key instead, which is calculated from the passphrase and the SSID using standard algorithms.<br />
<br />
Calculate your 256-bit PSK using [[WPA_supplicant#Connecting_with_wpa_passphrase|wpa_passphrase]]:<br />
{{hc|$ wpa_passphrase ''your_essid'' ''passphrase''|2=<br />
network={<br />
ssid="''your_essid''"<br />
#psk="''passphrase''"<br />
psk=64cf3ced850ecef39197bb7b7b301fc39437a6aa6c6a599d0534b16af578e04a<br />
}<br />
}}<br />
<br />
The ''pre-shared key'' (psk) now needs to replaces the plain text passphrase of the {{ic|Key}} variable in the profile. Once completed your network profile {{ic|wireless-wpa}} containing a 256-bit PSK should resemble:<br />
<br />
{{hc|/etc/netctl/wireless-wpa|2=<br />
Description='A simple WPA encrypted wireless connection using 256-bit PSK'<br />
Interface=wlp2s2<br />
Connection=wireless<br />
Security=wpa<br />
IP=dhcp<br />
ESSID=''your_essid''<br />
Key=\"64cf3ced850ecef39197bb7b7b301fc39437a6aa6c6a599d0534b16af578e04a<br />
}}<br />
<br />
{{Note|<br />
* Make sure to use the '''special quoting rules''' for the {{ic|Key}} variable as explained at the end of [https://github.com/joukewitteveen/netctl/blob/master/docs/netctl.profile.5.txt netctl.profile(5)].<br />
* If the passphrase fails, try removing the {{ic|\"}} in the {{ic|Key}} variable.<br />
* Although "encrypted", the key that you put in the profile configuration is enough to connect to a WPA-PSK network. Therefore this process is only useful for hiding the human-readable version of the passphrase. This will not prevent anyone with read access to this file from connecting to the network.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Using an Experimental GUI ===<br />
<br />
If you want a graphical user interface to manage ''netctl'' and your connections and you are not afraid of highly experimental unofficial packages you can install {{AUR|netgui}} from [[AUR]]. Note, however, that ''netgui'' is still in beta status and you should be familiar with the general ''netctl'' syntax to debug possible issues. Another GUI alternative is {{AUR|netctl-gui}} which provides a Qt-based graphical interface, DBus daemon and KDE widget. A third alternative is {{AUR|netmenu}}, which uses {{Pkg|dmenu}} as its graphical interface.<br />
<br />
=== Eduroam ===<br />
<br />
See [[WPA2_Enterprise#netctl]].<br />
<br />
=== Bonding ===<br />
<br />
From [https://www.kernel.org/doc/Documentation/networking/bonding.txt kernel documentation]:<br />
<br />
:''The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical "bonded" interface. The behavior of the bonded interfaces depends on the mode. Generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed.''<br />
<br />
==== Load balancing ====<br />
<br />
To use bonding with netctl, additional package from official repositories is required: {{Pkg|ifenslave}}.<br />
<br />
Copy {{ic|/etc/netctl/examples/bonding}} to {{ic|/etc/netctl/bonding}} and edit it, for example:<br />
<br />
{{hc|/etc/netctl/bonding|2=<br />
Description='Bond Interface'<br />
Interface='bond0'<br />
Connection=bond<br />
BindsToInterfaces=('eth0' 'eth1')<br />
IP=dhcp<br />
IP6=stateless}}<br />
<br />
Now you can disable your old configuration and set ''bonding'' to be started automatically. Switch to the new profile, for example:<br />
<br />
# netctl switch-to bonding<br />
<br />
{{Note|This uses the round-robin policy, which is the default for the {{ic|bonding}} driver. See [https://www.kernel.org/doc/Documentation/networking/bonding.txt official documentation] for details.}}<br />
<br />
{{Tip|To check the status and bonding mode: {{bc|$ cat /proc/net/bonding/bond0}}}}<br />
<br />
==== Wired to wireless failover ====<br />
This example describes how to use ''bonding'' to fallback to wireless when the wired ethernet goes down. This is most useful when both the wired and wireless interface will be connected to the same network. Your wireless router/access point must be configured in ''bridge'' mode.<br />
<br />
You will need additional packages from the official repositories: {{Pkg|ifenslave}} and {{Pkg|wpa_supplicant}}.<br />
<br />
Fisrt enable the bonding module to be loaded upon boot time, as instructed on [[Kernel modules#Loading]]:<br />
<br />
{{hc|/etc/modules-load.d/bonding.conf|2=<br />
bonding<br />
}}<br />
<br />
Then, configure the options of the {{ic|bonding}} driver to use {{ic|active-backup}} and configure the {{ic|primary}} parameter to the device you want to be the active one (normally the wired interface). Also, be sure to use the same device name as returned when running {{ic|ip link}}:<br />
<br />
{{hc|/etc/modprobe.d/bonding.conf|2=<br />
options bonding mode=active-backup miimon=100 primary=eth0 max_bonds=0<br />
}}<br />
<br />
The {{ic|miimon}} option is needed, for the link failure detection. The {{ic|max_bonds}} option avoids the {{ic|Interface bond0 already exists}} error. More information can be obtained on the [https://www.kernel.org/doc/Documentation/networking/bonding.txt kernel documentation].<br />
<br />
Next, configure a netctl profile to enslave the two hardware interfaces. Use the name of all the devices you want to enslave. If you have more than two wired or wireless interfaces, you can enslave all of them on a bond interface. But, for most cases you will have only two devices, a wired and a wireless one:<br />
<br />
{{hc|/etc/netctl/failover|2=<br />
Description='A wired connection with failover to wireless'<br />
Interface='bond0'<br />
Connection=bond<br />
BindsToInterfaces=('eth0' 'wlan0')<br />
IP='dhcp'<br />
}}<br />
<br />
Disable any other profiles (specially a wired or wireless) you had enabled before and then enable the failover profile on startup:<br />
<br />
# netctl enable failover<br />
<br />
Now you need to configure ''wpa_supplicant'' to connect to any know network you wish. You should create a file for each interface and enable it on systemd. Create the following file with this content:<br />
<br />
{{hc|/etc/wpa_supplicant/wpa_supplicant-wlan0.conf|2=<br />
ctrl_interface=/run/wpa_supplicant<br />
update_config=1<br />
}}<br />
<br />
And append to the end of this file any networks you want to connect:<br />
<br />
network={<br />
ssid="SSID"<br />
psk=PSK<br />
}<br />
<br />
To generate the obfuscated PSK you can run ''wpa_passphrase'' as on the [[WPA supplicant#Connecting with wpa_passphrase]] page.<br />
<br />
Now, enable the {{ic|wpa_supplicant}} service on the network interface:<br />
<br />
# systemctl enable wpa_supplicant@wlan0<br />
<br />
You can try now to reboot your machine and see if your configuration worked.<br />
<br />
{{Note|If you get this error on boot bonding:<br />
<br />
wlan0 is up - this may be due to an out of date ifenslave<br />
<br />
Then this is happening because the ''wpa_supplicant'' is being run before the {{ic|failover}} netctl profile. This happens because [[systemd]] runs everything in parallel, unless told otherwise. ''ifenslave'' need all the interfaces to be down before bonding them to the {{ic|bond0}} interface. And, since the ''wpa_supplicant'' need to put the interface up to be able to scan for networks, this might cause the interface to not be enslaved and your bonding to only have the wired interface.<br />
<br />
If this is your case, then you will need to setup a custom dependency on the {{ic|wpa_supplicant@wlan0}} service in relation with the {{ic|netctl@failover}} profile. More specifically, the ''wpa_supplicant'' must be started '''after''' the netctl profile. To accomplish this, create a custom dependency file based on the instructions provided here: [[systemd#Handling dependencies]]<br />
<br />
{{hc|/etc/systemd/system/wpa_supplicant@wlan0.service.d/customdependency.conf|2=<br />
[Unit]<br />
After=netctl@failover.service<br />
}}<br />
<br />
After that you can try to reboot your system again and see if it works. You can check the status of your bonding by running:<br />
<br />
# journalctl -u netctl@failover.service<br />
<br />
And:<br />
<br />
# ip link<br />
<br />
You should see something like this:<br />
<br />
1: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000<br />
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff<br />
2: wlan0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP mode DORMANT group default qlen 1000<br />
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff<br />
3: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default <br />
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff<br />
}}<br />
<br />
Now, you can test your failover setup, by initiating a big download. Unplug your wired interface. Your download should keep going over the wireless interface. Then, plug your wired interface again and it should keep working. You can debug with the following comands:<br />
<br />
# journalctl -u netctl@failover.service<br />
<br />
And:<br />
<br />
# journalctl -u wpa_supplicant@wlan0.service<br />
<br />
=== Using any interface ===<br />
In some cases it may be desirable to allow a profile to use any interface on the system. A common example use case is using a common disk image across many machines with differing hardware (this is especially useful if they are headless). If you use the kernel's naming scheme, and your machine has only one ethernet interface, you can probably guess that eth0 is the right interface. If you use udev's [http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ Predictable Network Interface Names], however, names will be assigned based on the specific hardware itself (e.g. enp1s0), rather than simply the order that the hardware was detected (e.g. eth0, eth1). This means that a netctl profile may work on one machine and not another, because they each have different interface names.<br />
<br />
A quick and dirty solution is to make use of the {{ic|/etc/netctl/interfaces/}} directory. Choose a name for your interface alias ({{ic|en-any}} in this example), and write the following to a file with that name (making sure it is executable).<br />
{{hc|/etc/netctl/interfaces/en-any|<nowiki><br />
#!/bin/bash<br />
for interface in /sys/class/net/en*; do<br />
break;<br />
done<br />
Interface=$(basename $interface)<br />
echo "en-any: using interface $Interface";<br />
</nowiki>}}<br />
Then create a profile that uses the interface. Pay special attention to the {{ic|Interface}} directive. The rest are only provided as examples.<br />
{{hc|/etc/netctl/wired|<nowiki><br />
Description='Wired'<br />
Interface=en-any<br />
Connection=ethernet<br />
IP=static<br />
Address=('192.168.1.15/24')<br />
Gateway='192.168.1.1'<br />
DNS=('192.168.1.1')<br />
</nowiki>}}<br />
<br />
When the {{ic|wired}} profile is started, any machine using the two files above will automatically bring up and configure the first ethernet interface found on the system, regardless of what name udev assigned to it. Note that this is not the most robust way to go about configuring interfaces. If you use multiple interfaces, netctl may try to assign the same interface to them, and will likely cause a disruption in connectivity. If you do not mind a more complicated solution, {{ic|netctl-auto}} is likely to be more reliable.<br />
<br />
=== Using hooks ===<br />
<br />
netctl supports hooks in {{ic|/etc/netctl/hooks/}} and per interface hooks in {{ic|/etc/netctl/interfaces/}}. You can set any option in a hook/interface that you can<br />
in a profile. They are read the same way! Most importantly this includes {{ic|ExecUpPost}} and {{ic|ExecDownPre}}. <br />
<br />
When a profile is read, netctl sources ''all executable'' scripts in {{ic|hooks}}, then it reads the profile file for the connection and finally it sources an executable script with the name of the interface used in the profile from the {{ic|interfaces}} directory. Therefore, declarations in an interface script override declarations in the profile, which override declarations in hooks. <br />
<br />
The variables {{ic|$INTERFACE}}, {{ic|$SSID}}, {{ic|$ACTION}} and {{ic|$Profile}} are available in hooks/interfaces '''only''' when using {{ic|netctl-auto}} <br />
<br />
==== Examples ====<br />
<br />
===== Execute commands on established connection =====<br />
{{hc|/etc/netctl/hooks/myservices|<nowiki><br />
#!/bin/sh<br />
ExecUpPost="systemctl start crashplan.service; systemctl start dropbox@<username>.service"<br />
ExecDownPre="systemctl stop crashplan.service; systemctl stop dropbox@<username>.service"<br />
</nowiki>}}<br />
<br />
===== Activate network-online.target =====<br />
<br />
{{hc|/etc/netctl/hooks/status|<nowiki><br />
#!/bin/sh<br />
ExecUpPost="systemctl start network-online.target"<br />
ExecDownPre="systemctl stop network-online.target"<br />
</nowiki>}} <br />
<br />
Using this, systemd services requiring an active network connection can be [[Systemd#Handling_dependencies|ordered]] to start only after the {{ic|network-online.target}} is reached, and can be stopped before the connection is brought down. <br />
<br />
===== Set default DHCP client =====<br />
<br />
To set or change the DHCP client used for all profiles: <br />
<br />
{{hc|/etc/netctl/hooks/dhcp|<nowiki><br />
#!/bin/sh<br />
DHCPClient='dhclient'<br />
</nowiki>}}<br />
<br />
Alternatively, it may also be specified for a specific network interface by creating an executable file {{ic|/etc/netctl/interfaces/<interface>}} with the following line:<br />
<br />
DHCPClient='dhclient'<br />
<br />
{{Expansion|It would be useful to replace the example with a general hook that executes different actions depending on {{ic|$ACTION}} being CONNECT and DISCONNECT.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Job for netctl@wlan(...).service failed ===<br />
<br />
Some people have an issue when they connect to a network with ''netctl'', for example:<br />
<br />
{{hc|# netctl start wlan0-ssid|<nowiki><br />
Job for netctl@wlan0\x2ssid.service failed. See 'systemctl status netctl@wlan0\x2ssid.service' and 'journalctl -xn' for details.<br />
</nowiki>}}<br />
<br />
When then looking at {{ic|journalctl -xn}}, either of the following are shown:<br />
<br />
1. If your device ({{ic|wlan0}} in this case) is up:<br />
network[2322]: The interface of network profile 'wlan0-ssid' is already up<br />
<br />
Setting the interface down should resolve the problem:<br />
# ip link set wlan0 down<br />
<br />
Then retry:<br />
# netctl start wlan0-ssid<br />
<br />
{{Accuracy|The following is an unsolved issue, using different DHCP client is just a poor/unexplained workaround.}}<br />
<br />
2. If it is down:<br />
dhcpcd[261]: wlan0: ipv4_sendrawpacket: Network is down<br />
<br />
One way to solve this is to use a different DHCP client, for example {{Pkg|dhclient}}. After installing the package configure ''netctl'' to use it:<br />
<br />
{{hc|/etc/netctl/wlan0-ssid|<nowiki><br />
...<br />
DHCPClient='dhclient'<br />
</nowiki>}}<br />
<br />
Adding the {{ic|ForceConnect}} option may also be helpful:<br />
<br />
{{hc|/etc/netctl/wlan0-ssid|<nowiki><br />
<br />
...<br />
<br />
ForceConnect=yes<br />
</nowiki>}}<br />
<br />
Save it and try to connect with the profile:<br />
# netctl start wlan0-ssid<br />
<br />
=== dhcpcd: ipv4_addroute: File exists ===<br />
<br />
On some systems dhcpcd in combination with netctl causes timeout issues on resume, particularly when having switched networks in the meantime. netctl will report that you are successfully connected but you still receive timeout issues. In this case, the old default route still exists and is not being renewed. A workaround to avoid this misbehaviour is to switch to [[#Set default dhcp client for all profiles|dhclient]] as the default dhcp client. More information on the issue can be found [https://bbs.archlinux.org/viewtopic.php?pid=1399842#p1399842 here].<br />
<br />
=== DHCP timeout issues ===<br />
<br />
If you are having timeout issues when requesting leases via DHCP you can set the timeout value higher than netctl's 30 seconds by default. Create a file in {{ic|/etc/netctl/hooks/}} or {{ic|/etc/netctl/interfaces/}}, add {{ic|1=TimeoutDHCP=40}} to it for a timeout of 40 seconds and make the file executable.<br />
<br />
=== Connection timeout issues ===<br />
<br />
If you are having timeout issues that are unrelated to DHCP (on a static ethernet connection for example), and are experiencing errors similar to the following when starting your profile:<br />
{{hc|# journalctl _SYSTEMD_UNIT&#61;netctl@''profile''.service|<br />
Starting network profile &#39;''profile''&#39;...<br />
No connection found on interface 'eth0' (timeout)<br />
Failed to bring the network up for profile &#39;''profile''&#39;<br />
}}<br />
Then you should increase carrier and up timeouts by adding {{ic|1=TimeoutUp=}} and {{ic|1=TimeoutCarrier=}} to your profile file:<br />
{{hc|/etc/netctl/''profile''|<nowiki><br />
...<br />
TimeoutUp=300<br />
TimeoutCarrier=300</nowiki><br />
}}<br />
Do not forget to reenable your profile:<br />
<br />
# netctl reenable ''profile''<br />
<br />
=== Problems with netctl-auto on resume ===<br />
Sometimes ''netctl-auto'' fails to reconnect when the system resumes from suspend. An easy solution is to restart the service for ''netctl-auto''. <br />
This can be automated with an additional service like the following:<br />
<br />
{{hc|/etc/systemd/system/netctl-auto-resume@.service|<nowiki><br />
[Unit]<br />
Description=restart netctl-auto on resume.<br />
Requisite=netctl-auto@%i.service<br />
After=suspend.target<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/usr/bin/systemctl restart netctl-auto@%i.service<br />
<br />
[Install]<br />
WantedBy=suspend.target<br />
</nowiki>}}<br />
<br />
To [[systemd#Using units|enable]] this service for your wireless card, for example, run {{ic|systemctl enable netctl-auto-resume@wlan0.service}} as root. Change {{ic|wlan0}} to the required network interface.<br />
<br />
== See also ==<br />
<br />
* [https://bbs.archlinux.org/viewtopic.php?id=157670 Official announcement thread]<br />
* There is a cinnamon applet available in the AUR: {{AUR|cinnamon-applet-netctl-systray-menu}}</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=371621Systemd-nspawn2015-04-28T09:15:26Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
<br />
== Installation ==<br />
<br />
''systemd-nspawn'' is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container. At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you do not need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that is it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times. The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' is a template unit that expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
<br />
{{Tip|<br />
* Instead of moving your container, as above, you can just ''symlink'' it to where it is expected to be,<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
To customize the startup of a container, add ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
<br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
<br />
== Management ==<br />
<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectl poweroff MyContainer}}<br />
<br />
{{Tip| shutdown and reboot operations can be performed from within a container session using the systemd {{ic|reboot}} and {{ic|shutdown}} commands}}<br />
<br />
=== systemd toolchain ===<br />
<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide a {{ic|1=-M, --machine=}} option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
<br />
=== Networking ===<br />
<br />
The examples above will give the container a workable network, with no extra configuration needed. <br />
<br />
You can describe more complex networks using [[systemd-networkd]].<br />
<br />
==== Examples ====<br />
<br />
{{Expansion| This section needs some good example network setups}}<br />
<br />
=== Running on a non-systemd system ===<br />
<br />
See [[Init#systemd-nspawn]].<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
remove {{ic|/etc/securetty}} from the '''container''' filesystem. See [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939].<br />
<br />
== See also ==<br />
<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Samba/Tips_and_tricks&diff=371620Samba/Tips and tricks2015-04-28T09:14:39Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register, typo, spelling</p>
<hr />
<div>{{Related articles start}}<br />
{{Related|NFS}}<br />
{{Related|Samba Domain Controller}}<br />
{{Related|Active Directory Integration}}<br />
{{Related articles end}}<br />
[[Category:Networking]]<br />
{{Merge|Samba|I cannot see any reason why this section must be separate from the main article.}}<br />
==Sample configuration==<br />
The following simple configuration file allows for a quick and easy setup to share any number of directories, as well as easy browsing from Windows clients.<br />
<br />
See {{ic|man smb.conf}} for details and explanation of configuration options. Here is an [http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html online version].<br />
<br />
{{hc|/etc/samba/smb.conf|<nowiki><br />
[global]<br />
workgroup = WORKGROUP<br />
server string = Samba Server<br />
netbios name = SERVER<br />
name resolve order = bcast host<br />
dns proxy = no<br />
<br />
log file = /var/log/samba/%m.log<br />
<br />
create mask = 0664<br />
directory mask = 0775<br />
<br />
force create mode = 0664<br />
force directory mode = 0775<br />
<br />
; One may be interested in the following setting:<br />
;force group = +nas<br />
<br />
[media1]<br />
path = /media/media1<br />
read only = No<br />
<br />
[media2]<br />
path = /media/media2<br />
read only = No<br />
<br />
[media3]<br />
path = /media/media3<br />
read only = No<br />
</nowiki>}}<br />
<br />
Remember to {{ic|testparm -s}} and {{ic|systemctl restart smbd nmbd}} after editing configuration files.<br />
<br />
==Share files without a username and password==<br />
Edit {{ic|/etc/samba/smb.conf}} and add the following line:<br />
{{bc|<nowiki>map to guest = Bad User</nowiki>}}<br />
<br />
After this line:<br />
{{bc|<nowiki>security = user</nowiki>}}<br />
<br />
Restrict the shares data to a specific interface replace:<br />
{{bc|<nowiki>; interfaces = 192.168.12.2/24 192.168.13.2/24</nowiki>}}<br />
<br />
with:<br />
<br />
{{bc|<nowiki><br />
interfaces = lo eth0<br />
bind interfaces only = true</nowiki>}}<br />
<br />
Optionally edit the account that access the shares, edit the following line:<br />
{{bc|<nowiki>; guest account = nobody</nowiki>}}<br />
<br />
For example:<br />
{{bc|<nowiki> guest account = pcguest</nowiki>}}<br />
<br />
And do something in the likes of:<br />
{{bc|<nowiki># useradd -c "Guest User" -d /dev/null -s /bin/false pcguest</nowiki>}}<br />
<br />
Then setup a "" password for user pcguest.<br />
<br />
The last step is to create share directory (for write access make writable = yes):<br />
<br />
{{bc|<nowiki><br />
[Public Share]<br />
path = /path/to/public/share<br />
available = yes<br />
browsable = yes<br />
public = yes<br />
writable = no<br />
</nowiki>}}<br />
<br />
{{note|Make sure the guest also has permission to visit /path, /path/to and /path/to/public, according to [http://unix.stackexchange.com/questions/13858/do-the-parent-directorys-permissions-matter-when-accessing-a-subdirectory http://unix.stackexchange.com/questions/13858/do-the-parent-directorys-permissions-matter-when-accessing-a-subdirectory]}}<br />
<br />
=== Sample Passwordless Configuration ===<br />
This is the configuration I use with samba 4 for easy passwordless filesharing with family on a home network. Change any options needed to suit your network (workgroup and interface). I'm restricting it to the static IP I have on my ethernet interface, just delete that line if you do not care which interface is used.<br />
{{hc|/etc/samba/smb.conf|<nowiki><br />
[global]<br />
<br />
workgroup = WORKGROUP<br />
<br />
server string = Media Server<br />
<br />
security = user<br />
map to guest = Bad User<br />
<br />
log file = /var/log/samba/%m.log<br />
<br />
max log size = 50<br />
<br />
<br />
interfaces = 192.168.2.194/24<br />
<br />
<br />
dns proxy = no <br />
<br />
<br />
[media]<br />
path = /shares<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
<br />
[storage]<br />
path = /media/storage<br />
public = yes<br />
only guest = yes<br />
writable = yes<br />
</nowiki>}}<br />
<br />
== Samba Security ==<br />
An extra layer of security can be obtainded by restricting your acceptable networks:<br />
<br />
{{hc|/etc/samba/smb.conf|<nowiki><br />
hosts deny = 0.0.0.0/0<br />
hosts allow = xxx.xxx.xxx.xxx/xx yyy.yyy.yyy.yyy/yy </nowiki>}}<br />
<br />
If you are behind a firewall, make sure to open the ports Samba uses:<br />
{{bc|<br />
UDP/137 - used by nmbd<br />
UDP/138 - used by nmbd<br />
TCP/139 - used by smbd<br />
TCP/445 - used by smbd}}<br />
<br />
So a series of commands like this should suffice:<br />
{{bc|<br />
# iptables -A INPUT -p tcp --dport 139 -j ACCEPT<br />
# iptables -A INPUT -p tcp --dport 445 -j ACCEPT<br />
# iptables -A INPUT -p udp --sport 137 -j ACCEPT<br />
# iptables -A INPUT -p udp --dport 137 -j ACCEPT<br />
# iptables -A INPUT -p udp --dport 138 -j ACCEPT<br />
}}<br />
<br />
If you are basing your firewall upon Arch Linux's [[Simple stateful firewall]], just substitute the INPUT chain for the correspondent TCP and UDP chains.<br />
<br />
== Adding network shares using KDE4 GUI ==<br />
How to configure the folder sharing in KDE4. Simple file sharing limits user shared folders to their home directory and read-only access. Advanced file sharing gives full semantics of Samba with no limits to shared folders but requires su or sudo root permissions.<br />
<br />
== Discovering network shares ==<br />
If nothing is known about other systems on the local network, and automated tools such as [[Samba#smbnetfs|smbnetfs]] are not available, the following methods allow one to manually probe for Samba shares.<br />
<br />
1. First, install {{Pkg|nmap}} and {{Pkg|smbclient}} using [[pacman]]:<br />
# pacman -S nmap smbclient<br />
<br />
2. {{ic|nmap}} checks which ports are open:<br />
# nmap -p 139 -sT 192.168.1.*<br />
<br />
In this case, a scan on the 192.168.1.* IP address range and port 139 has been performed, resulting in:<br />
{{hc<br />
|$ nmap -sT 192.168.1.*<br />
|Starting nmap 3.78 ( http://www.insecure.org/nmap/ ) at 2005-02-15 11:45 PHT<br />
Interesting ports on 192.168.1.1:<br />
(The 1661 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
'''139/tcp open netbios-ssn'''<br />
5000/tcp open UPnP<br />
<br />
Interesting ports on 192.168.1.5:<br />
(The 1662 ports scanned but not shown below are in state: closed)<br />
PORT STATE SERVICE<br />
6000/tcp open X11<br />
<br />
Nmap run completed -- 256 IP addresses (2 hosts up) scanned in 7.255 seconds<br />
}}<br />
<br />
The first result is another system; the second happens to be the client from where this scan was performed.<br />
<br />
3. Now that systems with port 139 open are revealed, use {{ic|nmblookup}} to check for NetBIOS names: <br />
{{hc<br />
|$ nmblookup -A 192.168.1.1<br />
|Looking up status of 192.168.1.1<br />
PUTER <00> - B <ACTIVE><br />
HOMENET <00> - <GROUP> B <ACTIVE><br />
PUTER <03> - B <ACTIVE><br />
'''PUTER <20> - B <ACTIVE>'''<br />
HOMENET <1e> - <GROUP> B <ACTIVE><br />
USERNAME <03> - B <ACTIVE><br />
HOMENET <1d> - B <ACTIVE><br />
MSBROWSE <01> - <GROUP> B <ACTIVE><br />
}}<br />
<br />
Regardless of the output, look for '''<20>''', which shows the host with open services.<br />
<br />
4. Use {{ic|smbclient}} to list which services are shared on ''PUTER''. If prompted for a password, pressing enter should still display the list:<br />
{{hc<br />
|$ smbclient -L \\PUTER<br />
|<nowiki><br />
Sharename Type Comment<br />
--------- ---- -------<br />
MY_MUSIC Disk<br />
SHAREDDOCS Disk<br />
PRINTER$ Disk<br />
PRINTER Printer<br />
IPC$ IPC Remote Inter Process Communication<br />
<br />
Server Comment<br />
--------- -------<br />
PUTER<br />
<br />
Workgroup Master<br />
--------- -------<br />
HOMENET PUTER<br />
</nowiki>}}<br />
<br />
This shows which folders are shared and can be mounted locally. See: [[#Accessing shares]]<br />
<br />
== Remote control of Windows computer ==<br />
Samba offers a set of tools for communication with Windows. These can be handy if access to a Windows computer through remote desktop is not an option, as shown by some examples.<br />
<br />
Send shutdown command with a comment:<br />
<br />
$ net rpc shutdown -C "comment" -I IPADDRESS -U USERNAME%PASSWORD<br />
A forced shutdown instead can be invoked by changing -C with comment to a single -f. For a restart, only add -r, followed by a -C or -f.<br />
<br />
Stop and start services:<br />
<br />
$ net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD<br />
<br />
To see all possible net rpc command:<br />
<br />
$ net rpc<br />
<br />
== Block certain file extensions on samba share ==<br />
Samba offers an option to block files with certain patterns, like file extensions. This option can be used to prevent dissemination of viruses or to dissuade users from wasting space with certain files:<br />
<br />
Veto files = /*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/*.avi/*.mp4/*.wmv/*.wma/<br />
<br />
== Samba 4.* : Password Complexity ==<br />
<br />
Samba 4 requires strong password when adding new user with pdbedit. If you want to disable the complexity check, just use the follwing command:{{bc|<br />
# samba-tool domain passwordsettings set --complexity&#61;off<br />
}}<br />
<br />
== Build Samba without CUPS ==<br />
<br />
Just build without cups installed. From the [https://wiki.samba.org/index.php/Samba_as_a_print_server Samba Wiki]:<br />
<blockquote>Samba has built-in support [for CUPS] and defaults to CUPS if the development package (aka header files and libraries) could be found at compile time.</blockquote><br />
<br />
Of course, modifications to the PKGBUILD will also be necessary: libcups will have to be removed from the depends and makedepends arrays and other references to cups and printing will need to be deleted. In the case of the 4.1.9-1 PKGBUILD, 'other references' includes lines 169, 170 and 236:<br />
{{bc|<br />
mkdir -p ${pkgdir}/usr/lib/cups/backend<br />
ln -sf /usr/bin/smbspool ${pkgdir}/usr/lib/cups/backend/smb<br />
install -d -m1777 ${pkgdir}/var/spool/samba<br />
}}</div>Infinitehhttps://wiki.archlinux.org/index.php?title=League_of_Legends&diff=371619League of Legends2015-04-28T09:12:28Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Gaming]]<br />
[[Category:Wine]]<br />
{{Poor writing|Style problems, little overview - see [[Help:Style]]}}<br />
There is currently only a Mac OS and a Windows version of LoL. This page outlines working methods to get the Windows League of Legends version working on your arch system through Wine.<br />
<br />
'''This guide was last tested with:'''<br />
<br />
''Arch Linux Kernel:'' '''3.15.5-1-ARCH'''<br />
<br />
''Wine Version:'' '''1.7.22'''<br />
<br />
''LoL Version:'' '''4.12.14_07_14_16_36'''<br />
<br />
'''Issues:'''<br />
* Icons for runes in the launcher store do not appear<br />
* Most button textures in the launcher store are missing (but the buttons do work)<br />
* Right clicking friends in the friend list (to invite to a game) does not work (this issue can be circumvented by using the invite button in the lobby)<br />
** [https://bugs.winehq.org/show_bug.cgi?id=35701#c5 Another workaround] to this issue is to mouse over your friend, press down right mouse button, press down left mouse button, release left mouse button, and then release right mouse button.<br />
* Lesser performance than running the game on windows<br />
* In a 64-bit Wine prefix the Patcher will be black (but pressing buttons will work) and launching a match will end up in a black screen.<br />
* The installer hangs when it should start the installation<br />
* The Basic Tutorial does not work.<br />
<br />
== PlayonLinux Method ==<br />
<br />
This is the easiest method. Just install {{Pkg|playonlinux}}. <br />
<br />
After installation run from the command line<br />
$ playonlinux<br />
<br />
When you first run it, playonlinux will install some necessary fonts. Afterwards, click Install, check the "testing box" and<br />
then search for "League of Legends". The rest is self-explanatory. <br />
<br />
=== Troubleshooting ===<br />
<br />
* '''Bugsplat opening patcher:''' To fix this you need to configure the PlayOnLinux's wine version by clicking the configure gear, change wine version to system from 1.7-LeagueOfLegends and if you have not done so already install {{Pkg|lib32-libldap}}.<br />
<br />
* '''Adobe air missing:''' To fix this you need to install {{Pkg|lib32-lcms2}}.<br />
<br />
* '''The login server did not respond:'''<br />
PlayOnLinux seem to be missing a symlink from the generic version of {{Pkg|libgcrypt}} to the specific version it ships.<br />
That can be fixed by finding the folders of the affected Wine versions and creating the links manually.<br />
Replace ARCH with either x86 or amd64, and VERSION with the Wine version you intend to fix.<br />
<br />
# cd ~/.PlayOnLinux/wine/linux-ARCH/VERSION/lib<br />
# ln -s libgcrypt.so.11.* libgcrypt.so.11<br />
# ln -s libgcrypt.so.11 libgcrypt.so<br />
<br />
If you are still unable to login after setting up the above symlinks, {{Pkg|lib32-gnutls}} may need to be manually installed or re-installed.<br />
<br />
* '''No sounds:''' install {{Pkg|lib32-alsa-lib}} (for pulseaudio users:{{Pkg|lib32-libpulse}})<br />
<br />
* '''Store (for runes) is all black:''' [http://forums.eune.leagueoflegends.com/board/showthread.php?t=571456 install IE8] in the PlayOnLinux components.<br />
<br />
* '''Crash after champ select:''' [http://www.playonlinux.com/en/topic-11344-1.html install directx9] in the PlayOnLinux components.<br />
<br />
== Wine Method ==<br />
<br />
{{Note| The guide is written mostly for x86_64 systems, if your architecture is i686, you can skip setting up the new Wine Prefix (Just use the default wine prefix instead: .wine). You can also ignore WINEARCH/WINEPREFIX parts of commands· And to you, "lib32-lcms2" would just be "lcms2"}} <br />
{{Warning|The installer does not currently seem to be working in Wine}}<br />
=== Create a 32-bit Wine PREFIX ===<br />
{{Tip|There is an experimental higher d3d performance [https://aur.archlinux.org/packages/wine-d3dstream-git/ patched version of wine] available in AUR, the performance boost it offers requires adding a registry key with regedit in Wine. I see my framerate go from 160 to 240 with this feature enabled, that is a solid +50% increase in framerate. See more at the bottom of the page.}}<br />
Install {{Pkg|wine}} on your system and run:<br />
<br />
# WINEARCH=win32 WINEPREFIX=$HOME/.wine32 winecfg<br />
to create a default 32-bit prefix at $HOME/.wine. If it asks to install something (like Wine Mono or Wine Gecko or some such) just always click install. After this make sure Windows Version is set to Windows XP.<br />
<br />
=== Install the dependencies ===<br />
<br />
Install the required packages on your system: <br />
* {{Pkg|lib32-alsa-lib}} (for pulseaudio users:{{Pkg|lib32-libpulse}})<br />
* {{Pkg|lib32-libldap}} <br />
* {{Pkg|lib32-lcms2}} <br />
* {{Pkg|lib32-gnutls}} <br />
* {{Pkg|winetricks}}<br />
<br />
Install the following windows components using winetricks:<br />
<br />
# WINEARCH=win32 WINEPREFIX=$HOME/.wine32 winetricks d3dx9 vcrun2005 wininet corefonts adobeair ie8<br />
<br />
If you run into problems installing adobeair, you need to make a little change in your Winecfg.<br />
<br />
# WINEARCH=win32 WINEPREFIX=$HOME/.wine32 winecfg<br />
<br />
Access the libraries tab, find in the list of existing libraries (or add a new entry for it if it does not exist) '''dnsapi''', click Edit... and configure it for "'''Native then Builtin'''"<br />
<br />
=== Installation ===<br />
The installer is currently not working for me in Wine, but the command to execute it if you want to try would be the following:<br />
<br />
# GC_DONT_GC=1 WINEARCH=win32 WINEPREFIX=$HOME/.wine32 wine /path/to/installer.exe<br />
<br />
==== Get your hands on an installed copy of the game ====<br />
There are several ways to do this, the Windows version (as long as it can run the Installer which probably requires Windows XP or newer) here are a few methods.<br />
<br />
* Get access to a physical Windows based machine, in your home or at your neighbors/friends place, bring a 8GB USB flash drive or external HDD with you and install the game on it. (If you do not have a 16GB flash drive you can use a smaller one and make a few round trips after installing the game on the HDD instead.)<br />
<br />
* Install a virtualization software (like Virtualbox or VMWare Player) and set up a Windows installation inside of it. Make sure it has a network connection, then install League of Legends on it, set up a shared folder between the VM and the host machine, and move the League of Legends installation into it, then from the Host system you can proceed to the next step and move the installation from the shared folder into your Wine Prefix.<br />
<br />
* If you already have a Dual-Boot setup, you can just install League of Legends onto the Windows installation, load the hard drive to Linux (requires {{Pkg|ntfs-3g}}, may also require you to set the exec option in /etc/fstab for the drive) then proceed to the next step and symlink the folder from your Windows drive to your Wine Prefix.<br />
<br />
* See if the installer works with {{Pkg|playonlinux}}. If it does then install it, move the folder from the playonlinux wineprefix to the wine32 prefix and uninstall playonlinux again (or keep it if you would like)<br />
<br />
After you get your hands on the game, either move or symlink it to your wine32 prefix, using either of these commands (assuming you have a dual boot setup and your windows partition is mounted at /mnt/windows, or you have the game on a USB flash drive mounted at /media/removable):<br />
<br />
# ln -s /mnt/windows/Riot\ Games/ $HOME/.wine32/drive_c/<br />
# mv /media/removable/Riot\ Games/ $HOME/.wine32/drive_c/<br />
<br />
==== Compatibility Steps ====<br />
<br />
*'''Hostname''' (Fixes the game failing to run after Champion Select screen)<br />
<br />
First you will want to find your hostname.<br />
# cat /etc/hostname<br />
<br />
Then you will want to make sure your /etc/hosts file uses your hostname over localhost, you can do this by opening /etc/hosts with an editor of your choice.<br />
# nano /etc/hosts<br />
<br />
Then replace all mentions of localhost with the hostname you got from the first command (this change requires a system restart, without this your game will fail after champion select with a "Bad Window" error)<br />
<br />
*'''Texture Patch''' (Fixes in-game store crashing the game when it is opened)<br />
<br />
You now need to patch away the mipmaps of the in-game shop icons. An alternative method is to patch [http://pastebin.com/xSNJjkMY Wine itself].<br />
<br />
'''Note''': A better method has been suggested which would be to edit the .../Config/Game.cfg and under the [General] section add "x3d_platform=1" along with the other options instead of patching either wine or the texture files, however since I already have patched textures I cannot test this presently, if anyone can confirm that doing this will allow you to open the in-game store without the game crashing, please update this section.<br />
<br />
Download <br />
<br />
[https://github.com/A-Metaphysical-Drama/LoL-Linux-Tools/ LoL-Linux-Tools]<br />
<br />
Extract the file to a location of your choosing, then edit config.py with an editor of your choice and set an absolute path.<br />
lol_path = '/home/USERNAME/.wine32/drive_c/Riot Games/League of Legends/'<br />
<br />
Then execute the patch with<br />
# python2 lol_linux.py texture_patch<br />
<br />
If all went well, you will see an output explaning what the patch is doing (unpacking a bunch of dds files from an archive, patching out the mipmaps in them, archiving them again, and then it will be done, this takes a few)<br />
And now your LoL client should finally be working!<br />
<br />
{{Warning|If you use this Texture Patch rather than patching Wine itself for compatibility with the original store icons, you will need to apply the patch again every time the game is updated. This is because if Riot Games add new icons or change existing ones, they will not be compatible with Wine anymore.}}<br />
You can create an alias in .bashrc to automate this process a bit.<br />
alias lol-update='python2 $HOME/.lol_patch/lol_linux.py texture_patch'<br />
The patch will only take long to finish the first time you run it, as it does not need to patch all of the files again, only the ones that are new or have changed.<br />
<br />
=== Run the Game ===<br />
<br />
Create an alias to execute the 32-bit Wine installation (in ~/.bashrc) this is not really a required step, but just a good practice since you can use this to run other programs that play better with a 32-bit wine prefix than a 64-bit one.<br />
# alias wine32='env WINEARCH=win32 WINEPREFIX="$HOME/.wine32" wine'<br />
<br />
The above alias will work with winecfg, it will however not work with winetricks (to run winetricks you need to do it like done formerly in this guide)<br />
<br />
Create a bash script or an alias with the following commands:<br />
<br />
Bash script example: '''/bin/leagueoflegends'''<br />
#!/bin/sh<br />
pushd $HOME/.wine32/drive_c/Riot\ Games/League\ of\ Legends/RADS/system/<br />
WINEARCH=win32 WINEPREFIX=$HOME/.wine32 wine rads_user_kernel.exe run lol_launcher $(ls ../projects/lol_launcher/releases/) LoLLauncher.exe<br />
popd<br />
<br />
Make sure to remember to make the file executable<br />
<br />
# chmod +755 /bin/leagueoflegends<br />
<br />
Alias example: '''$HOME/.bashrc'''<br />
# alias League_of_Legends='popd $HOME/.wine32/drive_c/Riot\ Games/League\ of\ Legends/RADS/system/ && wine32 rads_user_kernel.exe run lol_launcher $(ls ../projects/lol_launcher/releases/) LoLLauncher.exe && pushd'<br />
<br />
Shortcut example (if you made a bash script, this can be useful for example if you want to launch the game from steam): '''/usr/share/applications/LeagueofLegends.desktop'''<br />
[Desktop Entry]<br />
Name=League of Legends<br />
Comment=Runs League of Legends through a 32-bit Wine installation.<br />
Exec=/bin/leagueoflegends<br />
Terminal=false<br />
Type=Application<br />
Icon=LoL_Icon.png<br />
Categories=Wine;Game;<br />
<br />
To be able to use an Icon for the application, you need to either convert the '''*/RADS/system/lol.ico''' to the png format (with imagemick or gimp), or download the icon separately and place it in the '''~/.icons/''' folder of your home directory. Here is a [http://img.informer.com/icons/png/48/4719/4719180.png 48x48 icon] you can download.<br />
<br />
Run the bash script/alias/shortcut and you should be good to go! <br />
<br />
To test if the game is working, create a custom Summoner's Rift match with one bot. If it loads and you do not crash upon opening the in-game store, you are golden! Congratulations!<br />
<br />
== Troubleshooting/Tips ==<br />
* In case of flashing minimap or exceedingly low FPS try disabling HUD animations in the in-game options for notable boost in performance.<br />
<br />
* On certain intel cards, enabling vertical sync can lead to a big boost in performance.<br />
<br />
* If the launcher is all black, make sure you have a lib32 version of libgl installed {{Pkg|lib32-mesa-libgl}} {{Pkg|lib32-nvidia-libgl}} {{AUR|lib32-catalyst-utils}}/[[AMD_Catalyst#Installing_from_the_unofficial_repository|lib32-catalyst-libgl]]<br />
<br />
*If the terrain is too dark, one solution would be to install the proprietary drivers of your graphics card.<br />
<br />
*Disabling Anti-Aliasing, Vertical Synchronization and Frame Rate Cap in the in-game options may greatly improve performance for some cards.<br />
<br />
*For further troubleshooting, go to [https://bbs.archlinux.org/viewtopic.php?id=183860 this thread].<br />
<br />
==== For d3dstream patched Wine ====<br />
{{Warning|On some setups users may experience temporary game freezes during gameplay if using this patch, proceed with caution. If this happens to you, you may be better off using the official version of Wine as freezing is not tolerable in competitive games.}}<br />
* You need to add a registry key to Wine in order to apply the performance boost the patch offers, [https://bbs.archlinux.org/viewtopic.php?pid=1321578#p1321578 read this] for more information on how.<br />
<br />
* If you cannot access the launcher store running d3dstream patched wine, you can bypass the problem by running the game from the default 64-bit prefix with the below command, just remember to restart the game before you try to go for another match.<br />
wine .wine32/drive_c/Riot\ Games/League\ of\ Legends/lol.launcher.exe<br />
<br />
==== In-game shop crash ====<br />
<br />
Edit the file {{ic|Config/game.cfg}} and add {{ic|1=x3d_platform=1}} to {{ic|[General]}} section.<br />
<br />
[General]<br />
x3d_platform=1<br />
<br />
This option should switch to the OpenGL renderer.<br />
<br />
{{Warning|This may cause some moderate to severe graphic bugs and blurry textures, depending on setup.}}<br />
<br />
==== Connection Error: connection failure unable to connect to the pvp.net server ====<br />
<br />
Authentication and logging in works, however the connection then fails with the abovementioned error. One possible solution, according to https://appdb.winehq.org/objectManager.php?sClass=version&iId=19141 is disabling TCP timestamps:<br />
<br />
# sysctl -w net.ipv4.tcp_timestamps=0<br />
<br />
For a permanent solution:<br />
<br />
# echo "net.ipv4.tcp_timestamps = 0" > /etc/sysctl.d/10-tcp-timestamps.conf</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Install_Arch_Linux_on_ZFS&diff=371618Install Arch Linux on ZFS2015-04-28T09:09:32Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[ja:ZFS に Arch Linux をインストール]]<br />
{{Related articles start}}<br />
{{Related|ZFS}}<br />
{{Related|Experimenting with ZFS}}<br />
{{Related|ZFS on FUSE}}<br />
{{Related articles end}}<br />
This article details the steps required to install Arch Linux onto a root ZFS filesystem. This article supplements the [[Beginners' guide]].<br />
<br />
== Installation ==<br />
<br />
See [[ZFS#Installation]] for installing the ZFS packages. If installing Arch Linux onto ZFS from the archiso, it would be easier to use the [[Unofficial user repositories#demz-repo-archiso|demz-repo-archiso]] repository.<br />
<br />
=== Embedding archzfs into archiso ===<br />
<br />
See [[ZFS#Embed_the_archzfs_packages_into_an_archiso|ZFS]] article.<br />
<br />
== Partition the destination drive ==<br />
<br />
Review [[Beginners' guide#Prepare_the_storage_drive]] for information on determining the partition table type to use for ZFS. ZFS supports GPT and MBR partition tables.<br />
<br />
ZFS manages its own partitions, so only a basic partition table scheme is required. The partition that will contain the ZFS filesystem should be of the type {{ic|bf00}}, or "Solaris Root".<br />
<br />
=== Partition scheme ===<br />
<br />
Here is an example, using MBR, of a basic partition scheme that could be employed for your ZFS root setup:<br />
<br />
{{bc|<nowiki><br />
Part Size Type<br />
---- ---- -------------------------<br />
1 512M Ext boot partition (8300)<br />
2 XXXG Solaris Root (bf00)</nowiki><br />
}}<br />
<br />
Here is an example using GPT. The BIOS boot partition contains the bootloader.<br />
<br />
{{bc|<nowiki><br />
Part Size Type<br />
---- ---- -------------------------<br />
1 2M BIOS boot partition (ef02)<br />
1 512M Ext boot partition (8300)<br />
2 XXXG Solaris Root (bf00)</nowiki><br />
}}<br />
<br />
An additional partition may be required depending on your hardware and chosen bootloader. Consult [[Beginners' guide#Install_and_configure_a_bootloader]] for more info.<br />
<br />
{{Tip|Bootloaders with support for ZFS are described in [[#Install and configure the bootloader]].}}<br />
{{Warning|Several GRUB bugs ([https://savannah.gnu.org/bugs/?42861 bug #42861], [https://github.com/zfsonlinux/grub/issues/5 zfsonlinux/grub/issues/5]) prevent or complicate installing it on ZFS partitions, use of a separate boot partition is recommended}}<br />
<br />
== Format the destination disk ==<br />
<br />
Format the boot partition as well as any other system partitions. Do not do anything to the Solaris partition nor to the BIOS boot partition. ZFS will manage the first, and your bootloader the second.<br />
<br />
== Setup the ZFS filesystem ==<br />
<br />
First, make sure the ZFS modules are loaded,<br />
<br />
# modprobe zfs<br />
<br />
=== Create the root zpool ===<br />
<br />
# zpool create zroot /dev/disk/by-id/''id-to-partition''<br />
<br />
{{Warning|<br />
* Always use id names when working with ZFS, otherwise import errors will occur.<br />
* The zpool command will normally activate all features. See [[ZFS#GRUB-compatible_pool_creation]] when using [[GRUB]].}}<br />
<br />
=== Create necessary filesystems ===<br />
<br />
If so desired, sub-filesystem mount points such as {{ic|/home}} and {{ic|/root}} can be created with the following commands:<br />
<br />
# zfs create zroot/home -o mountpoint=/home<br />
# zfs create zroot/root -o mountpoint=/root<br />
<br />
Note that if you want to use other datasets for system directories ({{ic|/var}} or {{ic|/etc}} included) your system will not boot unless they are listed in {{ic|/etc/fstab}}! We will address that at the appropriate time in this tutorial.<br />
<br />
=== Swap partition ===<br />
<br />
See [[ZFS#Swap volume]].<br />
<br />
=== Configure the root filesystem ===<br />
<br />
First, set the mount point of the root filesystem:<br />
<br />
# zfs set mountpoint=/ zroot<br />
<br />
and optionally, any sub-filesystems:<br />
<br />
# zfs set mountpoint=/home zroot/home<br />
# zfs set mountpoint=/root zroot/root<br />
<br />
and if you have separate datasets for system directories (ie {{ic|/var}} or {{ic|/usr}})<br />
<br />
# zfs set mountpoint=legacy zroot/usr<br />
# zfs set mountpoint=legacy zroot/var<br />
<br />
and put them in {{ic|/etc/fstab}}<br />
{{hc|/etc/fstab|<br />
# <file system> <dir> <type> <options> <dump> <pass><br />
zroot/usr /usr zfs defaults,noatime 0 0<br />
zroot/var /var zfs defaults,noatime 0 0}}<br />
<br />
Set the bootfs property on the descendant root filesystem so the boot loader knows where to find the operating system.<br />
<br />
# zpool set bootfs=zroot zroot<br />
<br />
Export the pool,<br />
<br />
# zpool export zroot<br />
<br />
{{Warning|Do not skip this, otherwise you will be required to use {{ic|-f}} when importing your pools. This unloads the imported pool.}}<br />
{{Note|This might fail if you added a swap partition above. Need to turn it off with the ''swapoff'' command.}}<br />
<br />
Finally, re-import the pool,<br />
<br />
# zpool import -d /dev/disk/by-id -R /mnt zroot<br />
<br />
{{Note|{{ic|-d}} is not the actual device id, but the {{ic|/dev/by-id}} directory containing the symbolic links.}}<br />
<br />
If there is an error in this step, you can export the pool to redo the command. The ZFS filesystem is now ready to use.<br />
<br />
Be sure to bring the zpool.cache file into your new system. This is required later for the ZFS daemon to start.<br />
<br />
# cp /etc/zfs/zpool.cache /mnt/etc/zfs/zpool.cache<br />
<br />
if you do not have /etc/zfs/zpool.cache, create it:<br />
<br />
# zpool set cachefile=/etc/zfs/zpool.cache zroot<br />
<br />
== Install and configure Arch Linux ==<br />
<br />
Follow the following steps using the [[Beginners' guide]]. It will be noted where special consideration must be taken for ZFSonLinux.<br />
<br />
* First mount any boot or system partitions using the mount command.<br />
<br />
* Install the base system.<br />
<br />
* The procedure described in [[Beginners' guide#Generate an fstab]] is usually overkill for ZFS. ZFS usually auto mounts its own partitions, so we do not need ZFS partitions in {{ic|fstab}} file, unless the user made datasets of system directories. To generate the {{ic|fstab}} for filesystems, use:<br />
# genfstab -U -p /mnt | grep boot >> /mnt/etc/fstab<br />
<br />
* Edit the {{ic|/etc/fstab}}:<br />
<br />
{{Note|<br />
* If you chose to create datasets for system directories, keep them in this {{ic|fstab}}! Comment out the lines for the '{{ic|/}}, {{ic|/root}}, and {{ic|/home}} mountpoints, rather than deleting them. You may need those UUIDs later if something goes wrong.<br />
* Anyone who just stuck with the guide's directions can delete everything except for the swap file and the boot/EFI partition. It seems convention to replace the swap's uuid with {{ic|/dev/zvol/zroot/swap}}.<br />
}}<br />
<br />
* When creating the initial ramdisk, first edit {{ic|/etc/mkinitcpio.conf}} and add {{ic|zfs}} before filesystems. Also, move {{ic|keyboard}} hook before {{ic|zfs}} so you can type in console if something goes wrong. You may also remove fsck (if you are not using Ext3 or Ext4). Your {{ic|HOOKS}} line should look something like this:<br />
HOOKS="base udev autodetect modconf block keyboard zfs filesystems"<br />
<br />
* Regenerate the initramfs with the command:<br />
# mkinitcpio -p linux<br />
<br />
== Install and configure the bootloader ==<br />
<br />
=== For BIOS motherboards ===<br />
<br />
Follow [[GRUB#BIOS_systems_2]] to install GRUB onto your disk. {{ic|grub-mkconfig}} does not properly detect the ZFS filesystem, so it is necessary to edit {{ic|grub.cfg}} manually:<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set timeout=2<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,msdos1)<br />
linux /vmlinuz-linux zfs=zroot rw<br />
initrd /initramfs-linux.img<br />
}<br />
</nowiki>}}<br />
<br />
if you did not create a separate /boot participation, kernel and initrd paths have to be in the following format:<br />
<br />
/dataset/@/actual/path <br />
<br />
Example:<br />
<br />
linux /@/boot/vmlinuz-linux zfs=zroot rw<br />
initrd /@/boot/initramfs-linux.img<br />
=== For UEFI motherboards ===<br />
<br />
Use {{ic|EFISTUB}} and {{ic|rEFInd}} for the UEFI boot loader. See [[Beginners' guide#For UEFI motherboards]]. The kernel parameters in {{ic|refind_linux.conf}} for ZFS should include {{ic|1=zfs=bootfs}} or {{ic|1=zfs=zroot}} so the system can boot from ZFS. The {{ic|root}} and {{ic|rootfstype}} parameters are not needed.<br />
<br />
== Unmount and restart ==<br />
<br />
We are almost done!<br />
# exit<br />
# umount /mnt/boot<br />
# zfs umount -a<br />
# zpool export zroot<br />
Now reboot.<br />
<br />
{{Warning|If you do not properly export the zpool, the pool will refuse to import in the ramdisk environment and you will be stuck at the busybox terminal.}}<br />
<br />
== After the first boot ==<br />
<br />
If everything went fine up to this point, your system will boot. Once.<br />
For your system to be able to reboot without issues, you need to enable the {{ic|zfs.target}} to auto mount the pools and set the hostid.<br />
<br />
For each pool you want automatically mounted execute:<br />
# zpool set cachefile=/etc/zfs/zpool.cache <pool><br />
Enable the target with [[systemd]]:<br />
# systemctl enable zfs.target<br />
<br />
When running ZFS on root, the machine's hostid will not be available at the time of mounting the root filesystem. There are two solutions to this. You can either place your spl hostid in the [[kernel parameters]] in your boot loader. For example, adding {{ic|<nowiki>spl.spl_hostid=0x00bab10c</nowiki>}}, to get your number use the {{ic|hostid}} command.<br />
<br />
The other, and suggested, solution is to make sure that there is a hostid in {{ic|/etc/hostid}}, and then regenerate the initramfs image. Which will copy the hostid into the initramfs image. To do write the hostid file safely you need to use a small C program:<br />
<br />
#include <stdio.h><br />
#include <errno.h><br />
#include <unistd.h><br />
<br />
int main() {<br />
int res;<br />
res = sethostid(gethostid());<br />
if (res != 0) {<br />
switch (errno) {<br />
case EACCES:<br />
fprintf(stderr, "Error! No permission to write the"<br />
" file used to store the host ID.\n"<br />
"Are you root?\n");<br />
break;<br />
case EPERM:<br />
fprintf(stderr, "Error! The calling process's effective"<br />
" user or group ID is not the same as"<br />
" its corresponding real ID.\n");<br />
break;<br />
default:<br />
fprintf(stderr, "Unknown error.\n");<br />
}<br />
return 1;<br />
}<br />
return 0;<br />
}<br />
<br />
Copy it, save it as {{ic|writehostid.c}} and compile it with {{ic|gcc -o writehostid writehostid.c}}, finally execute it and regenerate the initramfs image:<br />
<br />
# ./writehostid<br />
# mkinitcpio -p linux<br />
<br />
You can now delete the two files {{ic|writehostid.c}} and {{ic|writehostid}}. Your system should work and reboot properly now.<br />
<br />
== See also ==<br />
<br />
* [https://github.com/dajhorn/pkg-zfs/wiki/HOWTO-install-Ubuntu-to-a-Native-ZFS-Root-Filesystem HOWTO install Ubuntu to a Native ZFS Root]<br />
* [http://lildude.co.uk/zfs-cheatsheet ZFS cheatsheet]<br />
* [http://www.funtoo.org/wiki/ZFS_Install_Guide Funtoo ZFS install guide]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=SystemTap&diff=371617SystemTap2015-04-28T09:07:58Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Kernel]]<br />
[[zh-CN:SystemTap]]<br />
[http://sourceware.org/systemtap/ SystemTap] provides free software (GPL)<br />
infrastructure to simplify the gathering of information about the running Linux system.<br />
<br />
==SystemTap==<br />
<br />
Simply install SystemTap from [[AUR]]: {{AUR|systemtap}}, all done.<br />
Compare it to the most recent upstream release at [https://sourceware.org/systemtap/wiki/SystemTapReleases].<br />
<br />
Consider also building it from sources at [https://sourceware.org/git/?p=systemtap.git;a=summary], where<br />
support for newer kernels or distros makes first appearance.<br />
<br />
==Standard kernel==<br />
<br />
You will need at least the {{Pkg|linux-headers}} package installed. <br />
<br />
Because Arch permanently strips debugging data from its distributed binaries (including the kernel),<br />
many normal/fancier systemtap capabilities are simply not available, so many examples at ''/usr/share/doc/systemtap/examples'' will not work. However, see the [https://sourceware.org/systemtap/man/stapprobes.3stap.html stapprobes man page] for the NON-DWARF and AUTO-DWARF probe types for what should still work, for example:<br />
<br />
* kernel tracepoints: kernel.trace("*")<br />
* user-space probes: process("...").function("...") (for programs you build yourself with -g)<br />
* user-space markers: process("...").mark("...") (if they were configured with the ''<sys/sdt.h>'' markers)<br />
* perfctr-based probes: perf.*<br />
* non-dwarf kernel probes: kprobe.function("...") and nd_syscall.* tapset (if a /boot/System.map* file is available, see below).<br />
<br />
==Kernel rebuild==<br />
<br />
You may consider to build a ''linux-custom'' package to run SystemTap, but rebuilding the original {{Pkg|linux}} package is easy and efficient. See also [https://wiki.archlinux.org/index.php/Kernels/Compilation/Traditional].<br />
<br />
===Prepare===<br />
First, run {{ic|<nowiki>ABSROOT=. abs core/linux; cd core/linux</nowiki>}} to get the original kernel build files.<br />
Then use {{ic|makepkg --verifysource}} to get the additional files. By performing the verification, you can safely '''skip''' the steps on "Update checksum".<br />
<br />
===modify config===<br />
Edit '''config''' (for 32-bit systems) or '''config.x86_64''' (for 64-bit systems), turn on these options:<br />
* CONFIG_KPROBES=y<br />
* CONFIG_KPROBES_SANITY_TEST=n<br />
* CONFIG_KPROBE_EVENT=y<br />
* CONFIG_NET_DCCPPROBE=m<br />
* CONFIG_NET_SCTPPROBE=m<br />
* CONFIG_NET_TCPPROBE=y<br />
* CONFIG_DEBUG_INFO=y<br />
* CONFIG_DEBUG_INFO_REDUCED=n<br />
* CONFIG_X86_DECODER_SELFTEST=n<br />
By default only ''CONFIG_DEBUG_INFO'' and ''CONFIG_DEBUG_INFO_REDUCED'' are not set.<br />
<br />
With current core/linux (tested with 3.15.2) you can simply append these lines into config.[x86_64]:<br />
{{hc|x86_64|<br />
<nowiki><br />
echo '<br />
CONFIG_DEBUG_INFO=y<br />
CONFIG_DEBUG_INFO_REDUCED=n<br />
' >> config.x86_64<br />
</nowiki><br />
}}<br />
<br />
''Note that if you want to put these lines into a self-maintained script, do not insert any space before CONFIG_* lines.''<br />
<br />
===Update checksum===<br />
''You can safely skip this step if you believe the source files are correct''.<br />
<br />
Run {{ic|md5sum config[.x86_64]}} to get a new md5sum.<br />
<br />
In '''PKGBUILD''' file, the {{ic|<nowiki>md5sums=('sum-of-first' ... 'sum-of-last')</nowiki>}} has the same order with<br />
{{ic|<nowiki>source=('first-source' ... 'last-source')</nowiki>}}, put your new md5sum in the right place.<br />
<br />
===Build and Install===<br />
Optional: It is recommended to set {{ic|<nowiki>MAKEFLAGS="-j16"</nowiki>}} in {{ic|/etc/makepkg.conf}} to speed up the compilation.<br />
<br />
You will need about 12 GB disk space for this build. Consider using an in-memory tmpfs if you have large DRAM.<br />
Run {{ic|makepkg}} or {{ic|makepkg --skipchecksums}} to compile, then simply {{ic|sudo pacman -U *.pkg.tar.gz}} to install the packages.<br />
'''pacman''' will tell you '''reinstall''', and you should say y.<br />
<br />
{{Pkg|linux}} and {{Pkg|linux-headers}} should be reinstalled, {{Pkg|linux-docs}} does not matter.<br />
<br />
Via this method, external modules (e.g. {{Pkg|nvidia}} and {{Pkg|virtualbox}}) do not need to be rebuilt.<br />
<br />
==Build custom kernel==<br />
Please reference this [http://sourceware.org/git/?p=systemtap.git;a=blob_plain;f=README;hb=HEAD README]<br />
<br />
==Troubleshooting==<br />
<br />
=== Pass 4 fails when launching ===<br />
<br />
If you have:<br />
<br />
/usr/share/systemtap/runtime/stat.c:214:2: error: 'cpu_possible_map' undeclared (first use in this function)<br />
<br />
Try to install systemtap-git package<br />
<br />
=== System.map is missing ===<br />
<br />
You can recover it where you build your linux kernel with DEBUG_INFO enabled<br />
<br />
cp src/linux-3.6/System.map /boot/System.map-3.6.7-1-ARCH<br />
<br />
Alternately,<br />
<br />
sudo cp /proc/kallsyms /boot/System.map-`uname -r`</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Foswiki&diff=371616Foswiki2015-04-28T09:06:55Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Web Server]]<br />
[http://foswiki.org Foswiki] is a free enterprise collaboration platform written in Perl; developed, supported and maintained by its users and the open-source community.<br />
<br />
More information:<br />
* [http://en.wikipedia.org/wiki/Foswiki Wikipedia article]<br />
* [http://foswiki.org The Foswiki website]<br />
<br />
You may also be interested in [[XWiki]], which caters to similar needs, but is Java-based.<br />
<br />
== Installation ==<br />
<br />
{{Note|I abandoned the idea of adopting and maintaining the {{ic|foswiki}} package on the AUR for the following reasons:<br />
* Foswiki currently requires some user intervention on every upgrade.<br />
* Foswiki has a convenient mechanism for installing, updating, and removing plugins that does not function unless the installation directory is writeable.}}<br />
<br />
These instructions assume you will be using the directory {{ic|/srv/http/foswiki}} to store your Foswiki installation.<br />
<br />
The [http://foswiki.org/System/InstallationGuide Foswiki Installation Guide] is very thorough (although maybe a bit overwhelming), and makes an excellent reference. Follow along using the official guide, but you will find these notes to be more concise, and more specific to ArchLinux.<br />
<br />
* You will need to install the following packages in order for Foswiki to work:<br />
** '''rcs'''<br />
** '''perl-crypt-passwdmd5'''<br />
** '''perl-cgi-session'''<br />
** '''perl-html-tree'''<br />
** '''perl-libwww'''<br />
<br />
* From the [http://foswiki.org Foswiki website], determine the URL of the latest Foswiki release.<br />
* Download and unpack the archive as the {{ic|http}} user at {{ic|/srv/http/foswiki}}. For instance (as {{ic|root}}):<br />
{{bc|<br />
# su -s /bin/bash - http<br />
$ mkdir /tmp/foswiki<br />
$ cd /tmp/foswiki<br />
$ wget <archive-url><br />
$ tar xzf Fos*<br />
$ rm *.tgz<br />
$ exit<br />
# mv /tmp/foswiki/* /srv/http/foswiki<br />
# rmdir /tmp/foswiki<br />
# cd /srv/http/foswiki<br />
}}<br />
* Depending on how keen you are on locking down access to the Foswiki installation, you could restrict access to the installation directory:<br />
{{bc|<br />
# chmod o-rx .<br />
}}<br />
* At this point, you want to ensure that all the files have the correct permissions. (See the Foswiki guide on [http://foswiki.org/Support.SettingFileAccessRightsLinuxUnix Setting File Access Permissions] for details.)<br />
<br />
:If you would like to determine whether the files already have the correct permissions, you can make use of {{ic|find}} to test permissions against the example commands listed in the above Foswiki guide. For instance, this will find any directories that do ''not'' have their access mode set to 755:<br />
{{bc|<br />
# find . -type d \! -perm 755<br />
}}<br />
<br />
:As of version '''1.1.5''', I found that only one file was incorrectly set to be owner-writable; all other files appeared to have the correct permissions fresh out of the archive. The following command can be used to set the correct permissions (either as {{ic|root}} or {{ic|http}}), and will also catch any similar files that may display the same issue in future:<br />
{{bc|<br />
$ find pub data -name '*,v' -type f -exec chmod 444 \{\} \;<br />
}}<br />
<br />
* Copy {{ic|bin/LocalLib.cfg.txt}} to {{ic|bin/LocalLib.cfg}}, ensuring that ownership and access rights are identical to the original file.<br />
* Edit your newly copied file so that the {{ic|$foswikiLibPath}} line reads as follows:<br />
{{bc|1=<br />
$foswikiLibPath = '/srv/http/foswiki/lib';<br />
}}<br />
<br />
== Apache ==<br />
<br />
See the [http://foswiki.org/System/InstallationGuide#Configure_the_web_server Configure the Webserver] section of the Foswiki Installation Guide for guidance on getting set up with Apache.<br />
<br />
== Nginx ==<br />
<br />
Setting up Nginx to work correctly with Foswiki is tricky, but almost everything you need is provided here. The configuration is heavily commented, to make it as easy as possible to modify it to suit your needs.<br />
<br />
Foswiki is written in Perl and is generally intended to be run as a series of CGI scripts. Check out the [http://foswiki.org/System/FastCGIEngineContrib FastCGIEngineContrib] if you are interested in running Foswiki as a FastCGI application, but be aware that some plugins do not work well with this setup.<br />
<br />
* Install {{ic|fcgiwrap}} (See the [[Nginx#fcgiwrap]] page). The rest of this configuration assumes you have set up {{ic|fcgiwrap}} using a socket.<br />
<br />
* Create a file with the following contents at '''/etc/nginx/foswiki.conf''':<br />
<br />
{{bc|1=<br />
location /bin/configure {<br />
# It is important to protect this location with a password.<br />
auth_basic "Restricted";<br />
auth_basic_user_file htpasswd/foswiki-configure;<br />
# (Temporarily?) allow an IP address below for configuration access<br />
#allow 127.0.0.1;<br />
deny all;<br />
fastcgi_pass fcgiwrap;<br />
include fastcgi.conf;<br />
fastcgi_split_path_info ^(/bin/configure)(.*);<br />
fastcgi_param PATH_INFO $fastcgi_path_info;<br />
}<br />
location /bin/ {<br />
fastcgi_pass fcgiwrap;<br />
include fastcgi.conf;<br />
fastcgi_split_path_info ^(/bin/\w+)(.*);<br />
fastcgi_param PATH_INFO $fastcgi_path_info;<br />
# Setting the NO_FOSWIKI_SESSION environment variable prevents a<br />
# session being created. If a bot is spawning too many sessions, add its<br />
# user agent string to this regexp.<br />
set $no_foswiki_session "";<br />
if ($http_user_agent ~* "^gsa-crawler") {<br />
set $no_foswiki_session true;<br />
}<br />
fastcgi_param NO_FOSWIKI_SESSION $no_foswiki_session;<br />
# This prevents the %INCLUDE% macro from including our own topics as URLs<br />
# and also prevents other Foswikis from doing the same. This is important to<br />
# prevent the most obvious Denial of Service attacks.<br />
if ($http_user_agent = "") { return 403; }<br />
}<br />
# Contains public-facing files.<br />
# The rewrite rule is necessary for enforcing access policies. Otherwise,<br />
# access would be free to this directory. Comment it out if you do not like<br />
# the performance hit (but see /pub/... locations below).<br />
location /pub/ {<br />
rewrite ^/pub/(.*)$ /bin/viewfile/$1 last;<br />
}<br />
# Prevent HTML attachments from rendering directly in the browser; it could<br />
# potentially be a security risk.<br />
location ~* /pub/.*\.html?$ {<br />
types {}<br />
default_type application/octet-stream;<br />
}<br />
# These locations contain CSS, JS, and other assets that are trusted and really<br />
# need to be cached, and that we do not want going through CGI for reasons of<br />
# performance. The ^~ prefix prevents the above HTML security fix from applying<br />
# to these locations (e.g. WYSIWYG uses some HTML from /pub/System).<br />
location ^~ /pub/System/ { # General system support files<br />
}<br />
location ^~ /pub/Main/SitePreferences/ { # Attachments for site logos etc...<br />
}<br />
# Anything in the Trash should not be visible.<br />
# This is not necessary if access policies are being enforced for the /pub<br />
# directory through the rewrite rule above.<br />
#location /pub/Trash {<br />
# deny all;<br />
#}<br />
location /robots.txt {<br />
}<br />
# Pretty URLs: /Main/Foo, /edit/Main/Foo, etc...<br />
location / {<br />
rewrite ^/(?:[A-Z].*)?$ /bin/view$uri last;<br />
rewrite ^/([a-z]+/[A-Z].*) /bin/$1 last;<br />
# The above should catch most day-to-day things. This is for some more unusual<br />
# situations (e.g. when Main requires authentication, when resubmitting a<br />
# form, maybe some other situations):<br />
rewrite ^ /bin$uri last;<br />
}<br />
}}<br />
<br />
{{Warning|When working on a production installation, take care of the {{ic|allow}} directive near the top of the file. Keep it commented out when you do not need access to the {{ic|configure}} script. This script is a potential security weak point for Foswiki, and is best kept locked down when it is not needed.}}<br />
<br />
* Uncomment the {{ic|allow}} directive near the top of the file, and replace {{ic|127.0.0.1}} with the IP address of your local machine.<br />
* Now, add a new server section to your main '''nginx''' configuration file at '''/etc/nginx/nginx.conf'''; for instance:<br />
<br />
{{bc|<br />
server {<br />
listen 80;<br />
server_name foswiki;<br />
root /srv/http/foswiki;<br />
<br />
include foswiki.conf;<br />
}<br />
}}<br />
<br />
* If you have not done so already, add an {{ic|upstream}} block before the {{ic|server}} blocks in '''nginx.conf''', as the '''foswiki.conf''' file references this:<br />
<br />
{{bc|<br />
upstream fcgiwrap {<br />
server unix:/var/run/fcgiwrap.sock;<br />
}<br />
}}<br />
<br />
* Follow the [http://wiki.nginx.org/Faq#How_do_I_generate_an_.htpasswd_file_without_having_Apache_tools_installed.3F instructions from the Nginx Wiki] to create an {{ic|htpasswd}} file at the required location. The above configuration expects such a file at '''/etc/nginx/htpasswd/foswiki-configure'''. Do not forget to set sensible file permissions for this file. For instance, as {{ic|root}}:<br />
<br />
{{bc|<br />
# mkdir -p /etc/nginx/htpasswd<br />
# cd /etc/nginx/htpasswd<br />
# printf "admin:$(openssl passwd -crypt <YOURPASSWORD>)\n" >> foswiki-configure<br />
# chgrp http foswiki-configure<br />
# chmod 640 foswiki-configure<br />
}}<br />
<br />
* Navigate your browser to the '''/configure''' URL, e.g.: http://foswiki/configure.<br />
* In the '''General Path Settings''' section, remove the contents of the {{ic|{ScriptUrlPaths}{view}}} setting. It should be completely blank. (This will make Foswiki use the pretty URLs we have set up in the Nginx configuration.)<br />
* All other settings should be fine, so press "Save Changes", and choose a password to protect your configuration. (You may as well use the same password you set for your HTTP Basic Authentication.)<br />
* Review the Foswiki configuration as desired, and save once more.<br />
* Comment out the {{ic|allow}} directive near the top of '''/etc/nginx/foswiki.conf''' to protect the {{ic|configure}} script.<br />
* Your Foswiki installation should now be complete.<br />
<br />
== After Installation ==<br />
<br />
Once your wiki is set up, you way also want to set up '''cron''' rules for:<br />
<br />
* [http://foswiki.org/System/MailerContrib E-mail notifications]<br />
* [http://foswiki.org/System/SiteToolStatistics Web statistics]<br />
<br />
== Upgrade ==<br />
<br />
The [http://foswiki.org/System.UpgradeGuide Foswiki Upgrade Guide] is the official reference for the upgrade process, and is generally sufficient to help you with the upgrade. Remember to install any plugins that were used in the old installation. The easiest way to do this is to compare the {{ic|lib/Foswiki/Plugins}} directories. The most painful part of the upgrade process is the copying of topics from the old installation to the new. A script is available that almost completely automates this process, leaving you only with the task of merging a few core topics that were modified in the old installation.<br />
<br />
You can find the script here: https://github.com/giddie/bits-n-pieces/blob/master/Foswiki/foswiki-copy.<br />
<br />
* Use {{ic|diff}} (or your favourite derivative) to compare '''lib/LocalSite.cfg''' and any topics that need merging manually.<br />
* It may be best to edit certain topics via the Web interface if you want Foswiki to save a revision with the original contents.<br />
* Do not forget to copy:<br />
** The '''<topic>.txt,v''' file containing the revision data if you are simply clobbering the new topic with the old one.<br />
** The '''pub''' folder of any topic you are merging manually, if it exists.<br />
** The '''data/.htpasswd''' file, which contains the users' password hashes.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Argument "5.8.1" is not numeric in numeric lt (<) ... when accessing configure ===<br />
<br />
This is caused by a [http://foswiki.org/Tasks/Item11937 bug in Foswiki]. A workaround is to downgrade to '''RCS 5.8'''. The configure script cannot handle the third digit in the version number.<br />
<br />
Since this is really just a lazy programming mistake (basically "5.8" is a number while "5.8.1" is not), you can safely comment out line 505-513 of {Foswiki_root}/lib/Foswiki/Configure/Checker.pm.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=PS3_Mediaserver&diff=371615PS3 Mediaserver2015-04-28T09:05:19Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Web Server]]<br />
[[ja:PS3 Mediaserver]]<br />
{{Out of date|Mentions rc.d scripts.}}<br />
Server implemented in java. Has very good default transcoding profiles for several clients, but lacks good information for headless servers.<br />
<br />
== Installation ==<br />
<br />
{{Note|Because of the dependency {{AUR|tsmuxer}} having extra 32-bit dependencies, you will need to enable the [[multilib]] repository if you have a 64-bit system.}}<br />
<br />
Install {{AUR|pms}} from [[AUR]].<br />
<br />
== Configuration ==<br />
The default install location is /opt/pms and the config file is at /opt/pms/PMS.conf, there are comments describing what each option is for.<br />
<br />
If running headless on a server<br />
{{hc|Operating Mode|<br />
minimized &#61; true}}<br />
<br />
If you do not want your entire filesystem to be shown<br />
{{hc|Media Locations|<br />
folders &#61; /directory.you.want.shared/,/another.directory<br />
}}<br />
<br />
If you run into issues with the wrong audio track playing (example: English desired)<br />
{{hc|Audio language priority|<br />
mencoder_audiolangs &#61; eng,und<br />
}}<br />
<br />
Example of english subtitles desired, no subtitles by default on English programs<br />
{{hc|Subtitle language priority|<br />
mencoder_sublangs &#61; loc,eng,und<br />
}}<br />
<br />
A list with all options can be found [http://ps3mediaserver.org/forum/viewtopic.php?f=3&t=254&hilit=pms.conf#p15283 here].<br />
<br />
== Run as a daemon ==<br />
=== SysVinit ===<br />
<br />
Use the following modified daemon script (originally from pms-svn).<br />
{{hc|/etc/rc.d/pms|<br />
#!/bin/bash<br />
<br />
. /etc/rc.conf<br />
. /etc/rc.d/functions<br />
. /etc/conf.d/pms<br />
<br />
PID&#61;`cat /var/run/pms.pid 2> /dev/null`<br />
[ -z "$PID" ] && PID&#61;`ps -Ao pid,command &#124; grep java &#124; grep pms.jar &#124; awk '{print $1}'`<br />
<br />
case "$1" in<br />
start)<br />
stat_busy "Starting PS3 Media Server"<br />
if [ -z "$PID" ]; then<br />
if [ -n "$PMS_USER" ]; then<br />
su -s '/bin/sh' $PMS_USER -c "/usr/bin/ps3mediaserver &>> /var/log/pms.log" &<br />
else<br />
/usr/bin/ps3mediaserver &>> /var/log/pms.log &<br />
fi<br />
PID&#61;$!<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
echo $PID > /var/run/pms.pid<br />
add_daemon pms<br />
stat_done<br />
fi<br />
fi<br />
;;<br />
stop)<br />
stat_busy "Stopping PS3 Media Server"<br />
[ ! -z "$PID" ] && kill $PID &> /dev/null<br />
while ps -p $PID &> /dev/null; do sleep 1; done<br />
if [ $? -gt 0 ]; then<br />
stat_fail<br />
else<br />
rm /var/run/pms.pid 2> /dev/null<br />
rm_daemon pms<br />
stat_done<br />
fi<br />
;;<br />
restart)<br />
$0 stop<br />
sleep 1<br />
$0 start<br />
;;<br />
*)<br />
echo "usage: $0 {start&#124;stop&#124;restart}"<br />
;;<br />
esac<br />
exit 0<br />
}}<br />
<br />
# /etc/rc.d/pms start<br />
<br />
* (optionally) watch the output with 'tail -f /var/log/pms.log' or 'tail -f /opt/pms/debug.log' for any problems.<br />
<br />
=== systemd ===<br />
<br />
The package ships a systemd unit file by default now (since 1.71.0-2). However, upon bootup the service [http://www.ps3mediaserver.org/forum/viewtopic.php?f=3&t=17992 will not execute properly]. This can be resolved by adding a timeout before the service starts the involved script. One only has to edit the file as follows by adding the "ExecStartPre" line.<br />
<br />
{{hc|/usr/lib/systemd/system/pms@.service|output=<br />
[Unit]<br />
Description=PS3 Media Server<br />
After=syslog.target network.target rpcbind.service<br />
<br />
[Service]<br />
User=%i<br />
Group=users<br />
WorkingDirectory=/opt/pms/<br />
Type=simple<br />
ExecStartPre=/usr/bin/sleep 16<br />
ExecStart=/opt/pms/PMS.sh<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
After the addition just run:<br />
<br />
# systemctl daemon-reload<br />
# systemctl start pms@<username> # to start once<br />
# systemctl enable pms@<username> # automatically start at boot<br />
# journalctl -u pms@<username> # to debug the logfiles<br />
<br />
== Indexing ==<br />
This should be done automagically upon starting the service, but if it does not, this is how to do it manually:<br />
* Browse the logs to see at what ip-address and port pms has started the built-in webservice<br />
* Use your web browser to go to: <nowiki>http://<ip-address-of-your-server>:5001/console/home</nowiki> and click on 'index files and folders'<br />
* After the indexing has ended, you are done.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Nextcloud&diff=371614Nextcloud2015-04-28T09:04:32Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Web Server]]<br />
[[fr:Owncloud]]<br />
[[ja:ownCloud]]<br />
{{lowercase title}}<br />
{{Related articles start}}<br />
{{Related|LAMP}}<br />
{{Related|Nginx}}<br />
{{Related|OpenSSL}}<br />
{{Related|WebDAV}}<br />
{{Related articles end}}<br />
From [[Wikipedia:ownCloud|Wikipedia]]:<br />
: ''ownCloud is a software suite that provides a location-independent storage area for data (cloud storage).''<br />
The ownCloud installation and configuration mainly depends on what web server and database you decide to run. Currently the wiki discusses [[#Apache configuration]] and [[#Nginx + uwsgi_php configuration]].<br />
== Prerequisites ==<br />
<br />
''ownCloud'' needs a [[:Category:Web_Server|web server]], [[PHP]] and a [[:Category:Database_management_systems|database]]. For instance, a classic [[LAMP|LAMP stack]] should work fine and is the [http://doc.owncloud.org/server/7.0/admin_manual/installation/installation_source.html#manual-installation recommended configuration].<br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|owncloud}} from the [[official repositories]]. Alternatively see the packages available in the [[Arch User Repository]]: [https://aur.archlinux.org/packages.php?K=owncloud].<br />
<br />
Uncomment the following '''required''' extensions in {{ic|/etc/php/php.ini}}:<br />
gd.so<br />
iconv.so<br />
xmlrpc.so<br />
zip.so<br />
<br />
It is also [http://doc.owncloud.org/server/7.0/admin_manual/installation/installation_source.html#prerequisites recommended] to install {{Pkg|php-intl}}, {{Pkg|php-mcrypt}} and uncomment the following extensions:<br />
bz2.so<br />
curl.so<br />
intl.so<br />
mcrypt.so<br />
openssl.so<br />
<br />
For enhanced performance, you may install ''either'':<br />
* {{Pkg|php-apcu}}: only provides user data caching. Enable it by removing the comment in {{ic|/etc/php/conf.d/apcu.ini}}. Then for opcode caching use the [http://www.php.net/manual/en/book.opcache.php opcache extension]: uncomment {{ic|1=zend_extension=opcache.so}} in {{ic|/etc/php/php.ini}}.<br />
* {{Pkg|php-xcache}}: development version which provides both an opcode and user data cache. Uncomment it in {{ic|/etc/php/conf.d/xcache.ini}} after installation.<br />
<br />
==== Database support ====<br />
Depending on which database backend you are going to use, uncomment both of the following two extensions in {{ic|/etc/php/php.ini}}:<br />
{| class="wikitable"<br />
!SQLite!!MySQL!!PostgreSQL<br />
|-<br />
|{{bc|pdo_sqlite.so<br />
sqlite3.so}}<br />
|{{bc|pdo_mysql.so<br />
mysql.so}}<br />
|{{bc|pdo_pgsql.so<br />
pgsql.so}}<br />
|-<br />
|}<br />
<br />
{{note|1=When using [[MySQL]] you need {{ic|mysql.so}}, even though it is deprecated. As of July 2014 (ownCloud 7.0) {{ic|mysqli.so}} is not supported.[http://doc.owncloud.org/server/7.0/admin_manual/configuration/configuration_database.html][https://forum.owncloud.org/viewtopic.php?f=26&t=21534]}}<br />
Do not forget to install the appropriate php-module for the database. In the PostgreSQL case thats {{Pkg|php-pgsql}} or for SQLite {{Pkg|php-sqlite}}.<br />
<br />
==== Exif support ====<br />
Additionally enable exif support by installing {{Pkg|exiv2}} from the [[official repositories]] and uncommenting the {{ic|exif.so}} extension in {{ic|php.ini}}.<br />
<br />
=== An all-in-one alternative with Docker ===<br />
<br />
A quick and safe alternative to installing and configuring ''ownCloud'' on your own is to use [[Docker]]. You can find several images of fully working LAMP stack with pre-installed ''ownCloud'' in the [https://index.docker.io/search?q=ownCloud Docker repositories]. ''Docker'' containers are generally safer than a [[chroot]] environment and the overhead is very low,; ''ownCloud'' in Docker works smoothly even on quite old machines. The whole setup including installing ''Docker'' and ''ownCloud'' image is considerably easier and quicker than a native installation.<br />
<br />
== Apache configuration ==<br />
<br />
Copy the Apache configuration file to its configuration directory:<br />
# cp /etc/webapps/owncloud/apache.example.conf /etc/httpd/conf/extra/owncloud.conf<br />
<br />
And include it at the bottom of {{ic|/etc/httpd/conf/httpd.conf}}:<br />
Include conf/extra/owncloud.conf<br />
<br />
Activate php (install package php-apache):<br />
LoadModule php5_module modules/libphp5.so<br />
Include conf/extra/php5_module.conf<br />
<br />
Make sure the web server can write to the ownCloud directory:<br />
# chown http:http /usr/share/webapps/owncloud/<br />
<br />
{{Warning|see [https://doc.owncloud.org/server/8.0/admin_manual/installation/installation_wizard.html#setting-strong-directory-permissions important security details] regarding permissions to avoid problems during installation}}<br />
<br />
ownCloud comes with its own [[WebDAV]] implementation enabled, which may conflict with the one shipped with Apache. If you have enabled WebDAV (not enabled by default with Apache), disable {{ic|mod_dav}} and {{ic|mod_dav_fs}} in {{ic|/etc/httpd/conf/httpd.conf}}. See https://forum.owncloud.org/viewtopic.php?f=17&t=7240 for details.<br />
<br />
Now restart Apache ({{ic|httpd.service}}).<br />
<br />
Replace this module in case of httpd startup problems (Invalid command 'php_admin_value'...):<br />
LoadModule mpm_event_module modules/mod_mpm_event.so<br />
<br />
by this one: <br />
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so<br />
<br />
Open http://localhost/ in your browser. You should now be able to create a user account and follow the installation wizard.<br />
<br />
==== Running ownCloud in a subdirectory ====<br />
<br />
By including the default {{ic|owncloud.conf}} in {{ic|httpd.conf}}, ownCloud will take control of port 80 and your localhost domain. <br />
<br />
If you would like to have ownCloud run in a subdirectory, then edit the {{ic|/etc/httpd/conf/extra/owncloud.conf}} you included and comment out the {{ic|<nowiki><VirtualHost *:80> ... </VirtualHost></nowiki>}} part of the include file.<br />
<br />
== Nginx + uwsgi_php configuration ==<br />
<br />
You can avoid the use of Apache, and run ownCloud in its own process by using the {{pkg|uwsgi-plugin-php}} application server. uWSGI itself has a wealth of features to limit the resource use, and to harden the security of the application, and by being a separate process it can run under its own user.<br />
<br />
=== Configuration ===<br />
<br />
*First of all you should set up your Nginx server. See the [[Nginx]] page for further information.<br />
*Set a server with the following lines in the http section of your {{ic|/etc/nginx/nginx.conf}} file:<br />
{{bc|<nowiki><br />
#this is to avoid Request Entity Too Large error<br />
client_max_body_size 1000M;<br />
# deny access to some special files<br />
location ~ ^/(data|config|\.ht|db_structure\.xml|README) {<br />
deny all;<br />
}<br />
# pass all .php or .php/path urls to uWSGI<br />
location ~ ^(.+\.php)(.*)$ {<br />
include uwsgi_params;<br />
uwsgi_modifier1 14;<br />
#Uncomment line below if you get connection refused error. Remember to commet out line with "uwsgi_pass 127.0.0.1:3001;" below<br />
#uwsgi_pass unix:/run/uwsgi/owncloud.sock;<br />
uwsgi_pass 127.0.0.1:3001;<br />
}<br />
# everything else goes to the filesystem,<br />
# but / will be mapped to index.php and run through uwsgi<br />
location / {<br />
root /usr/share/webapps/owncloud;<br />
index index.php;<br />
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;<br />
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;<br />
}<br />
</nowiki>}}<br />
*Then create a [[Uwsgi|uWSGI]] config file. {{ic|/etc/uwsgi/owncloud.ini}} could be a good choice:<br />
{{bc|<nowiki><br />
[uwsgi]<br />
master = true<br />
socket = 127.0.0.1:3001<br />
<br />
# Change this to where you want ownlcoud data to be stored (maybe /home/owncloud)<br />
owncloud_data_dir = /usr/share/webapps/owncloud/data/<br />
chdir = %(owncloud_data_dir)<br />
<br />
plugins = php<br />
php-docroot = /usr/share/webapps/owncloud<br />
php-index = index.php<br />
<br />
# only allow these php files, I do not want to inadvertently run something else<br />
php-allowed-ext = /index.php<br />
php-allowed-ext = /public.php<br />
php-allowed-ext = /remote.php<br />
php-allowed-ext = /cron.php<br />
php-allowed-ext = /status.php<br />
php-allowed-ext = /settings/apps.php<br />
php-allowed-ext = /core/ajax/update.php<br />
php-allowed-ext = /core/ajax/share.php<br />
php-allowed-ext = /core/ajax/requesttoken.php<br />
php-allowed-ext = /core/ajax/translations.php<br />
php-allowed-ext = /search/ajax/search.php<br />
php-allowed-ext = /search/templates/part.results.php<br />
php-allowed-ext = /settings/admin.php<br />
php-allowed-ext = /settings/users.php<br />
php-allowed-ext = /settings/personal.php<br />
php-allowed-ext = /settings/help.php<br />
php-allowed-ext = /settings/ajax/getlog.php<br />
php-allowed-ext = /settings/ajax/setlanguage.php<br />
php-allowed-ext = /settings/ajax/setquota.php<br />
php-allowed-ext = /settings/ajax/userlist.php<br />
php-allowed-ext = /settings/ajax/createuser.php<br />
php-allowed-ext = /settings/ajax/removeuser.php<br />
php-allowed-ext = /settings/ajax/enableapp.php<br />
php-allowed-ext = /core/ajax/appconfig.php<br />
php-allowed-ext = /settings/ajax/setloglevel.php<br />
php-allowed-ext = /ocs/v1.php<br />
<br />
# set php configuration for this instance of php, no need to edit global php.ini<br />
php-set = date.timezone=Etc/UTC<br />
php-set = open_basedir=%(owncloud_data_dir):/tmp/:/usr/share/pear/:/usr/share/webapps/owncloud:/etc/webapps/owncloud<br />
php-set = session.save_path=/tmp<br />
php-set = post_max_size=1000M<br />
php-set = upload_max_filesize=1000M<br />
php-set = always_populate_raw_post_data=-1<br />
<br />
# load all extensions only in this instance of php, no need to edit global php.ini<br />
php-set = extension=bz2.so<br />
php-set = extension=curl.so<br />
php-set = extension=intl.so<br />
php-set = extension=openssl.so<br />
php-set = extension=pdo_sqlite.so<br />
php-set = extension=exif.so<br />
php-set = extension=gd.so<br />
php-set = extension=imagick.so<br />
php-set = extension=gmp.so<br />
php-set = extension=iconv.so<br />
php-set = extension=mcrypt.so<br />
php-set = extension=sockets.so<br />
php-set = extension=sqlite3.so<br />
php-set = extension=xmlrpc.so<br />
php-set = extension=xsl.so<br />
php-set = extension=zip.so<br />
<br />
processes = 10<br />
cheaper = 2<br />
cron = -3 -1 -1 -1 -1 /usr/bin/php -f /usr/share/webapps/owncloud/cron.php 1>/dev/null<br />
<br />
</nowiki>}}<br />
<br />
=== Activation ===<br />
<br />
[[Uwsgi|uWSGI]] provides a [[Systemd#Using_units|template unit]] that allows to start and enable application using their configuration file name as instance identifier. For example:<br />
# systemctl start uwsgi@owncloud.service<br />
would start it referencing the configuration file {{ic|/etc/uwsgi/owncloud.ini}}. <br />
<br />
To enable the uwsgi service by default at start-up, run:<br />
# systemctl enable uwsgi@owncloud.service<br />
<br />
See also [[Uwsgi#Starting_service]].<br />
<br />
== Synchronization ==<br />
<br />
=== Desktop ===<br />
<br />
The official client can be installed with the package {{Pkg|owncloud-client}} from the official repositories. Alternative versions are avaiable in the [[AUR]]: {{AUR|owncloud-client-beta}}, {{AUR|owncloud-client-git}} and {{AUR|owncloud-client-qt5}}. Its use is described in [http://doc.owncloud.org/server/7.0/user_manual/files/sync.html this page] of the documentation.<br />
<br />
==== Calendar ====<br />
<br />
To access your ''ownCloud'' calendars using Mozilla [[Thunderbird]]'s [[Thunderbird#Lightning_-_Calendar|Lightning calendar]] you would use the following URL:<br />
<br />
<nowiki>https://ADDRESS/remote.php/caldav/calendars/USERNAME/CALENDARNAME</nowiki><br />
<br />
To access your ''ownCloud'' calendars using CalDAV-compatible programs like Kontact or [[Evolution]], you would use the following URL:<br />
<br />
<nowiki>https://ADDRESS/remote.php/caldav</nowiki><br />
<br />
For details see the [http://doc.owncloud.org/server/7.0/user_manual/pim/calendar.html#synchronizing-calendars-using-caldav official documentation].<br />
<br />
==== Contacts ====<br />
<br />
To sync contacts with [[Thunderbird]] you must install the [http://www.sogo.nu/downloads/frontends.html SOGo frontend], [[Thunderbird#Lightning_-_Calendar|Lightning extension]] and follow [http://doc.owncloud.org/server/7.0/user_manual/pim/sync_thunderbird.html those instructions] from the official doc.<br />
<br />
==== Mounting files with davfs2 ====<br />
<br />
If you want to mount your ownCloud permanently install {{Pkg|davfs2}} (as described in [[Davfs]]) first.<br />
<br />
Considering your ownCloud were at {{ic|https://own.example.com}}, your WebDAV URL would be {{ic|https://own.example.com/remote.php/webdav}} (as of ownCloud 6.0).<br />
<br />
To mount your ownCloud, use:<br />
<br />
# mount -t davfs https://own.example.com/remote.php/webdav /path/to/mount<br />
<br />
You can also create an entry for this in {{ic|/etc/fstab}}<br />
<br />
{{hc|/etc/fstab|<br />
https://own.example.com/remote.php/webdav /path/to/mount davfs rw,user,noauto 0 0<br />
}}<br />
<br />
{{Tip|In order to allow automount you can also store your username (and password if you like) in a file as described in [[Davfs#Mounting as regular user]].}}<br />
<br />
{{Note| If creating/copying files is not possible, while the same operations work on directories, see [[Davfs#Creating.2Fcopying_files_not_possible]].}}<br />
<br />
=== Android ===<br />
<br />
There is an official Android app available for a small fee on the Play Store and for free [https://f-droid.org/repository/browse/?fdfilter=owncloud&fdid=com.owncloud.android on F-Droid].<br />
<br />
To enable contacts and calendar sync:<br />
* if using Android 4+:<br />
*# download [http://davdroid.bitfire.at/what-is-davdroid DAVdroid] (available in [https://f-droid.org/repository/browse/?fdfilter=owncloud&fdid=at.bitfire.davdroid F-Droid])<br />
*# Enable mod_rewrite.so in httpd.conf<br />
*# create a new DAVdroid account in the ''Account'' settings, and specify your "short" server address and login/password couple, e.g. {{ic|<nowiki>https://cloud.example.com</nowiki>}} (there is no need for the {{ic|<nowiki>/remote.php/{carddav,webdav}</nowiki>}} part if you configured your web server with the proper redirections, as illustrated previously in the article; ''DAVdroid'' will find itself the right URLs)<br />
:For an older version of the app but with still useful info, see [http://www.slsmk.com/sync-android-contacts-calendar-and-files-to-owncloud/ this article].<br />
<br />
* if using an Android version below 4.0 and favouring Free/Libre software solutions, give a try to [https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=com.morphoss.acal aCal] for calendar and contacts sync or CalDAV Sync Adapter ([https://f-droid.org/repository/browse/?fdfilter=caldav&fdid=org.gege.caldavsyncadapter F-Droid]) for just calendar sync; if you are willing to use non-libre software, then the [http://doc.owncloud.org/server/7.0/user_manual/pim/contacts.html#synchronizing-with-android recommended solution] is to use [http://dmfs.org/ CardDAV-Sync and CalDAV-Sync].<br />
<br />
== Important notes ==<br />
<br />
* When using a subdomain (like cloud.example.net), make sure it is covered by your certificate. Otherwise, connection via the ownCloud client or webdav might fail.<br />
<br />
* If you are planning on using ownCloud's [http://owncloud.org/sync-clients/ sync-clients], make sure to have [[ntpd]] installed and running on your ownCloud server, otherwise the sync-clients will fail.<br />
<br />
* Add some [[LAMP#SSL|SSL encryption]] to your connection!<br />
(If adding SSL encryption as above, be sure to edit /etc/httpd/conf/extra/httpd-ssl.conf and change DocumentRoot "/srv/http" to DocumentRoot "/usr/share/webapps/owncloud" )<br />
<br />
* More Apps for ownCloud can be found [http://apps.owncloud.com/ here]<br />
<br />
* To install an new application, download the zip from the apps store, extract it into /srv/http/owncloud/apps/.<br />
Afterwards restart httpd:<br />
<br />
# systemctl restart httpd<br />
<br />
log into your server go to the app sections you should see the new apps in there,<br />
<br />
* If you are protecting access to your ownCloud location with HTTP basic auth, the file "status.php" must be excluded from auth and be publicly accessible. [https://github.com/owncloud/mirall/issues/734]<br />
<br />
=== SABnzbd ===<br />
<br />
When using [[SABnzbd]], you might want to set<br />
folder_rename 0<br />
in your sabnzbd.ini file, because ownCloud will scan the files as soon as they get uploaded, preventing SABnzbd from removing UNPACKING prefixes etc.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Self-signed certificate not accepted ===<br />
<br />
OwnCloud uses [[Wikipedia:cURL]] and [[Wikipedia:SabreDAV]] to check if WebDAV is enabled. If you use a SSL/TLS with a self-signed certificate, e.g. as shown in [[LAMP]] and access ownCloud's admin panel, you will see the following error message:<br />
<br />
Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.<br />
<br />
Assuming that you followed the [[LAMP]]-tutorial, execute the following steps:<br />
<br />
Create local directory for non-distribution certificates and copy [[LAMP]]s certificate there. This will prevent {{Ic|ca-certificates}}-updates to overwrite it.<br />
<br />
# cp /etc/httpd/conf/server.crt /usr/share/ca-certificates/''WWW.EXAMPLE.COM.crt''<br />
<br />
Add ''WWW.EXAMPLE.COM.crt'' to {{ic|/etc/ca-certificates.conf}}:<br />
<br />
''WWW.EXAMPLE.COM.crt''<br />
<br />
Now, regenerate your certificate store:<br />
<br />
# update-ca-certificates<br />
<br />
Restart the httpd service to activate your certificate.<br />
<br />
<br />
Should this not work consider disabling mod_curl in /etc/php/php.ini.<br />
<br />
=== Self-signed certificate for Android devices ===<br />
<br />
Once you have followed the setup for SSL as on [https://wiki.archlinux.org/index.php/LAMP#TLS.2FSSL LAMP] for example [https://f-droid.org/repository/browse/?fdfilter=davdroid&fdid=at.bitfire.davdroid davdroid] will fail to work because the certificate is not accepted. A certificate can be made as follows on your server:<br />
<br />
# openssl x509 -req -days 365 -in /etc/httpd/conf/server.csr -signkey /etc/httpd/conf/server.key -extfile android.txt -out CA.crt<br />
# openssl x509 -inform PEM -outform DER -in CA.crt -out CA.der.crt <br />
<br />
The file android.txt should contain the following:<br />
<br />
basicConstraints=CA:true<br />
<br />
Then import CA.der.crt to your android device:<br />
<br />
Put the CA.der.crt onto the sdcard of your Android device (usually to internal one, eg save from a mail attachment). It should be in root directory.<br />
Go to Settings / Security / Credential storage and select “Install from device storage”.<br />
The .crt file will be detected and you will be prompted to enter a certificate name.<br />
After importing the certificate, you will find it in Settings / Security / Credential storage / Trusted credentials / User.<br />
<br />
Thanks to: [http://www.leftbrainthings.com/2013/10/13/creating-and-importing-self-signed-certificate-to-android-device/]<br />
<br />
=== Cannot write into config directory! ===<br />
<br />
Check your httpd conf file (like owncloud.conf). Add your config dir (/etc/webapps by default) to <br />
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/"<br />
<br />
Restart the httpd or php-fpm service to activate the change.<br />
<br />
=== Cannot create data directory (/path/to/dir) ===<br />
<br />
Check your httpd conf file (like owncloud.conf). Add your data dir to <br />
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/path/to/dir/"<br />
<br />
Restart the httpd or php-fpm service to activate the change.<br />
<br />
=== CSync failed to find a specific file. ===<br />
<br />
Most probably a certificate issue, recreate it, and do not leave the common name empty or you will see the error again.<br />
<br />
openssl genrsa -out server.key 2048<br />
openssl req -new -key server.key -x509 -days 365 -out server.crt<br />
<br />
=== Seeing white page after login ===<br />
<br />
The cause is probably a new app that you installed, to fix that you can either use phpMyAdmin by editing the oc_appconfig table(in the case you got lucky and the table has edit option) or do it by hand with mysql:<br />
<br />
mysql -u root -p owncloud<br />
MariaDB [owncloud]> '''delete from''' oc_appconfig '''where''' appid='<nameOfExtension>' '''and''' configkey='enabled' '''and''' configvalue='yes'<br />
MariaDB [owncloud]> '''insert into''' oc_appconfig (appid,configkey,configvalue) '''values''' ('<nameOfExtension>','enabled','no');<br />
<br />
This should delete the relevant configuration from the table and add it again.<br />
<br />
=== GUI sync client fails to connect ===<br />
<br />
If using HTTP basic auth, make sure to exclude "status.php", which must be publicly accessible [https://github.com/owncloud/mirall/issues/734]<br />
<br />
=== "Cannot write into apps directory" ===<br />
As mentioned in the [http://doc.owncloud.org/server/6.0/admin_manual/configuration/configuration_apps.html official admin manual] either you need an apps directory that is writable by the http user, or you need to set "appstoreenabled" to false. <br />
<br />
''Also'', not mentioned there, the directory needs to be in the open_basedir line in {{ic|/etc/php/php.ini}}<br />
<br />
<br />
{{Accuracy|Does not seem to work with 8.0.2}}<br />
<br />
One clean method is to have the package-installed directory at {{ic|/usr/share/webapps/owncloud/apps}} stay owned by root, and have the user-installed apps go into e.g. {{ic|/var/www/owncloud/apps}} which is owned by http. Then you can set "appstoreenabled" to true and package upgrades of apps should work fine as well. Relevant lines from {{ic|/etc/webapps/owncloud/config/config.php}}:<br />
<pre><br />
'apps_paths' => <br />
array (<br />
0 => <br />
array (<br />
'path' => '/usr/share/webapps/owncloud/apps',<br />
'url' => '/apps',<br />
'writable' => false,<br />
),<br />
1 => <br />
array (<br />
'path' => '/var/www/owncloud/apps',<br />
'url' => '/wapps',<br />
'writable' => true,<br />
),<br />
),<br />
</pre><br />
Example open_basedir line from {{ic|/etc/php/php.ini}} (you might have other dirs in there as well):<br />
<pre><br />
open_basedir = /srv/http/:/usr/share/webapps/:/var/www/owncloud/apps/<br />
</pre><br />
<br />
Directory permissions:<br />
<pre><br />
$ ls -ld /usr/share/webapps/owncloud/apps /var/www/owncloud/apps/<br />
drwxr-xr-x 26 root root 4096 des. 14 20:48 /usr/share/webapps/owncloud/apps<br />
drwxr-xr-x 2 http http 48 jan. 20 20:01 /var/www/owncloud/apps/<br />
</pre><br />
<br />
== Upload and Share from File Manager ==<br />
You can use the following script to quickly upload and share files to your ownCloud installation from Thunar (and possibly other filemanagers): https://github.com/schiesbn/shareLinkCreator<br />
You need to edit the file with the proper configuration settings.<br />
'''Note: password is stored as plain text.'''<br />
<br />
== See also ==<br />
* [http://owncloud.org/ ownCloud official website]<br />
* [http://doc.owncloud.org/server/8.0/admin_manual/ ownCloud 8.0 Admin Documentation]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Creating_Arch_Linux_disk_image&diff=371613Creating Arch Linux disk image2015-04-28T09:02:47Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Virtualization]]<br />
[[Category:Getting and installing Arch]]<br />
[[ar:Creating Arch Linux disk image]]<br />
This page describes how to create a file that contains a disk image of Arch Linux. This disk image can be run in a virtual machine using software such as [[QEMU]], [[OpenStack]], [[VirtualBox]], or [[VMware]], and it can be customized however you want.<br />
<br />
== Archiso ==<br />
<br />
The [https://archlinux.org/download/ official installation media for Arch Linux] is a hybrid ISO/disk image, so it can already be booted either as a CD-ROM or as a disk. However, it uses an ISO filesystem, so nothing on it can be changed without re-making the installation media.<br />
<br />
You can also create your own live Arch Linux systems using the [[Archiso]] tools.<br />
This may be what you want, but Archiso is only designed for building live systems that boot from a read-only filesystem.<br />
<br />
== Install Arch Linux in a disk image using the installation media ==<br />
<br />
Using [[QEMU]], [[VirtualBox]], or other virtualization software, you can install Arch Linux into a disk image by booting the virtual machine from [https://archlinux.org/download/ the installation media] with the disk image file attached as a virtual hard disk. This is the preferred way to make a virtual disk image containing Arch Linux because other than starting up the virtual machine, the installation will proceed exactly as in the [[Installation guide]].<br />
<br />
== Install Arch Linux in a disk image without the installation media ==<br />
<br />
It is also possible to create a disk image of Arch Linux directly from software and packages on a host Arch Linux system. This has several advantages:<br />
* You do not need to have a copy of [https://archlinux.org/download/ the installation media].<br />
* You can include the most up-to-date software packages in the disk image by installing them directly from the host's package manager, and you can do this before you have even booted up the guest for the first time.<br />
* You can customize the disk image in ways that may not be supported by the official Arch Linux installer.<br />
<br />
However, this method is more difficult than using the installation media. In addition, it will not work if your host machine does not have [[pacman]] (i.e. is not running Arch Linux).<br />
<br />
In these directions, the host system refers to the Arch Linux system you are currently running, while the guest system refers to the Arch Linux system you are creating as a disk image.<br />
<br />
=== Make a file containing the disk image ===<br />
<br />
Create a raw disk image for the virtual machine. In this example, it is made with a size of 1 GiB.<br />
<br />
On file systems supporting the {{ic|fallocate()}} system call:<br />
<br />
$ fallocate -l 1G archlinux.raw<br />
<br />
Otherwise, simply use [[dd]]:<br />
<br />
$ dd of=archlinux.raw bs=1 seek=1G count=0<br />
<br />
{{Note|If you have {{Pkg|qemu}} installed, using ''qemu-img'' is another alternative. See [[QEMU#Creating a hard disk image]] for details.}}<br />
<br />
=== Create filesystem(s) on the virtual disk ===<br />
<br />
==== Use entire disk as one filesystem ====<br />
<br />
If you do not need multiple partitions in your Arch Linux guest, it is easiest to leave the virtual disk unpartitioned and use the whole thing as a filesystem.<br />
<br />
To make an [[Ext4|ext4 filesystem]]:<br />
<br />
$ mkfs.ext4 -F archlinux.raw<br />
<br />
==== Partitioned disk ====<br />
<br />
Or you can partition the disk. In this simple example, it will be given only one partition, and it will be a bootable primary partition formatted as an [[Ext4|ext4 filesystem]] containing the guest's entire filesystem. There will be no [[swap]] partition.<br />
<br />
First partition the disk:<br />
<br />
{{Poor writing|This instruction explains only how and not '''why''', is rather error-prone, and is hard to debug. Why not just link to [[Partitioning]]?}}<br />
<br />
$ fdisk archlinux.raw <<< '<br />
$ > o<br />
$ > n<br />
$ > p<br />
$ > 1<br />
$ ><br />
$ ><br />
$ > a<br />
$ > 1<br />
$ > w'<br />
<br />
Then make the partitions available as loopback devices. The rest of the instructions will assume that the loopback device created for {{ic|archlinux.raw}} is {{ic|/dev/loop0}}, but it will be a higher number if you already have set up loop devices.<br />
<br />
# losetup -f --show archlinux.raw<br />
# kpartx -a /dev/loop0<br />
<br />
{{Note|{{ic|kpartx}} is part of the {{AUR|multipath-tools}} package from the [[Arch User Repository|AUR]]. See [[QEMU#Mounting a partition inside a raw disk image]] for other ways to mount a partition inside a disk image.}}<br />
<br />
Finally make the needed filesystems on the partitions.<br />
<br />
# mkfs.ext4 /dev/mapper/loop0p1<br />
<br />
=== Install packages on the guest's filesystem ===<br />
<br />
Mount the guest's root filesystem on a temporary directory. For convenience, set its path as {{ic|$TMPDIR}}j, which will also be used in the following instructions.<br />
<br />
# TMPDIR=/full/path/to/temporary/directory<br />
<br />
For an unpartitioned disk:<br />
<br />
# mount archlinux.raw $TMPDIR<br />
<br />
or, for a partitioned disk:<br />
<br />
# mount /dev/mapper/loop0p1 $TMPDIR<br />
<br />
Install {{Pkg|arch-install-scripts}} and then install the packages you want on the system (like the {{Grp|base}} group):<br />
<br />
# pacstrap $TMPDIR base<br />
<br />
=== Write a fstab file for the guest ===<br />
<br />
Add any mountpoints to the guest's [[fstab]] file. In this example, we just need a mountpoint for the guest's root filesystem. You do not have to specify it by UUID, but it is a good idea to do so because it guarantees that the root partition will be found regardless of what type of disk is emulated.<br />
<br />
# genfstab -U $TMPDIR >> $TMPDIR/etc/fstab<br />
<br />
And then fix up the paths as necessary.<br />
<br />
=== Generate initramfs for the guest ===<br />
<br />
{{Accuracy|This step may be unnecessary, for me initramfs generation when pacstrap installed the kernel was successful. Perhaps just configure the bootloader to use {{ic|/boot/initramfs-linux-fallback.img}} until the initramfs is regenerated from the VM (using the {{ic|autodetect}} hook)?}}<br />
<br />
As noted earlier, [[initramfs]] generation failed when installing {{Pkg|linux}}. <br />
<br />
You may need to edit {{ic|$TMPDIR/etc/mkinitcpio.conf}} to remove the {{ic|autodetect}} hook, to stop your host system's hardware configuration from removing essential modules (e.g. those needed to access the root filesystem) from the [[initramfs]] of the guest, which is going to be running in a different environment in a virtual machine.<br />
<br />
Generate the initramfs for the guest manually by running the following command:<br />
<br />
# mkinitcpio -g $TMPDIR/boot/initramfs-linux.img -k $TMPDIR/boot/vmlinuz-linux -c $TMPDIR/etc/mkinitcpio.conf<br />
<br />
=== Install bootloader on the guest ===<br />
<br />
For your bootloader, you can choose [[Extlinux]], [[GRUB2]], or another bootloader.<br />
<br />
You may run into some problems when trying to install GRUB2 on a virtual disk. It seems to only work on partition loopback devices created through the device mapper, not those created using the {{ic|loop}} module or setting up a loop device with an offset. In addition, GRUB2 may fail to detect your ext4 filesystem for some reason. It is recommended to try [[#Extlinux|Extlinux]] first, unless you need to use GRUB.<br />
<br />
==== Extlinux ====<br />
<br />
Install Extlinux on the guest's bootable partition:<br />
<br />
# extlinux --install $TMPDIR/boot<br />
<br />
Install Syslinux's MBR in the guest's MBR (only for partitioned disks):<br />
<br />
# dd if=/usr/lib/syslinux/mbr.bin conv=notrunc bs=440 count=1 of=/dev/loop0<br />
<br />
Finally, create a configuration file for Extlinux. Replace {{ic|''UUID''}} with the UUID of the guest's root filesystem, which can be obtained by running {{ic|lsblk -f}}.<br />
<br />
{{hc|$TMPDIR/boot/extlinux.conf|2=<br />
DEFAULT archlinux<br />
LABEL archlinux<br />
SAY Booting Arch Linux<br />
LINUX /boot/vmlinuz-linux<br />
APPEND root=/dev/disk/by-uuid/''UUID'' ro<br />
INITRD /boot/initramfs-linux.img<br />
}}<br />
<br />
{{Note|In order for Extlinux to be booted from the MBR on a partitioned disk, it must be installed on a partition marked as bootable.}}<br />
<br />
==== GRUB2 ====<br />
<br />
In this example, we will install the [[GRUB2]] bootloader on the partitioned disk of the guest.<br />
<br />
Install GRUB2. {{ic|--boot-directory}} must be set to the {{ic|/boot}} directory within the guest's root filesystem, while the given device must be the loopback device corresponding to the guest's entire disk image. Be careful not to overwrite the bootloader of your host system!<br />
<br />
# grub-install --boot-directory=$TMPDIR/boot /dev/loop0<br />
<br />
Then write a {{ic|grub.cfg}} file. Replace {{ic|''UUID''}}, in both places, with the UUID of the guest's root filesystem, which can be obtained by running {{ic|lsblk -f}}.<br />
<br />
{{hc|$TMPDIR/boot/grub/grub.cfg|2=<br />
set default="0"<br />
set timeout="3"<br />
insmod msdospart<br />
insmod ext2<br />
set root='(/dev/sda, msdos1)'<br />
search --no-floppy --fs-uuid --set=root ''UUID''<br />
menuentry "Arch Linux" {<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-uuid/''UUID'' ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
}}<br />
<br />
=== Configure cloud-init ===<br />
This step is optional. Users planning to use the arch linux images on cloud like say to launch in OpenStack would want to perform some early initialization that can be done with cloud-init package. Follow instruction in [[cloud-init]] to configure the package.<br />
<br />
=== Cleanup ===<br />
<br />
You should not boot the guest while its filesystem is still mounted; otherwise, the files on it may be corrupted. Unmount the guest's filesystem and get rid of the loopback devices first.<br />
<br />
# umount $TMPDIR<br />
# kpartx -d /dev/loop0<br />
# losetup -d /dev/loop0<br />
<br />
=== Boot the guest ===<br />
<br />
Finally, boot the guest Arch Linux using your virtualization software of choice, such as [[QEMU]]:<br />
<br />
# qemu archlinux.raw<br />
<br />
=== Other tips ===<br />
<br />
* If you use [[QEMU]], you can specify the guest's kernel and initramfs on the command line. If you do this, you do not need to install a bootloader on the disk image, nor do you need to install the {{Pkg|linux}} package.<br />
<br />
* Since you have full control over the guest's hardware, it is not too hard compile a custom [[Kernels|kernel]] for the guest that has all the needed [[Kernel modules|modules]] built in, if you are familiar with configuring the Linux kernel.<br />
<br />
* You can make copies of your disk image and run multiple Arch Linux virtual machines at the same time.<br />
<br />
* See [[Install from Existing Linux]] for some more general tips about installing Arch Linux from an existing Linux installation that does not necessarily have to be Arch Linux.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Anything-sync-daemon&diff=371612Anything-sync-daemon2015-04-28T09:01:31Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Scripts]]<br />
[[zh-CN:Anything-sync-daemon]]<br />
{{Related articles start}}<br />
{{Related|Profile-sync-daemon}}<br />
{{Related articles end}}<br />
<br />
{{AUR|Anything-sync-daemon}} (asd) is a tiny pseudo-daemon designed to manage user specified directories referred to as sync targets from here on out, in tmpfs and to periodically sync them back to the physical disc (HDD/SSD). This is accomplished via a symlinking step and an innovative use of rsync to maintain synchronization between a tmpfs copy and media-bound backups. Additionally, asd features several crash recovery features.<br />
<br />
== Asd or Psd? ==<br />
{{Warning|If syncing browser profiles is desired, it is recommended NOT to use asd for this purpose. Instead, use [[Profile-sync-daemon]] which has built in sanity checks for unique situations specific to running a browser profile in tmpfs. Anything-sync-daemon does not have these checks; under certain circumstances, browser profile data can be lost. You have been warned.}}<br />
<br />
== Benefits of Asd ==<br />
Design goals of asd:<br />
#Completely transparent user experience.<br />
#Reduced wear to physical discs,<br />
#Speed,<br />
<br />
Since the sync target(s) is relocated into tmpfs (RAM disk), the corresponding onslaught of I/O associated with system usage of them is also redirected from the physical disc to RAM, thus reducing wear to the physical disc and also improving speed and responsiveness. The access time of RAM is on the order of nanoseconds while the access time of physical discs is on the order of milliseconds. This is a difference of six orders of magnitude or 1,000,000 times faster.<br />
<br />
==Setup and Installation==<br />
{{AUR|Anything-sync-daemon}} is available for download from the [[Arch User Repository|AUR]].<br />
<br />
=== Edit /etc/asd.conf ===<br />
<br />
User managed settings are defined in {{ic|/etc/asd.conf}} which is included in the package. <br />
<br />
*At a minimum, define the sync target(s) to be managed by asd in the WHATTOSYNC array. Syntax below.<br />
*Optionally uncomment and define the location of your distro's tmpfs in the VOLATILE variable.<br />
*Optionally enable the use of overlayfs to improve sync speed even further and use a smaller memory footprint. Do this in the USE_OVERLAYFS variable. Note that this option requires a Linux kernel version >=3.18.0. See the FAQ below for additional details on this feature.<br />
<br />
{{Note|The default value of "/dev/shm" should work just fine for the VOLATILE setting. Be aware that using software such as bleachbit with asd can be dangerous since bleachbit likes to remove files stored in /tmp. This is why a value of /dev/shm is recommended.}}<br />
<br />
Example:<br />
WHATTOSYNC=('/var/lib/monitorix' '/srv/http' '/foo/bar')<br />
<br />
or<br />
<br />
WHATTOSYNC=(<br />
'/var/lib/monitorix'<br />
'/srv/http'<br />
'/foo/bar'<br />
)<br />
<br />
=== Using asd ===<br />
=== Preview mode (parse) ===<br />
<br />
The 'parse' option can be called to show users exactly what asd will do/is doing based on the entries in /etc/asd.conf as well printout useful information such as dir size, paths, and if any recovery snapshots have been created.<br />
<br />
$ asd p<br />
Anything-sync-daemon v5.61 on Arch Linux.<br />
<br />
Systemd service is currently active.<br />
Systemd resync service is currently active.<br />
Overlayfs v23 is currently active.<br />
<br />
Asd will manage the following per /run/asd.conf settings:<br />
<br />
owner/group id: root/0<br />
target to manage: /srv/http/serve<br />
sync target: /srv/http/.serve-backup_asd<br />
tmpfs target: /dev/shm/asd-root/srv/http/serve<br />
dir size: 21M<br />
overlayfs size: 15M<br />
recovery dirs: 2 <- delete with the c option<br />
dir path/size: /srv/http/.serve-backup_asd-crashrecovery-20141105_124948 (17M)<br />
dir path/size: /srv/http/.serve-backup_asd-crashrecovery-20150124_062311 (21M)<br />
<br />
owner/group id: facade/100<br />
target to manage: /home/facade/logs<br />
sync target: /home/facade/.logs-backup_asd<br />
tmpfs target: /dev/shm/asd-facadey/home/facade/logs<br />
dir size: 1.5M<br />
overlayfs size: 480K<br />
recovery dirs: none<br />
<br />
=== Clean mode ===<br />
The clean mode will delete ALL recovery snapshots that have accumulated. Run this only if you are sure that you want to delete them.<br />
<br />
{{Note|If a sync target is owned by root or another user, and if asd is called to clean, it will throw errors based on the permissions of the sync targets. One can call this function with sudo or as root to avoid these errors.}}<br />
<br />
{{hc|# asd c|<br />
Anything-sync-daemon v5.61 on Arch Linux.<br />
<br />
Deleting 2 crashrecovery dir(s) for sync target /srv/http/serve<br />
/srv/http/.serve-backup_asd-crashrecovery-20141105_124948<br />
/srv/http/.serve-backup_asd-crashrecovery-20150124_062311<br />
}}<br />
<br />
=== Running asd ===<br />
<br />
Do not call {{ic|/usr/bin/anything-sync-daemon}} to sync or to unsync directly. Instead use the provided service files. <br />
<br />
Both a [[systemd]] [[daemon|service]] file and a timer are provided and should be used to interact with ''asd''. The role of the timer is update the tmpfs copy/copies back to the disk which it does once per hour. The timer starts automatically with {{ic|asd.service}}.<br />
<br />
[[Start]] {{ic|asd.service}} and [[enable]] it to run at boot time/shutdown ('''highly recommended''').<br />
<br />
=== Sync at more frequent intervals (optional) ===<br />
<br />
The package provided timer syncs once per hour. Users may optionally redefine this behavior simply by [[Systemd#Editing_provided_unit_files|extending the systemd unit]]. The example below changes the timer to sync once every ten minutes:<br />
<br />
{{hc|/etc/systemd/system/asd-resync.timer.d/frequency.conf|<nowiki><br />
[Unit]<br />
Description=Timer for Arofile-sync-daemon - 10min<br />
<br />
[Timer]<br />
# Empty value resets the list of timers<br />
OnUnitActiveSec=<br />
OnUnitActiveSec=10min<br />
</nowiki>}}<br />
<br />
See {{ic|man systemd.timer}} for additional options.<br />
<br />
== FAQ ==<br />
=== What is overlayfs and why do I want to use it? ===<br />
<br />
Overlayfs is a simple union file-system mainlined in the Linux kernel version 3.18.0. Starting with asd version 5.54, overlayfs can be used to reduce the memory footprint of asd's tmpfs space and to speed up sync and unsync operations. The magic is in how the overlay mount only writes out data that has changed rather than the entire directory. See Example 1 below. The same recovery features asd uses in its default mode are also active when running in overlayfs mode. Overlayfs mode is enabled by uncommenting the USE_OVERLAYFS="yes" line in /etc/asd.conf followed by a restart of the daemon.<br />
<br />
See the example in the preview mode section above which shows system using overlayfs to illustrate the memory savings that can be achieved. Note the "overlayfs size" report compared to the total "dir size" report for each sync target. Be aware that these numbers will change depending on just how much data is written to the sync target, but in common use cases, the overlayfs size will always be less than the dir size.<br />
<br />
=== My system crashed and did not sync back. What do I do? ===<br />
<br />
Odds are the "last good" backup of your sync target(s) is just fine still sitting happily on your filesystem. Upon restarting asd (on a reboot for example), a check is preformed to see if the symlink to the tmpfs copy of your sync target is valid. If it is invalid, asd will snapshot the "last good" backup before it rotates it back into place. This is more for a sanity check that asd did no harm and that any data loss was a function of something else.<br />
<br />
=== Where can I find this snapshot? ===<br />
<br />
You will find the snapshot in the same directory as the sync target and it will contain a date-time-stamp that corresponds to the time at which the recovery took place. For example, a /foo/bar snapshot will be /foo/.bar-backup_asd-crashrecovery-20141221_070112 -- of course, the date_time suffix will be different for you.<br />
<br />
=== How can I restore the snapshot? ===<br />
<br />
* Stop {{ic|asd}}.<br />
* Confirm that there is no symlink to the sync target. If there is, ''asd'' did not stop correctly for other reasons.<br />
* Move the "bad" copy of the sync target to a backup (do not blindly delete anything).<br />
* Copy the snapshot directory to the expected sync target.<br />
<br />
Example using /foo/bar<br />
mv /foo/bar /for/bar-bad<br />
cp -a /foo/.bar-backup_asd-crashrecovery-20141221_070112 /foo/bar<br />
<br />
=== Can asd delete the snapshots automatically? ===<br />
<br />
Yes, run asd with the "clean" switch to delete snapshots.<br />
<br />
== Support ==<br />
Post in the [https://bbs.archlinux.org/viewtopic.php?id=139141 discussion thread] with comments or concerns.</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Go_package_guidelines&diff=371611Go package guidelines2015-04-28T09:00:25Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Package development]]<br />
{{Package guidelines}}<br />
<br />
[[Wikipedia:Go (programming language)|Go]] is well supported on Arch Linux.<br />
<br />
The {{Pkg|go}} package contains the '''go''' tool (for running {{Ic|go fix}}, {{Ic|go build}} etc). There is also {{Pkg|gcc-go}} which provides {{Ic|gccgo}}.<br />
<br />
= General guidelines =<br />
<br />
== Naming ==<br />
* For applications written in Go, use the name of the application as the package name, in lowercase.<br />
** Be creative if the name is already taken.<br />
* For libraries written in Go, use {{Ic|go-''modulename''}}, in lowercase.<br />
** If the name already starts with {{Ic|go-}}, do not call the package {{Ic|go-''go-modulename''}}, but just {{Ic|go-''modulename''}}.<br />
* For PKGBUILDS that uses the "go" tool to download the package, only add "-git" to the package name if it is not built from a tarball or a from a tagged release (but from trunk/HEAD).<br />
** Similarly for mercurial packages, only add "-hg" to the package name if it is not a release-revision.<br />
** Extend this pattern for other version control systems.<br />
** The go tool has its own logic for which branch or tag it should use. See {{Ic|go get --help}}.<br />
* Consider adding the name of the author to the package name if there are several applications that are named the same, like {{AUR|dcpu16-kballard}}.<br />
** In general, the most popular packages should be allowed to use the shortest or "best" name.<br />
* Postfixes to the package names (like {{Ic|-hg}}, {{Ic|-git}} or {{Ic|-svn}}) are optional if there are no official releases from the project in question. On one hand, it is common to use them when the package downloads from a VCS. On the other hand, most Go projects do not have any release-tarballs, only the repo which is used for branching/tagging the official release, if it is not ''trunk''. Also, {{Ic|go get}}, which is the "official" way to install Go modules, uses the repositories directly. Use your better judgement.<br />
<br />
== Packaging ==<br />
* Go projects are either just library files, just executables or both. Choose the appropriate way of packaging them. There are several examples below.<br />
* Some Go applications or libraries have not been updated to the latest version of Go yet.<br />
** Running {{Ic|go build -fix}} may often work, but it may have to be fixed by the developer. Report an issue upstream if this is the case.<br />
* Several Go projects do not have a version number or a license file.<br />
** Use license=('unknown') and report an issue to the developer if a license file is missing.<br />
** Use version "0.1", "1" or the git-revision (or equivalent for other version control systems) if the version number is missing.<br />
** Alternatively, use the current date as the version number, in this form {{Ic|YYYYMMDD}}.<br />
* Since Go applications are usually statically compiled, it is hard to envision reasons for packaging Go libraries instead of just Go applications.<br />
<br />
= Sample PKGBUILDs =<br />
<br />
== Sample PKGBUILD for an application written in Go ==<br />
<br />
{{bc|<nowiki># Maintainer: NAME <EMAIL><br />
<br />
pkgname=PACKAGE NAME<br />
pkgver=1.2.3<br />
pkgrel=1<br />
pkgdesc="PACKAGE DESCRIPTION"<br />
arch=('x86_64' 'i686')<br />
url="http://SERVER/$pkgname/"<br />
license=('MIT')<br />
makedepends=('go')<br />
options=('!strip' '!emptydirs')<br />
source=("http://SERVER/$pkgname/$pkgname-$pkgver.tar.gz")<br />
sha256sums=('00112233445566778899aabbccddeeff')<br />
<br />
build() {<br />
cd "$pkgname-$pkgver"<br />
<br />
go build<br />
}<br />
<br />
package() {<br />
cd "$pkgname-$pkgver"<br />
<br />
install -Dm755 "$pkgname-$pkgver" "$pkgdir/usr/bin/$pkgname"<br />
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"<br />
}<br />
<br />
# vim:set ts=2 sw=2 et:</nowiki>}}<br />
<br />
=== Sample packages ===<br />
* {{Pkg|gendesk}}<br />
* {{AUR|dcpu16}}<br />
<br />
== Sample PKGBUILD for when only a single source file is available ==<br />
<br />
{{bc|<nowiki># Maintainer: NAME <EMAIL><br />
<br />
pkgname=PACKAGE NAME<br />
pkgver=1.2.3<br />
pkgrel=1<br />
pkgdesc="PACKAGE DESCRIPTION"<br />
arch=('x86_64' 'i686')<br />
url="http://SERVER/$pkgname/"<br />
license=('GPL3')<br />
makedepends=('go')<br />
options=('!strip' '!emptydirs')<br />
source=("http://SERVER/$pkgname/$pkgname.go")<br />
sha256sums=('00112233445566778899aabbccddeeff')<br />
<br />
build() {<br />
go build -o "$pkgname"<br />
}<br />
<br />
package() {<br />
install -Dm755 "$pkgname" "$pkgdir/usr/bin/$pkgname"<br />
}<br />
<br />
# vim:set ts=2 sw=2 et:</nowiki>}}<br />
<br />
=== Sample packages ===<br />
* {{AUR|gorun}}<br />
<br />
== Sample PKGBUILDs for Go libraries that also includes executables ==<br />
<br />
=== Using ''go get'' ===<br />
<br />
This is the recommended way, instead of the method below.<br />
<br />
Here is a way that relies on go get.<br />
<br />
You probably will not need to modify the build() or package() functions at all, only the variables at the top (pkgname etc).<br />
<br />
If this does not work, test with go get first.<br />
<br />
{{Note| Remove {{Ic|/...}} if the PKGBUILD fails!}}<br />
<br />
{{bc|<nowiki># Maintainer: NAME <EMAIL><br />
<br />
pkgname=codesearch<br />
pkgver=20120515<br />
pkgrel=1<br />
pkgdesc="Code indexing and search written in Go"<br />
arch=('x86_64' 'i686')<br />
url="http://code.google.com/p/codesearch"<br />
license=('BSD')<br />
depends=('go')<br />
makedepends=('mercurial')<br />
options=('!strip' '!emptydirs')<br />
_gourl=code.google.com/p/codesearch<br />
<br />
build() {<br />
GOPATH="$srcdir" go get -fix -v -x ${_gourl}/...<br />
}<br />
<br />
check() {<br />
GOPATH="$GOPATH:$srcdir" go test -v -x ${_gourl}/...<br />
}<br />
<br />
package() {<br />
mkdir -p "$pkgdir/usr/bin"<br />
install -p -m755 "$srcdir/bin/"* "$pkgdir/usr/bin"<br />
<br />
mkdir -p "$pkgdir/$GOPATH"<br />
cp -Rv --preserve=timestamps "$srcdir/"{src,pkg} "$pkgdir/$GOPATH"<br />
<br />
# Package license (if available)<br />
for f in LICENSE COPYING LICENSE.* COPYING.*; do<br />
if [ -e "$srcdir/src/$_gourl/$f" ]; then<br />
install -Dm644 "$srcdir/src/$_gourl/$f" \<br />
"$pkgdir/usr/share/licenses/$pkgname/$f"<br />
fi<br />
done<br />
}<br />
<br />
# vim:set ts=2 sw=2 et:</nowiki>}}<br />
<br />
Thanks to Rémy Oudompheng for this one.<br />
<br />
=== Using ''go get'' ===<br />
<br />
Here is another way that relies on {{Ic|go get}}.<br />
<br />
You probably will not need to modify the build() or package() functions at all, only the variables at the top (pkgname etc).<br />
<br />
If this does not work, test with {{Ic|go get}} first.<br />
<br />
{{bc|<nowiki># Maintainer: NAME <EMAIL><br />
<br />
pkgname=PACKAGE NAME<br />
pkgver=1.2.3<br />
pkgrel=1<br />
pkgdesc="PACKAGE DESCRIPTION"<br />
arch=('x86_64' 'i686')<br />
url="http://SERVER/$pkgname/"<br />
license=('MIT')<br />
makedepends=('go' 'git')<br />
options=('!strip' '!emptydirs')<br />
_gourl=SERVER.NET/PATH/MODULENAME<br />
<br />
build() {<br />
export GOROOT=/usr/lib/go<br />
<br />
rm -rf build<br />
mkdir -p build/go<br />
cd build/go<br />
<br />
for f in "$GOROOT/"*; do<br />
ln -s "$f"<br />
done<br />
<br />
rm pkg<br />
mkdir pkg<br />
cd pkg<br />
<br />
for f in "$GOROOT/pkg/"*; do<br />
ln -s "$f"<br />
done<br />
<br />
platform=`for f in "$GOROOT/pkg/"*; do echo \`basename $f\`; done|grep linux`<br />
<br />
rm "$platform"<br />
mkdir "$platform"<br />
cd "$platform"<br />
<br />
for f in "$GOROOT/pkg/$platform/"*.h; do<br />
ln -s "$f"<br />
done<br />
<br />
export GOROOT="$srcdir/build/go"<br />
export GOPATH="$srcdir/build"<br />
<br />
go get -fix "$_gourl"<br />
<br />
# Prepare executable<br />
if [ -d "$srcdir/build/src" ]; then<br />
cd "$srcdir/build/src/$_gourl"<br />
go build -o "$srcdir/build/$pkgname"<br />
else<br />
echo 'Old sources for a previous version of this package are already present!'<br />
echo 'Build in a chroot or uninstall the previous version.'<br />
return 1<br />
fi<br />
}<br />
<br />
package() {<br />
export GOROOT="$GOPATH"<br />
<br />
# Package go package files<br />
for f in "$srcdir/build/go/pkg/"* "$srcdir/build/pkg/"*; do<br />
# If it's a directory<br />
if [ -d "$f" ]; then<br />
cd "$f"<br />
mkdir -p "$pkgdir/$GOROOT/pkg/`basename $f`"<br />
for z in *; do<br />
# Check if the directory name matches<br />
if [ "$z" == `echo $_gourl | cut -d/ -f1` ]; then<br />
cp -r $z "$pkgdir/$GOROOT/pkg/`basename $f`"<br />
fi<br />
done<br />
cd ..<br />
fi<br />
done<br />
<br />
# Package source files<br />
if [ -d "$srcdir/build/src" ]; then<br />
mkdir -p "$pkgdir/$GOROOT/src/pkg"<br />
cp -r "$srcdir/build/src/"* "$pkgdir/$GOROOT/src/pkg/"<br />
find "$pkgdir" -depth -type d -name .git -exec rm -r {} \;<br />
fi<br />
<br />
# Package license (if available)<br />
for f in LICENSE COPYING; do<br />
if [ -e "$srcdir/build/src/$_gourl/$f" ]; then<br />
install -Dm644 "$srcdir/build/src/$_gourl/$f" \<br />
"$pkgdir/usr/share/licenses/$pkgname/$f"<br />
fi<br />
done<br />
<br />
# Package executables<br />
if [ -e "$srcdir/build/$pkgname" ]; then<br />
install -Dm755 "$srcdir/build/$pkgname" \<br />
"$pkgdir/usr/bin/$pkgname"<br />
fi<br />
}<br />
<br />
# vim:set ts=2 sw=2 et:</nowiki>}}</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Pacaur&diff=371610Pacaur2015-04-28T08:58:18Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>[[Category:Package management]]<br />
[[Category:Arch User Repository]]<br />
'''Pacaur''' is an [[Arch User Repository]] (AUR) [[AUR helpers|helper]] aiming at speed and simplicity, designed to minimize user prompt interaction and to use an uncluttered interface. It is written in Bash and built upon the well designed cower and expac C backends.<br />
<br />
{{note|Pacaur is targeted at '''advanced users''' who want some degree of automation for repetitive tasks. As such, the user is expected to be familiar with the [[Arch User Repository|manual build process]]. }}<br />
<br />
{{warning|Since version 4.2, pacaur supports '''split packages''' and solves the dependency tree using the '''fully secured''' extended RPC AUR interface by default. Packages which are missing AUR metadata may however not provide correct dependency information and a warning will be displayed.<br />
<br />
All packages uploaded to the AUR before 2014-05-27 18:35 UTC (AUR 3.0.0 release) and packages that use architecture-specific fields uploaded to the AUR before 2014-12-29 02:37 UTC (pacman 4.2 release in [core]) are concerned and should be reuploaded by their respective maintainers. If you encounter such packages, please notify their maintainer about their missing AUR metadata status.}}<br />
<br />
==Philosophy==<br />
<br />
Pacaur's main feature revolves around a ''fast workflow'' idea, that is, '''spending as little time as possible interacting with package management prompts'''. Speed, simplicity and the need for an uncluttered interface were also taken into consideration.<br />
<br />
A few characteristics:<br />
<br />
Fast<br />
* minimizes user interaction.<br />
* retrieves and edits all PKGBUILDs, solves all conflicts and asks about providers before building anything.<br />
* very good performance with a small memory footprint.<br />
<br />
Simple<br />
* does not add a lot of features, but simply extends pacman to manage the AUR.<br />
* small bash script using existing tiny libraries.<br />
* based on the libalpm C interface directly maintained by a pacman developer.<br />
<br />
Powerful<br />
* fully supports split packages with proper independent subpackages installation.<br />
* solves the dependency tree entirely through the AUR RPC interface.<br />
* searches with regex support (through cower).<br />
* prompts automatically for sudo password.<br />
* can be used as a separate AUR frontend, or a single tool to manage official and AUR packages.<br />
* shows current and available versions when checking for updates.<br />
* provides binary and AUR package names completion.<br />
<br />
==Installation==<br />
<!-- Please do not add direct commands to install pacaur. All users should be familiar with the build process. --><br />
<br />
The following binary dependencies need to be installed:<br />
* {{pkg|sudo}} [core]<br />
* {{pkg|expac}} [community]<br />
<br />
You can then install {{AUR|cower}} as a dependency, and then {{AUR|pacaur}} itself. Both of those packages are available in the [[Arch User Repository|AUR]].<br />
<br />
==Usage==<br />
<br />
Invoking pacaur consists of supplying an operation, any applicable options, and usually one or more targets.<br />
<br />
<pre><br />
usage: pacaur <operation> [options] [target(s)]<br />
operations:<br />
pacman extension<br />
-S, -Q extend pacman operations to the AUR<br />
AUR only<br />
-s, --search search AUR repository for matching strings<br />
-i, --info view package information<br />
-d, --download download target(s) -- pass twice to download AUR dependencies<br />
-m, --makepkg download and make target(s)<br />
-y, --sync download, make and install target(s)<br />
-k, --check check for AUR update(s)<br />
-u, --update update AUR package(s)<br />
general<br />
-v, --version display version information<br />
-h, --help display help information<br />
<br />
options:<br />
pacman extension - can be used with the -S, -Ss, -Si, -Sii, -Sw, -Su, -Qu, -Sc, -Scc operations<br />
-a, --aur only search, install or clean target(s) from the AUR<br />
-r, --repo only search, install or clean target(s) from the repositories<br />
general<br />
-e, --edit edit target(s) PKGBUILD and view install script<br />
-c, --clean clean target(s) build files -- can be combined with the -m, -y, -u operations<br />
-q, --quiet show less information for query and search<br />
--devel consider AUR development packages upgrade<br />
--ignore ignore a package upgrade (can be used more than once)<br />
--needed do not reinstall already up to date target(s)<br />
--noconfirm do not prompt for any confirmation<br />
--noedit do not prompt to edit files<br />
--rebuild always rebuild package(s)<br />
</pre><br />
<br />
===Userbase target===<br />
<br />
Pacaur has two types of users in mind:<br />
* those who prefer to have one single tool to manage AUR and official repositories,<br />
* those who prefer to keep their AUR frontend separate from Pacman.<br />
<br />
As such there are two sets of commands: <br />
* commands that wrap the pacman binary (-S, -Ss, -Si, -Sw. -Su, -Qu, -Sc) and extend its functions to the AUR. This behavior can be disabled with the fallback variable in the config file.<br />
* commands that are AUR specific (-s, -i, -m, -y, -k, -u).<br />
<br />
===Example===<br />
<br />
By default, pacaur -Ss ''package'' will search the repo, then the AUR if necessary.<br />
<br />
$ pacaur -Ss expac<br />
community/expac 1-2<br />
pacman database extraction utility<br />
aur/expac-git 20110324-1 (24)<br />
pacman database extraction utility<br />
<br />
This behavior is optional and can be disabled with the ''fallback'' variable in the config file. When disabled, pacaur -Ss ''package'' will search the repo only.<br />
<br />
Also, pacaur -Ssr ''package'' will be restricted to searching in the repo only, while pacaur -Ssa ''package'' will search the AUR.<br />
<br />
$ pacaur -Ssr expac<br />
community/expac 1-2<br />
pacman database extraction utility<br />
<br />
$ pacaur -Ssa expac<br />
aur/expac-git 20110324-1 (24)<br />
pacman database extraction utility<br />
<br />
pacaur -s ''package'' will search the AUR only.<br />
<br />
$ pacaur -s expac<br />
aur/expac-git 20110324-1 (24)<br />
pacman database extraction utility<br />
<br />
==Configuration==<br />
<br />
Here are the available options in the config file:<br />
<pre><br />
#!/bin/bash<br />
<br />
#<br />
# /etc/xdg/pacaur/config<br />
#<br />
<br />
# The following options are commented out with their default values listed.<br />
# If you wish to use different values, uncomment and update the values.<br />
# The Color and VerbosePkgLists options can be enabled in /etc/pacman.conf.<br />
#builddir="${BUILDDIR:-$tmpdir}" # build directory<br />
#editor="${EDITOR:-vi}" # PKGBUILD editor<br />
#editpkgbuild=true # edit PKGBUILD script<br />
#editinstall=true # edit install script<br />
#fallback=true # pacman fallback to the AUR<br />
#clean=true # clean up after package install<br />
#cleandevel=true # clean up devel package<br />
#sortbyvotes=true # sort search results by votes<br />
#sudoloop=false # prevent sudo timeout<br />
</pre><br />
<br />
See also '''man pacaur'''.<br />
<br />
=== Config files ===<br />
Pacaur fully honors pacman and makepkg configuration files, as well as the sudoers and cower config file (if existing).<br />
<br />
In particular, the following options in {{ic|/etc/pacman.conf}} can be used for further configuration:<br />
* '''Colors''' to enable colored output.<br />
* '''VerbosePkgLists''' to display the name, version and size of target packages formatted as a table.<br />
<br />
Note that pacman and makepkg '''environment variables''' ({{ic|$BUILDDIR}}, {{ic|$PKGDEST}}, {{ic|$PACMAN}}, ...) are fully honored.<br />
<br />
=== Sudo configuration ===<br />
Pacaur is designed to be used with [[sudo]] for minimal password prompting and your {{ic|/etc/sudoers}} should be configured accordingly.<br />
<br />
To avoid password prompt timeout (typically if you went grabbing a coffee while waiting the build to finish), disable it in your sudoers:<br />
<pre><br />
Defaults passwd_timeout=0<br />
</pre><br />
<br />
Alternatively, enable the '''sudoloop''' option in the config file.<br />
<br />
=== Auto completion ===<br />
<br />
==== Bash ====<br />
<br />
Because of speed issue, AUR completion is disabled by default.<br />
<br />
You can enable it by uncommenting this line in the {{ic|/usr/share/bash-completion/completions/pacaur}} file:<br />
<br />
# S) _pacman_pkg Slq; _cower_pkg;; # disabled. Too slow and no fallback var support.<br />
<br />
==== Zsh ====<br />
<br />
You can disable AUR completion using the following zstyle:<br />
<br />
zstyle ':completion:*:pacaur:*' remote-access false<br />
<br />
The name `remote-access` mimics other completion zstyles like _cvs and _scp<br />
that use this for deciding whether to complete remote files or not.<br />
<br />
==Troubleshooting==<br />
<br />
{{note|Most complicated errors result from out-dated pacaur/cower package in your system, in case you did not even understand what the error is about and/or cannot find any solution, try explicitly updating your pacaur/cower first. }}<br />
<br />
===No results found for error===<br />
<br />
{{Merge|AUR helpers|This is due to a soname bump in libalpm, and other AUR helpers are affected by this}}<br />
<br />
If pacman or its dependencies are updated, pacaur may output "no results found for error". If this occurs, you may need to [[Arch_User_Repository#Acquire_build_files|rebuild]] the {{AUR|cower}} backend.<br />
<br />
===Host name error===<br />
When checking AUR packages for updates, pacaur outputs a lot of "Couldn't resolve host name" and "Timeout was reached" messages in spite of the internet line working correctly.<br />
* [[General recommendations#DNS_speed_improvement|Configure your DNS server]] to improve queries speed. Try using Google primary DNS (8.8.8.8 and 8.8.4.4).<br />
* Alternatively, tweak cower's config file to decrease the number of threads used in "MaxThread" variable.<br />
<br />
===Using gvim as editor===<br />
When using gvim as editor, gvim opens but the build continues. In the config file, try:<br />
<br />
<pre><br />
editor="gvim --nofork"<br />
</pre><br />
<br />
==Improving pacaur==<br />
<br />
===Internationalization===<br />
See [https://github.com/Spyhawk/pacaur/blob/master/po/HOWTO Internationalization howto].<br />
<br />
===Bug reports===<br />
When reporting problems, please:<br />
<br />
* check whether "makepkg -si" can build and install a package successfully. As pacaur relies exclusively on makepkg to build and install packages, the PKGBUILD must be corrected by its maintainer if makepkg fails.<br />
* check whether the package and its dependencies provide AUR metadata.<br />
* check that the problem is reproducible, and is not caused by a misconfiguration of pacaur/pacman/makepkg/sudoers/gpg/etc.<br />
* post the ouput of "bash -x pacaur <your command>" in the [https://bbs.archlinux.org/viewtopic.php?pid=937423 forum thread] or on [https://github.com/Spyhawk/pacaur github] to help debug the issue.<br />
<br />
===Feature requests===<br />
Pacaur is considered as being "feature complete" and will most probably not include any new features. However, any improvement request or patch will be considered, and might be implemented as long as the objectives of speed, simplicity, fast workflow, uncluttered interface and the Arch way are respected.<br />
<br />
==See also==<br />
* [https://bbs.archlinux.org/viewtopic.php?pid=937423 Forum page]<br />
* [https://github.com/rmarquis/pacaur pacaur's github page]</div>Infinitehhttps://wiki.archlinux.org/index.php?title=User:Andy_Crowd/Update_packages_from_crontab&diff=371609User:Andy Crowd/Update packages from crontab2015-04-28T08:56:55Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Package management]]<br />
{{Related articles start}}<br />
{{Related|Recovery after failed update or upgrade}}<br />
{{Related articles end}}<br />
<br />
{{Warning|'''Doing automatic updates from cron is strongly discouraged. It is likely to leave your machine in a broken and unbootable state.'''<br />
If this breaks your machine, do not hold anyone but yourself responsible. You have been warned. }}<br />
== Do not try this at home! ==<br />
<br />
So, proceed only if you have balls of steel or you were intending to crash your machine anyway. If so, you might as well do it the "right way".<br />
<br />
# First, you (obviously!) need to [[cron|install cron itself]]. Do that first.<br />
# It is highly recommended to also install a mail transfer agent, such as [[Postfix]], to send you notifications if pacman fails.<br />
# Run as root: {{ic|crontab -e}}<br />
# Copy-paste this to your crontab:<br />
<br />
{{bc|<nowiki><br />
MAILTO=your@email<br />
LOGFILE=/var/log/cron-pacman.log<br />
<br />
# 1. minute (0-59)<br />
# | 2. hour (0-23)<br />
# | | 3. day of month (1-31)<br />
# | | | 4. month (1-12)<br />
# | | | | 5. day of week (0-7: 0 or 7 is Sun, or use names)<br />
# | | | | | 6. commandline<br />
# | | | | | |<br />
#min hr dom mon dow command<br />
00 13 * * * . /etc/profile && (echo; date; yes |pacman -Syuq) &>>$LOGFILE || (echo 'pacman failed!'; tail $LOGFILE; false)<br />
</nowiki>}}To check every */time you must use e.g. {{ic|*/2}} to check every 2 min or any other time value.<br />
<br />
If you want to automatically reboot your computer upon a successful upgrade, append '&& reboot' to the above line.<br />
<br />
== Do try this at home! ==<br />
Instead of using `pacman -Syuq` above, use `pacman -Syuwq`. The '-w' will cause pacman to "retrieve all packages from the server, but do not install/upgrade anything." While you will still have to manually update your system, you will not have to wait (as long) for packages to download while doing so.<br />
<br />
== Manual set up of auto-update ==<br />
<br />
{{Note|The sections below are mostly focused on setting up Linux on computer for the home user.}}<br />
<br />
{{Warning|<br />
* The [https://userbase.kde.org/KCron KCron] and [https://wiki.gnome.org/Schedule GNOME Schedule] can use own wrappers inside crontab to run scheduled tasks that will cause problems such as use of the {{ic|pacman-db-upgrade}} may leave the {{ic|/var/lib/pacman/db.lck}} lock file that will prevent run of the next {{Pkg|pacman}} command.<br />
* You must make backup of [[Pacman_tips#Backing_up_Local_database_with_systemd|pacman database]] before giving computer to user.}}<br />
<br />
If you want to set up Arch Linux for home user and still keep system up to date you will need to make work in background without distraction of user. <br />
<br />
=== Update notifier ===<br />
<br />
There are many programs such as {{Pkg|zenity}} that can show GUI messages from program or scripts that runs in console. In this example you will see a dialog with list with file names and size for each of them that need to be downloaded for installation. By clicking Yes it will return exit code 0 respective 1 for No that will be placed in the [http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html $?] variable.<br />
<br />
{{bc|<nowiki>$ zenity --question --text="$(pacman -Qu|awk '//{if(index($0,"[ignored]") == 0 )print $1 }'|pacman -Si -|grep ^[a-Z]| \<br />
sed 's/ //g'| awk -F':' '//{ZZ=ZZ+1;XX[ZZ]=$1;SS[ZZ]=$2;} <br />
END{AA=ZZ/18;for(i=1;i <= AA;i++){print XX[i*18-16]": "SS[18*i-16]" | "XX[i*18-4]": "SS[i*18-4];}}' )"</nowiki>}}<br />
<br />
For a long list of updates is better to use this example and {{ic|zenity}} can also read data from stdin. <br />
<br />
{{bc|<nowiki>$ pacman -Qu |awk '//{if(index($0,"[ignored]") == 0 )print $1 }'|pacman -Si -|grep ^[a-Z]|\<br />
sed 's/ //g'|awk -F':' '//{ZZ=ZZ+1;XX[ZZ]=$1;SS[ZZ]=$2;}<br />
END{AA=ZZ/18;for(i=1;i <= AA;i++){print XX[i*18-16]": "SS[18*i-16]" | "XX[i*18-4]": "SS[i*18-4];}}' | zenity --text-info --title=Uppdateringar</nowiki>}}<br />
<br />
Is suitable to use after updates has been downloaded.<br />
<br />
This will show progress bar. Depends on amount of repositories you will need to calculate correct step size, you can do it simply by dividing 100 with amount of lines printed by [[pacman]] or use {{ic|1=LCount=$(grep ^"\[" /etc/pacman.conf -c);echo $((100/LCount)) }} to calculate and pass it to the [https://www.gnu.org/software/gawk/manual/html_node/Using-Shell-Variables.html awk] command.<br />
<br />
$ pacman -Sy --noprogressbar |awk '{AA=AA+16.7;system("echo "AA)}' | zenity --progress --no-cancel<br />
<br />
In comparison to {{Pkg|zenity}} the program {{ic|xmessage}} from {{Pkg|xorg-xmessage}} package shows much smaller windows but does not support UTF and has some more limitations but here we will not discuss them, it is just a perfect light notifier.<br />
<br />
{{bc|1=...........<br />
...........<br />
STARTit=$(date '+%M-%S')<br />
xmessage -timeout 2 "Starting downloading of updates" & disown<br />
...........<br />
...........<br />
ENDit="$(date '+%M-%S')"<br />
xmessage -timeout 3 "${STARTit}"' * '"${ENDit}" & disown<br />
...........<br />
...........}}<br />
<br />
See also: [http://stackoverflow.com/questions/7035/how-to-show-a-message-box-from-a-bash-script-in-linux How to show a message box from a bash script in Linux].<br />
<br />
Before running {{ic|pacman}} you can also add integrity of database check:<br />
<br />
{{bc|1=testdb -b "/var/lib/pacman/"<br />
if [ ${?} != "0" ];then <br />
zenity --warning --text="Databasfilen är skadat. Kontakta Admin!";<br />
exit 1;<br />
fi}}<br />
<br />
=== Download updates ===<br />
<br />
The easiest way of creating a short list of updates is by creating the script that will print them to stdout, e.g.<br />
{{hc|ShortListUpdates.sh|<nowiki><br />
#!/bin/bash<br />
pacman -Qq | \<br />
grep -e smplayer \<br />
-e smtube \<br />
-e ^jre \<br />
-e ^gst \<br />
-e firefox | \<br />
grep -v -e 'to_ignore_package1' -e 'to_ignore_package2' -e 'to_ignore_package3'<br />
#Files from a group to add<br />
pacman -Qqg kde | grep -v -e 'to_ignore_package1' -e 'to_ignore_package2' -e 'to_ignore_package3'<br />
</nowiki>}}<br />
<br />
Good to download updates after few hours of idle and limit it only to a day time and make similar just that will download and possible also install updates at night time if computer is powered on. To speed up update process at night and lower possible damage add some of packages to [[Pacman#Skip_package_from_being_upgraded|ignore list]], such as fonts, kernel and mkinitcpio or any other that you think is not at all necessary to be updated. But still you can make a script that user can manually run to update all packages, e.g. {{ic|<nowiki>pacman -Qqen | pacman -S --needed --noconfirm -</nowiki>}} but do not forget to add safety check of battery status if it is a laptop. <br />
<br />
Steps for downloading process<br />
<br />
# Check if stop mark after download exist, e.g. {{ic|if [ ! -f /tmp/.downloaded_yes ];then echo Is OK to download;else echo Already downloaded;fi}}<br />
# Check if computer is idle and how long time. Utilities {{AUR|xprintidle}}[http://www.ruddwire.com/handy-code/date-to-millisecond-calculators/] for X and command {{ic|w}} for tty.<br />
# Check if computer is connected with cable or how much battery is charged. You will need to install {{Pkg|upower}}. {{bc|<nowiki>#!/bin/bash<br />
<br />
MAXpower="60"<br />
<br />
ST=($(upower -i "$(upower -e | grep 'BAT')" | grep -e "state" -e percentage | awk '{print $2}' | sed 's/%//g'))<br />
if [ ! -z ${ST[0]} ];then<br />
if [ ${ST[1]} -gt ${MAXpower} ] || [ ${ST[0]} == 'charging' ] || [ ${ST[0]} == 'fully-charged' ]; then<br />
echo "OK"<br />
else<br />
echo "Fail"<br />
fi<br />
else <br />
echo "OK"<br />
fi</nowiki>}}<br />
# Check type of connection to prevent downloading due huge amount of data if computer using 3G or other PPP connection. Command {{ic|<nowiki>ifconfig | grep ^ppp -c</nowiki>}}.<br />
# Check if is online {{ic|1=ping -c 1 8.8.8.8 ; if [ "${?}" != "0" ]; then echo bad; else echo good; fi}}, if the firewall is blocking ping requests then you can use {{ic|<nowiki>ifconfig | grep -v 'lo:' | grep RUNNING -c</nowiki>}} or by trying to download a file and check if no errors accrued during downloading.<br />
# Make a short list of the most important updates, e.g. for average internet user will be good to have a web-browser and its plugins,extensions, certifications and SSL componets and some of media players that you configured as default will need to be downloaded. {{Note|Do not make list too big for daily downloads and do not start installation directly after them were downloaded to avoid possible conflicts.}}<br />
# Create a stop mark to prevent multiple update checks after download were finished, e.g. {{ic|echo downloaded > /tmp/.downloaded_yes}}.<br />
<br />
{{Note|The stop mark can be also created after all checks are passed in case if check of idle time is too low and download time might take more time depends on the connection and total size of updates.}}<br />
<br />
=== Download and install updates from short list ===<br />
<br />
To download updates from the short list you can use this line {{ic|pacman -Sw --noconfirm --needed $(/full/path/to/ShortListUpdates.sh)}}.<br />
<br />
You will need to add only a power check before continue with installation of updates.<br />
<br />
{{bc|<nowiki><br />
...............<br />
...............<br />
yes | pacman -S --noconfirm --needed $(/full/path/to/ShortListUpdates.sh)<br />
systemctl daemon-reload<br />
sleep 2<br />
...............<br />
...............</nowiki>}}<br />
<br />
If you will use a GUI notifier then you may want to use this part in the begin of the update script if updates runs after reboot and user comes to log in screen([[Display manager]]). Be careful with the {{ic|sleep}} timeout if too low it might freeze the screen. The notifier will be shown even on the login screen that will probably make user wait until updates are finished or after user logged if you will set ''sleep'' timeout too high and user logged in before script started.<br />
<br />
{{bc|1=#!/bin/bash<br />
sleep 5<br />
if [ "$(pgrep X -c)" != "0" ]; then<br />
export DISPLAY=:0<br />
else<br />
export DISPLAY=:0<br />
startx "$0"<br />
fi<br />
.........<br />
.........<br />
.........<br />
}}<br />
<br />
You may also will make it remove unnecessary locales for spell check in e.g. {{ic|/usr/include/hunspell}}, {{ic|/usr/lib/aspell-0.60}} or any other that contains unnecessary files that created after update or install of packages.<br />
<br />
In the crone you can schedule installation of updates from a short list on each boot by using in {{ic|crontab}}: <br />
@reboot /usr/local/bin/update<br />
<br />
{{Note|You can also make it copy the update-downloading scripts to {{ic|/tmp}} to minimize disk usage because the {{ic|/tmp}} is using RAM for storage of files.}}<br />
<br />
=== Download and install at night ===<br />
<br />
If user will leave computer powered on at night then this example could be used to download and install after computer become idle for a some time to be more sure that user will not interrupt. <br />
<br />
{{bc|<nowiki>..............<br />
..............# Battery and connection safety checks<br />
..............<br />
yes | pacman -S --needed $(pacman -Ssq openjdk | grep -v -e doc -e src)<br />
if [ $(ifconfig | grep ^ppp -c) != "0" ];then<br />
pacman -Suw --noconfirm<br />
else<br />
pacman -Qq --native | pacman -Sw --needed -<br />
fi<br />
yes | pacman -Su<br />
if [ "${?}" != "0" ];then beep -f 100 -l 1000 && zenity --warning --text="Ett problem har uppstått. Kontakta Admin!"<br />
if [ -f "/var/lib/pacman/db.lck" ];then zenity --warning --text="Databasfilen är skadat eller används: /var/lib/pacman/db.lck";fi;<br />
exit 1<br />
else<br />
BkupDate=$(date '+%A-day_of_the_week-%u')<br />
pacman -Q --native > /opt/.alt_db_bkup-"${BkupDate}"<br />
date >> /opt/.alt_db_bkup-"${BkupDate}"<br />
systemctl daemon-reload<br />
sleep 2<br />
fi<br />
pacman-db-upgrade<br />
..............<br />
..............<br />
..............</nowiki>}}<br />
<br />
Some of updates can be installed directly if you want make it download new releases of updates and not only updates for existing.<br />
If computer will use wireless or cable connection it will download all even packages that are in the ignore list but install only updates that are not in the ignore list. You can also make it download all updates one day and install next day, for that you will need to modify script and schedule days of the week for downloading and another script for installing or use command line variables to switch from downloading to installing.<br />
<br />
=== Update packages from the AUR ===<br />
<br />
First must be created the [[GnuPG#Create_key|GPG key]] and added to the {{ic|makepkg}} configuration file.<br />
<br />
{{hc|/etc/makepkg.conf|2=<br />
...............<br />
PKGDEST=/path/to/custom_repo<br />
GPGKEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"<br />
...............}}<br />
<br />
This can be used as a part in the download scripts and in the end of them.<br />
<br />
{{Warning|Sometimes packages can change their names that will prevent update of the equivalent installed or if dependencies will be changed.}}<br />
<br />
When you are installing Arch Linux on someones computer for use as a desktop then you are responsible too keep it working and the hardest part is too keep packages from the [[AUR]] up to date. There are a few alternatives that you can use:<br />
<br />
* Make a script that will download files from the AUR or use {{AUR|aurget}} but this can result that installed packages will not be updated if them are moved to the [[Official repositories]] in that case you will need to make a check even there if not found and vice versa. <br />
* Update packages by downloading and extracting binaries if they are available for your architecture, but version of the packages will not be registered in the [[pacman]] database. The best way if it is possible then download by using a single URL instead of parsing the downloaded file for the URLs.<br />
* Have a cloned installation in the virtual environment and keep watching for updates and test them there if any problem accrued then create a fix that you can delivery to the user. The ways that you can use are by mailing a script with the configuration files or by setting up own repository that will keep only fixes and probably also packages that has often problem with updating in time.<br />
<br />
This example shows how to download and install packages from the [[AUR]] when using [[cron]] and when you need to run makepkg while logged in as root by changing user without logging out.<br />
<br />
{{bc|1=<br />
wget -nd -nH -m <nowiki>https://aur.archlinux.org/packages/....../</nowiki>PKGBUILD -P /tmp<br />
wget -nd -nH -m <nowiki>https://raw.githubusercontent.com/....../</nowiki>''filename'' -P /tmp<br />
cd /tmp<br />
runuser -u ''user_name_with_limited_rights'' makepkg<br />
if [ "$?" == 0 ]; then<br />
repo-add -s -n /opt/.AUR/x86_64/custom.db.tar /opt/.AUR/x86_64/*.tar.xz<br />
fi<br />
rm /tmp/PKGBUILD<br />
rm /tmp/''filename''<br />
}}<br />
<br />
Example how to download and install [https://www.google.com/chrome/browser/desktop/index.html pepper flash] binaries. The script is using {{Pkg|p7zip}} for extraction of the archive to stdout.<br />
<br />
{{bc|<nowiki><br />
#......... #Check if the destination folders are exist, use notifiers if needed and if running as root<br />
#......... #<br />
Arch="amd64"<br />
#Arch="i386"<br />
PathTo="/path/to/.AUR/chromium-pepper-flash"<br />
wget -m -nd -nH https://dl.google.com/linux/direct/google-chrome-stable_current_${Arch}.deb \ <br />
-P "${PathTo}" -o /tmp/chromium-pepper-flash.wget-log<br />
if [ "$(grep '100%' -c /tmp/chromium-pepper-flash.wget-log)" != "0" ];then<br />
7z e "${PathTo}/google-chrome-stable_current_${Arch}.deb" -so | \<br />
tar -xv --strip-components=5 --wildcards ./opt/google/chrome/PepperFlash/* -C /usr/lib/PepperFlash<br />
#......... # <br />
#......... # Use notifier if needed<br />
fi<br />
</nowiki>}}<br />
<br />
=== Update the mirrorlist file ===<br />
<br />
This can be scheduled to update mirrors once a week or few times in a month only for countries you want:<br />
<br />
{{bc|<nowiki><br />
rm /etc/pacman.d/mirrorlist<br />
for Cnt in China Iran Russia Korea;<br />
do <br />
awk -v GG=$Cnt '{if(index($0,GG) != 0)AA=1;if(AA == 1)<br />
{if( match($0,"#") != "0"){SS=$0;sub("#","",SS);print SS ;}else AA=0} }' \<br />
/etc/pacman.d/mirrorlist.pacnew >> /etc/pacman.d/mirrorlist;<br />
<br />
done<br />
</nowiki>}}<br />
<br />
{{Note|It is assumed that the {{ic|/etc/pacman.d/mirrorlist.pacnew}} file exists, usually created by the {{Pkg|pacman-mirrorlist}} after update.}}<br />
<br />
See also: [[Mirrors#Official_mirrors|What to do if pacman-mirrorlist is not installed]].</div>Infinitehhttps://wiki.archlinux.org/index.php?title=Linux-pf&diff=371608Linux-pf2015-04-28T08:56:15Z<p>Infiniteh: avoid contractions to comply with Help:Style#Language_register, spelling</p>
<hr />
<div>[[Category:Kernel]]<br />
[http://pf.natalenko.name/ Linux-pf] is a kernel package based on the stock -ARCH kernel, patched with a row of significant patches:<br />
* [http://ck-hack.blogspot.com/ The latest Con Kolivas' -ck patchset, including BFS]<br />
* [[TuxOnIce]]<br />
* [http://algo.ing.unimo.it/people/paolo/disk_sched/ BFQ] (as default I/O scheduler)<br />
* [http://kerneldedup.org/projects/uksm/ UKSM]<br />
* [http://aufs.sourceforge.net/ AUFS3]<br />
<br />
== Installation ==<br />
<br />
Install {{AUR|linux-pf}} from the [[AUR]]. A long-term support version of linux-pf is available with {{AUR|linux-pf-lts}}.<br />
<br />
=== From the unofficial repository (recommended) ===<br />
<br />
{{Expansion|There are two different repositories, [[Unofficial_user_repositories#pfkernel|pfkernel]] and [[Unofficial_user_repositories#Linux-pf|Linux-pf]].}}<br />
<br />
Precompiled packages, generic and CPU-family optimized are uploaded at the [http://dl.dropbox.com/u/11734958/index.html pfkernel unofficial repository], usually within 6 hours of the AUR update for x86_64 and 12 hours for i686. Append the following to {{ic|/etc/pacman.conf}} to activate the pfkernel repo:<br />
:{{bc|<nowiki><br />
[pfkernel]<br />
# linux-pf and linux-pf-lts, generic and optimized packages<br />
SigLevel = Optional<br />
Server = http://dl.dropbox.com/u/11734958/$arch<br />
</nowiki>}}<br />
Packages in the unofficial repository are not signed, so you will need to set SigLevel to Optional or Never. Running {{ic|$ pacman -Syyl pfkernel}} will update all repos and show the available packages from pfkernel. Afterwards, just install {{AUR|linux-pf}} and {{AUR|linux-pf-headers}} (for generic binaries - platform-specific binaries are also available and will be listed in the output from the aforementioned pacman command), but additional configuration steps must be performed; see the [[#Installation|Installation]] section.<br />
<br />
=== Manual compilation ===<br />
<br />
There are a number of options a user is asked to choose from, should he/she select to compile from the PKGBUILD:<br />
{{bc|<nowiki><br />
==> Hit <Y> to use your running kernel's config<br />
(needs IKCONFIG and IKCONFIG_PROC)<br />
==> Hit <L> to run 'make localmodconfig'<br />
==> Hit <N> (or just <ENTER>) to build an all-inclusive kernel like stock -ARCH<br />
(warning: it can take a looong time)<br />
</nowiki>}}<br />
The <Y> option is for users who have already compiled and are running a custom kernel. The PKGBUILD reads the running kernel's configuration and uses it for the subsequent compilation.<br />
The <L> option tries some kind of autodetection of the user's hardware: it first tries to use the [[modprobed_db]] module database, then falls back to the linux kernel's '''''make localmodconfig''''' functionality. The last option is self-explanatory.<br />
<br />
{{bc|<nowiki><br />
==> Kernel configuration options before build:<br />
<M> make menuconfig (console menu)<br />
<N> make nconfig (newer alternative to menuconfig)<br />
<G> make gconfig (needs gtk)<br />
<X> make xconfig (needs qt)<br />
<O> make oldconfig<br />
<ENTER> to skip configuration and start compiling<br />
</nowiki>}}<br />
Choose one of these to use your favourite user interface for configuring the kernel. Note that the last option might still prompt with unresolved/new configuration options, if you have selected <Y> or <L> in the previous step.<br />
<br />
{{bc|<nowiki><br />
==> An non-generic CPU was selected for this kernel.<br />
==> Hit <G> : to create a generic package named linux-pf<br />
==> Hit <ENTER> : to create a package named after the selected CPU<br />
(e.g. linux-pf-core2 - recommended)<br />
==> This option affects ONLY the package name. Whether or not the<br />
==> kernel is optimized was determined at the previous config step.<br />
</nowiki>}}<br />
If you have selected a specific CPU optimization for your kernel in the previous step, the default action is to append the CPU to the package name. This way, a subsequent package update from the repository will pull the optimized package and not the generic one. This also will help better compatibility with 3rd party precompiled modules (e.g. nvidia-pf), which might break things if loaded on optimized linux-pf kernels.<br />
<br />
==== Install compiled package ====<br />
<br />
After the compilation finishes, an additional ''linux-pf-headers[-cpu]'' package will be created. Do not forget to install it too, if you plan on using additional modules like [[nvidia]] or [[virtualbox]].<br />
<br />
# pacman -U linux-pf-core2-3.3.2-1-$CPUTYPE.pkg.tar.xz linux-pf-headers-core2-3.3.2-1-$CPUTYPE.pkg.tar.xz<br />
<br />
During the kernel installation, [[mkinitcpio]] will be called by the install script to recreate the initramfs.<br />
{{Note|If you make any changes to {{ic|/etc/mkinitcpio.conf}} after the installation, you must run '''''mkinitcpio -p linux-pf''''' to have the initial ramdisk recreated.}}<br />
<br />
== Configuration ==<br />
<br />
Then, you need to add a boot entry in [[Boot Loader#Configuration files|boot loader configuration file]] which points to linux-pf (the following example is from one of the maintainer's boxes):<br />
{{bc|<nowiki><br />
title Linux-pf 3.2<br />
root (hd0,4)<br />
kernel (hd0,0)/vmlinuz-linux-pf root=/dev/disk/by-label/ROOT ro vga=0x318 lapic resume=/dev/disk/by-label/SWAP video=vesafb:ywrap,mtrr:3 fastboot quiet<br />
initrd (hd0,0)/initramfs-linux-pf.img<br />
</nowiki>}}<br />
<br />
If you intend to use TuxOnIce for hibernation, make sure you have added the necessary modules to the MODULES array of {{ic|/etc/mkinitcpio.conf}} and at least the ''resume'' hook to the HOOKS array:<br />
{{bc|<nowiki><br />
MODULES="... lzo tuxonice_compress tuxonice_swap tuxonice_userui ..."<br />
HOOKS="... block userui resume filesystems ..."<br />
</nowiki>}}<br />
In the example above, TuxOnIce is setup to use a swap partition as the suspended image allocator. The ''resume'' hook must be placed before ''filesystems''. Also, a progress indicator is requested with ''userui''. Please read the [[TuxOnIce]] wiki page for more detailed information.<br />
<br />
Last, you must choose whether you want to suspend using [[pm-utils]] or the [[hibernate-script]]. Please, refer to the respective wiki pages for more details. [[TuxOnIce]] offers the option for a text mode or an even nicer [[fbsplash|framebuffer splash]] progress indicator.<br />
<br />
== Tips and tricks ==<br />
<br />
* If you notice disk-related performance problems or occasional hiccups, it might be an I/O scheduler issue. Try a different one than the linux-pf default (BFQ) by echoing to {{ic|/sys/block/sda/queue/scheduler}} ''cfq'', ''noop'' or ''deadline'': {{ic|# echo noop >| /sys/block/sda/queue/scheduler}}. Note, the aforementioned command only sets the I/O scheduler for the 1st hard drive and additional ''echoes'' will be needed if you have more. If the situation improves, then append "''elevator''='''''cfq'''''" (or '''''noop''''' or '''''deadline''''') to the linux-pf command line in {{ic|/boot/grub/menu.lst}}, to make the change permanent.<br />
* For people who build their own tailored kernels and compilation aborts with with an error about "missing include/config/dvb/*.h files", setting ''[*] Digital TV support'' at ''Device Drivers / <M> Multimedia support'' and leaving everything else out, creates just the necessary dvb.h, which allows the compilation to continue.<br />
<br />
== Forum thread for linux-pf ==<br />
<br />
There is a [https://bbs.archlinux.org/viewtopic.php?id=103462 discussion thread] at the BBS for reporting errors, impressions, ideas and requests.<br />
<br />
== See also ==<br />
<br />
* [https://bitbucket.org/nous/linux-pf/ linux-pf mercurial repository]<br />
* [http://pf.natalenko.name/ Patchset homepage]<br />
* [http://pf.natalenko.name/forum Patchset community forum]<br />
* [http://freecode.com/projects/pf-kernel Patchset changelog]</div>Infiniteh