sentry-self-hosted icon indicating copy to clipboard operation
sentry-self-hosted copied to clipboard

Name or service not known

Open dragonfire1119 opened this issue 4 years ago • 5 comments

I keep getting could not translate host name "postgres" to address: Name or service not known when running install.sh

I have added 127.0.0.1 postgres to /etc/hosts but still, get this error

dragonfire1119 avatar Feb 29 '20 03:02 dragonfire1119

I am having the same issue.

rustanacexd avatar Mar 29 '20 09:03 rustanacexd

How far did you get through the install.sh script? If you let us know which was the last message it might help narrow this down.

jeff-h avatar Mar 29 '20 09:03 jeff-h

it fails on line 62

rustanacexd avatar Mar 29 '20 09:03 rustanacexd

After looking into this more it seems that a docker change has made it to where you need a postgres password or you need to set it to POSTGRES_HOST_AUTH_METHOD: 'trust' on the postgres environment. What I did to get this script to run is

install.sh

#!/bin/bash

# Installs Sentry and all dependencies on a fresh Debian 9.
# Installation requires 4GB of RAM. If you don't have that much,
# increase the swap size. Running should be okay at 1 GB.
# To start, copy all files to the server and invoke ./install.sh.

# Error handling:
set -e
trap 'echo "Error on line $LINENO"' ERR

# Change these values!
DOMAIN=sentry.yourdomain.com
[email protected]
GMAIL_PASSWORD=mypassword
[email protected]

if [ -z "$LC_ALL" ]; then
    echo 'Setting locale to avoid Perl warnings "Setting locale failed."'
    locale-gen en_US.UTF-8
    su -c "echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale"
    echo 'Shell restart required. Please log out and back in, then execute the script again.'
    exit
fi

apt-get update
apt-get upgrade -y

echo 'Installing docker...'
apt-get install apt-transport-https dirmngr -y
echo 'deb https://apt.dockerproject.org/repo debian-stretch main' >> /etc/apt/sources.list
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys F76221572C52609D
apt-get update
apt-get install docker-engine -y

echo 'Installing docker-compose'
# Some, but not all versions of Debian have curl pre-installed.
# Make sure it is installed:
apt-get install curl -y
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

echo 'Creating application user...'
useradd --system --gid docker --shell /bin/bash -m sentry

echo 'Cloning sentry-onpremise repository...'
su -c 'git clone https://github.com/getsentry/onpremise.git sentry' - sentry
su -c 'cd sentry && git checkout cd13427aa9a231b2b27c9fd14017d183cca52c1e' - sentry

echo 'Updating Sentry config to use SSL...'
sed -i 's/environment:/environment:\n    SENTRY_USE_SSL: 1/g' /home/sentry/sentry/docker-compose.yml

echo 'Updating Sentry config to use sentry db password...'
sed -i "s=SENTRY_EMAIL_HOST: smtp=SENTRY_EMAIL_HOST: smtp\n    SENTRY_DB_PASSWORD: postgres=g" /home/sentry/sentry/docker-compose.yml

echo 'Updating Sentry config to use Gmail...'
sed -i "s=image: tianon/exim4=image: tianon/exim4\n    environment:\n      GMAIL_USER: ${GMAIL_USER}\n      GMAIL_PASSWORD: ${GMAIL_PASSWORD}=g" /home/sentry/sentry/docker-compose.yml

echo 'Updating Sentry config to use postgres password...'
sed -i "s=image: postgres:9.5=image: postgres:9.5\n    environment:\n      POSTGRES_USER: postgres\n      POSTGRES_PASSWORD: postgres\n      POSTGRES_DBNAME: sentry\n      POSTGRES_DBUSER: sentry\n      POSTGRES_DBPASS: sentry=g" /home/sentry/sentry/docker-compose.yml

echo 'Building Sentry...'
su -c 'docker volume create --name=sentry-data' - sentry
su -c 'docker volume create --name=sentry-postgres' - sentry
su -c 'cd sentry && cp -n .env.example .env' - sentry
su -c 'cd sentry && docker-compose build' - sentry
su -c 'cd sentry && SENTRY_SECRET_KEY=`docker-compose run --rm web config generate-secret-key` && echo "SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY}" > .env' - sentry
su -c 'cd sentry && docker-compose run --rm web upgrade' - sentry

echo 'Creating all necessary Docker containers...'
su -c 'cd sentry && docker-compose up -d' - sentry

echo 'Installing Lets Encrypt...'
git clone https://github.com/letsencrypt/letsencrypt

echo 'Generating SSL certificates...'
letsencrypt/letsencrypt-auto --standalone --non-interactive --force-renew --email ${ADMIN_EMAIL} --agree-tos auth -d ${DOMAIN}

echo 'Uninstalling Lets Encrypt...'
rm -rf letsencrypt

echo 'Creating Sentry log file directory...'
su -c 'mkdir -p /home/sentry/logs' - sentry

echo 'Setting up Nginx...'
apt-get install nginx -y
cp nginx-site /etc/nginx/sites-available/sentry
sed -i "s/DOMAIN/${DOMAIN}/g" /etc/nginx/sites-available/sentry
ln -s /etc/nginx/sites-available/sentry /etc/nginx/sites-enabled/sentry
rm /etc/nginx/sites-enabled/default
service nginx reload

echo 'Installing Supervisor...'
apt-get install supervisor -y

echo 'Configuring Supervisor...'
cp supervisor*.conf /etc/supervisor/conf.d/

echo 'Updating Supervisor...'
supervisorctl reread
supervisorctl update

echo "Rebooting. In a few minutes, you should be able to open https://${DOMAIN}"
reboot

Then run it. Should succeed.

I'll look at making a pull request.

dragonfire1119 avatar Mar 29 '20 16:03 dragonfire1119

@dragonfire1119 Thanks will give it a try!

rustanacexd avatar Apr 02 '20 16:04 rustanacexd