|
3 | 3 | Installing PostgreSQL Database |
4 | 4 | ============================== |
5 | 5 |
|
6 | | -1. For the purposes of this guide we will assume this server has an IP |
7 | | - address of ``10.10.10.1`` |
| 6 | +1. Log into the server that will host the database, and open a terminal window. |
8 | 7 |
|
9 | | - - **Optional:** if installing on the same machine substitute ``10.10.10.1`` with ``127.0.0.1`` |
| 8 | +2. Download the PostgreSQL 9.4 Yum repository. |
10 | 9 |
|
11 | | -2. Install PostgreSQL 9.4+ |
| 10 | + ``wget https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-3.noarch.rpm`` |
12 | 11 |
|
13 | | - - ``sudo yum install http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm`` |
14 | | - - ``sudo yum install postgresql94-server postgresql94-contrib`` |
15 | | - - ``sudo /usr/pgsql-9.4/bin/postgresql94-setup initdb`` |
16 | | - - ``sudo systemctl enable postgresql-9.4`` |
17 | | - - ``sudo systemctl start postgresql-9.4`` |
| 12 | +3. Install the Yum repository from the file that you downloaded. |
18 | 13 |
|
19 | | -3. PostgreSQL created a user account called ``postgres``. You will need |
20 | | - to log into that account with: |
| 14 | + ``sudo yum localinstall pgdg-redhat94-9.4-1.noarch.rpm`` |
21 | 15 |
|
22 | | - - ``sudo -i -u postgres`` |
| 16 | +4. Install PostgreSQL. |
23 | 17 |
|
24 | | -4. You can get a PostgreSQL prompt by typing: |
| 18 | + ``sudo yum install postgresql94-server postgresql94-contrib`` |
25 | 19 |
|
26 | | - - ``psql`` |
| 20 | +5. Initialize the database. |
27 | 21 |
|
28 | | -5. Create the Mattermost database by typing: |
| 22 | + ``sudo service postgresql initdb`` |
29 | 23 |
|
30 | | - - ``postgres=# CREATE DATABASE mattermost;`` |
| 24 | +6. Set PostgreSQL to start on boot. |
31 | 25 |
|
32 | | -6. Create the Mattermost user by typing: |
| 26 | + ``sudo systemctl enable postgresql`` |
33 | 27 |
|
34 | | - - ``postgres=# CREATE USER mmuser WITH PASSWORD 'mmuser_password';`` |
| 28 | +7. Start the PostgreSQL server. |
35 | 29 |
|
36 | | -7. Grant the user access to the Mattermost database by typing: |
| 30 | + ``sudo systemctl start postgresql`` |
37 | 31 |
|
38 | | - - ``postgres=# GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;`` |
| 32 | +8. Switch to the *postgres* Linux user account that was created during the installation. |
39 | 33 |
|
40 | | -8. You can exit out of PostgreSQL by typing: |
| 34 | + ``sudo --login --user postgres`` |
41 | 35 |
|
42 | | - - ``postgres=# \q`` |
| 36 | +9. Start the PostgreSQL interactive terminal. |
43 | 37 |
|
44 | | -9. You can exit the Postgres account by typing: |
| 38 | + - ``psql`` |
45 | 39 |
|
46 | | - - ``exit`` |
| 40 | +10. Create the Mattermost database. |
47 | 41 |
|
48 | | -10. Allow Postgres to listen on all assigned IP Addresses: |
| 42 | + ``postgres=# CREATE DATABASE mattermost;`` |
49 | 43 |
|
50 | | - - ``sudo vi /var/lib/pgsql/9.4/data/postgresql.conf`` |
51 | | - - Uncomment ``listen_addresses`` and change ``localhost`` to ``\*`` |
| 44 | +11. Create the Mattermost user 'mmuser'. |
52 | 45 |
|
53 | | -11. Alter ``pg_hba.conf`` to allow the Mattermost Server to talk to the |
54 | | - Postgres database: |
| 46 | + ``postgres=# CREATE USER mmuser WITH PASSWORD 'mmuser_password';`` |
| 47 | + |
| 48 | + .. note:: |
| 49 | + Use a password that is more secure than 'mmuser-password' |
55 | 50 |
|
56 | | - - ``sudo vi /var/lib/pgsql/9.4/data/pg_hba.conf`` |
57 | | - - Add the following line to the ``IPv4 local connections``: |
58 | | - - ``host all all 10.10.10.2/32 md5`` |
| 51 | +12. Grant the user access to the Mattermost database. |
59 | 52 |
|
60 | | -12. Reload Postgres database: |
| 53 | + ``postgres=# GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;`` |
61 | 54 |
|
62 | | - - ``sudo systemctl reload postgresql-9.4`` |
| 55 | +13. Exit the PostgreSQL interactive terminal. |
63 | 56 |
|
64 | | -13. Attempt to connect with the new created user to verify everything |
65 | | - looks good: |
| 57 | + ``postgre=# \q`` |
66 | 58 |
|
67 | | - - ``psql --host=10.10.10.1 --dbname=mattermost --username=mmuser --password`` |
68 | | - - ``mattermost=> \q`` |
| 59 | +14. Log out of the *postgres* account. |
| 60 | + |
| 61 | + ``exit`` |
| 62 | + |
| 63 | +15. Allow Postgres to listen on all assigned IP Addresses. Open ``/etc/postgresql/9.4/main/postgresql.conf`` as root in a text editor. |
| 64 | + |
| 65 | + a. Find the following line: |
| 66 | + |
| 67 | + ``#listen_addresses = 'localhost'`` |
| 68 | + |
| 69 | + b. Uncomment the line and change ``localhost`` to ``*``: |
| 70 | + |
| 71 | + ``listen_addresses = '*'`` |
| 72 | + |
| 73 | +16. If the Mattermost server is on a separate machine, modify the file ``pg_hbe.conf`` to allow the Mattermost server to communicate with the database. |
| 74 | + |
| 75 | + If the Mattermost server and the database are on the same machine, then you can skip this step. |
| 76 | + |
| 77 | + a. Open ``/etc/postgresql/9.4/main/pg_hba.conf`` in a text editor. |
| 78 | + |
| 79 | + b. Add the following line to the end of the file, where *<mm-server-IP>* is the IP address of the machine that contains the Mattermost server. |
| 80 | + |
| 81 | + ``host all all <mm-server-IP>/32 md5`` |
| 82 | + |
| 83 | +17. Reload Postgres database |
| 84 | + |
| 85 | + ``sudo systemctl reload postgresql`` |
| 86 | + |
| 87 | +18. Verify that you can connect with the user *mmuser*. |
| 88 | + |
| 89 | + ``psql --host=localhost --dbname=mattermost --username=mmuser --password`` |
| 90 | + |
| 91 | + The PostgreSQL interactive terminal starts. To exit the PostgreSQL interactive terminal, type ``\q`` and press **Enter**. |
| 92 | + |
| 93 | +With the database installed and the initial setup complete, you can now install the Mattermost server. |
0 commit comments