Commit 7c7bc18b302d33b9130c0cd166a17b0fe6ee2446
1 parent
913c9dc4
Exists in
master
and in
1 other branch
Adding script postgresql.sh
Showing
1 changed file
with
106 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,106 @@ |
| 1 | +#!/bin/bash | |
| 2 | + | |
| 3 | +# Pré-requisitos | |
| 4 | + | |
| 5 | +sudo yum update -y | |
| 6 | +# Todas as máquinas devem ter o usuário colab | |
| 7 | +# O usuário colab das maquinas devem estar no arquivo ``sudoers`` | |
| 8 | + | |
| 9 | +# Instalação do Postgres 9.3 | |
| 10 | + | |
| 11 | +# Siga todas as instruções a seguir na máquina destinada ao banco de dados Postgres | |
| 12 | +# *NOTE:* | |
| 13 | +# 1. Libere a porta 5432 desta máquina para que máquina do colab possa ouvi-la | |
| 14 | + | |
| 15 | +# 2. Instale o pacote postgresql | |
| 16 | + | |
| 17 | +sudo yum localinstall http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm -y | |
| 18 | +sudo yum install postgresql93 postgresql93-devel postgresql93-libs postgresql93-server vim -y | |
| 19 | + | |
| 20 | +# 3. Inicie o banco de dados | |
| 21 | + | |
| 22 | +sudo service postgresql-9.3 initdb | |
| 23 | + | |
| 24 | +# 4. Adicione o Postgres para iniciar com o sistema | |
| 25 | + | |
| 26 | +sudo chkconfig postgresql-9.3 on | |
| 27 | + | |
| 28 | +# 5. Inicie o postgresql | |
| 29 | + | |
| 30 | +sudo service postgresql-9.3 start | |
| 31 | + | |
| 32 | +# 6. Coloque os binários do postgres na variável PATH | |
| 33 | +echo "export PATH=$PATH:/usr/pgsql-9.3/bin/" >> ~/.bashrc | |
| 34 | +source ~/.bashrc | |
| 35 | +sudo sh -c "echo 'export PATH=$PATH:/usr/pgsql-9.3/bin/' >> ~/.bashrc" | |
| 36 | +sudo sh -c "source /root/.bashrc" | |
| 37 | + | |
| 38 | +# 7. Edite o arquivo sudoers | |
| 39 | + | |
| 40 | +sudo sed -i 's/\/sbin:\/bin:\/usr\/sbin:\/usr\/bin/\/sbin:\/bin:\/usr\/sbin:\/usr\/bin:\/usr\/pgsql-9.3\/bin/' /etc/sudoers | |
| 41 | + | |
| 42 | +# sudo vim /etc/sudoers | |
| 43 | +# Dentro do arquivo mude a seguinte linha | |
| 44 | +# Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin | |
| 45 | +# para | |
| 46 | +# Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-9.3/bin/ | |
| 47 | +# Salve e feche o arquivo | |
| 48 | +# [ESC]:wq! | |
| 49 | + | |
| 50 | +# 8. Crie todos os usuários e banco de dados necessários para o funcionamento correto do colab. | |
| 51 | + | |
| 52 | +sudo -u postgres psql -c "CREATE USER colab SUPERUSER INHERIT CREATEDB CREATEROLE;" | |
| 53 | +sudo -u postgres psql -c "ALTER USER colab PASSWORD 'colab';" | |
| 54 | +sudo -u postgres psql -c "CREATE USER git;" | |
| 55 | +sudo -u postgres psql -c "CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redmine' NOINHERIT VALID UNTIL 'infinity';" | |
| 56 | +sudo -u postgres psql -c "CREATE DATABASE gitlabhq_production OWNER git;" | |
| 57 | +sudo -u postgres psql -c "CREATE DATABASE colab WITH OWNER colab ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0;" | |
| 58 | +sudo -u postgres psql -c "CREATE DATABASE trac_colab WITH OWNER colab ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0;" | |
| 59 | +sudo -u postgres psql -c "CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;" | |
| 60 | + | |
| 61 | +#sudo -u postgres psql | |
| 62 | +# | |
| 63 | +# CREATE USER colab SUPERUSER INHERIT CREATEDB CREATEROLE; | |
| 64 | +# ALTER USER colab PASSWORD 'colab'; | |
| 65 | +# CREATE USER git; | |
| 66 | +# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redmine' NOINHERIT VALID UNTIL 'infinity'; | |
| 67 | +# | |
| 68 | +# CREATE DATABASE gitlabhq_production OWNER git; | |
| 69 | +# CREATE DATABASE "colab" WITH OWNER "colab" ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0; | |
| 70 | +# CREATE DATABASE "trac_colab" WITH OWNER "colab" ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0; | |
| 71 | +# CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine; | |
| 72 | +# \q | |
| 73 | + | |
| 74 | +# 9. Altere o pg_hba.conf para conceder as permissões corretas aos usuários | |
| 75 | + | |
| 76 | +sudo wget https://gitlab.com/softwarepublico/colabdocumentation/raw/master/Arquivos/postgres/pg_hba.conf -O /var/lib/pgsql/9.3/data/pg_hba.conf | |
| 77 | + | |
| 78 | +# sudo vi /var/lib/pgsql/9.3/data/pg_hba.conf | |
| 79 | + | |
| 80 | +# As permissõe devem ser as que estão abaixo, que serão encontradas no final do arquivo, ou seja, as linhas do fim do arquivo devem ser substituidas. | |
| 81 | + | |
| 82 | + # TYPE DATABASE USER ADDRESS METHOD | |
| 83 | + | |
| 84 | + # "local" is for Unix domain socket connections only | |
| 85 | +# local all postgres peer | |
| 86 | +# local redmine redmine md5 | |
| 87 | +# local trac_colab colab md5 | |
| 88 | +# local colab colab md5 | |
| 89 | +# local gitlabhq_production git trust | |
| 90 | + # IPv4 local connections: | |
| 91 | +# host all postgres 127.0.0.1/32 ident | |
| 92 | +# host redmine redmine 127.0.0.1/32 md5 | |
| 93 | +# host trac_colab colab 127.0.0.1/32 md5 | |
| 94 | +# host colab colab 127.0.0.1/32 md5 | |
| 95 | +# host gitlabhq_production git 127.0.0.1/32 trust | |
| 96 | + # IPv6 local connections: | |
| 97 | +# host all postgres ::1/128 ident | |
| 98 | +# host redmine redmine ::1/128 md5 | |
| 99 | +# host trac_colab colab ::1/128 md5 | |
| 100 | +# host colab colab ::1/128 md5 | |
| 101 | +# host gitlabhq_production git ::1/128 trust | |
| 102 | +# [ESC]:wq! | |
| 103 | + | |
| 104 | +# 10. Reinicie o postgresql | |
| 105 | + | |
| 106 | +sudo service postgresql-9.3 restart | ... | ... |