install postgresql issue
jiangjianxiao opened this issue Β· comments
pg_createcluster 9.5 main --start
Creating new cluster 9.5/main ...
config /etc/postgresql/9.5/main
data /var/lib/postgresql/9.5/main
locale en_US.UTF-8
FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=1, size=56, 03600).
HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter, or possibly that it is less than your kernel's SHMMIN parameter.
The PostgreSQL documentation contains more information about shared memory configuration.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.5/main"
Error: initdb failed
sysctl -w kernel.shmmax=1
sysctl: cannot stat /proc/sys/kernel/shmmax: No such file or directory
I had the same error yesterday. It appears that writing on some folders or creating symlinks are problematic in WSL right now.
Has anyone found a workaround for this?
Seems like there's no proper System V shared memory support at the moment.
No workouronds yet?
Same issue here with build 14352.rs1_release.160522-1930. Any fixes on this yet? It's the final piece of the puzzle for my workflow!
Output below:
rob@DESKTOP-NQ3AL5E:~$ sudo apt-get install postgresql postgresql-common
[sudo] password for rob:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libossp-uuid16 libxslt1.1 os-prober
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
postgresql-9.3 postgresql-client-9.3 postgresql-client-common
Suggested packages:
oidentd ident-server locales-all postgresql-doc-9.3
The following NEW packages will be installed:
postgresql postgresql-9.3 postgresql-client-9.3 postgresql-client-common
postgresql-common
0 upgraded, 5 newly installed, 0 to remove and 40 not upgraded.
Need to get 0 B/3,603 kB of archives.
After this operation, 15.2 MB of additional disk space will be used.
Preconfiguring packages .../n] y
E: Can not write log (Is /dev/pts mounted?) - openpty (2: No such file or directory)
Selecting previously unselected package postgresql-client-common.
(Reading database ... 32749 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_154ubuntu1_all.deb ...
Unpacking postgresql-client-common (154ubuntu1) ...
Selecting previously unselected package postgresql-client-9.3.
Preparing to unpack .../postgresql-client-9.3_9.3.13-0ubuntu0.14.04_amd64.deb ...
Unpacking postgresql-client-9.3 (9.3.13-0ubuntu0.14.04) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_154ubuntu1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (154ubuntu1) ...
Selecting previously unselected package postgresql-9.3.
Preparing to unpack .../postgresql-9.3_9.3.13-0ubuntu0.14.04_amd64.deb ...
Unpacking postgresql-9.3 (9.3.13-0ubuntu0.14.04) ...
Selecting previously unselected package postgresql.
Preparing to unpack .../postgresql_9.3+154ubuntu1_all.deb ...
Unpacking postgresql (9.3+154ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-client-common (154ubuntu1) ...
Setting up postgresql-client-9.3 (9.3.13-0ubuntu0.14.04) ...
update-alternatives: using /usr/share/postgresql/9.3/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-common (154ubuntu1) ...
Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-9.3 (9.3.13-0ubuntu0.14.04) ...
Creating new cluster 9.3/main ...
config /etc/postgresql/9.3/main
data /var/lib/postgresql/9.3/main
locale C
FATAL: could not create shared memory segment: Function not implemented
DETAIL: Failed system call was shmget(key=1, size=48, 03600).
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.3/main"
Error: initdb failed
Error: could not create default cluster. Please create it manually with
pg_createcluster 9.3 main --start
or a similar command (see 'man pg_createcluster').
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql (9.3+154ubuntu1) ...
rob@DESKTOP-NQ3AL5E:~$ sudo pg_createcluster 9.3 main --start
Creating new cluster 9.3/main ...
config /etc/postgresql/9.3/main
data /var/lib/postgresql/9.3/main
locale en_US.UTF-8
FATAL: could not create shared memory segment: Function not implemented
DETAIL: Failed system call was shmget(key=1, size=48, 03600).
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.3/main"
Error: initdb failed
Still waiting on this.
One of the things holding me from developing on windows with Ruby.
So you don't get an error while installing postgres on WSL?
Which version of postgres are you using?
Or do you mean the combination of postgres on Windows and Ruby on WSL works great?
I thought programs on Windows are not accessible from WSL.
So I figured, the same would go for a rails server using postgres...
Thanks, didn't think of it that way.
Gonna try it out.
Op vr 17 jun. 2016 23:05 schreef SRGOM notifications@github.com:
The combination. You don't use postgres as a process, you access it over a
port so there should be no issues thereβ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#61 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AEo0Vj99_9zBZtrF5rFHiLNe6_bqnT9rks5qMwwOgaJpZM4IC15g
.met vriendelijke groet,
Arjen
M 06-51 800 419
W www.payt.nl
I got the same error on a new release - build 14367.rs1_release.160613-1700. Can anyone find a solution?
Someone has to implement that call to the kernel.
Hi!
Can someone please describe how to connect to postgres on the host, like @SRGOM mentioned?
Thanks!
I am successfully connecting my Rails app running in WSL to Postgres on Windows. I don't recall doing anything special to make that happen.
@SRGOM Thanks! Just tried it and it works perfectly.
@SRGOM Thank you. When installing Postgres on Windows normally. You can consider this alternative, until they make proper implementation in bash.
Recipe for those who have problems:
- Set Postgres for Windows.
- Start the server Postgres.
- Connect to the database server, as is usually done in the unix;
For records, I'm receiving the same issue on Build 14372.rs1_release.160620-2343, trying to create cluster after installation of postgresql 9.4
$ sudo pg_createcluster 9.4 main
Creating new cluster 9.4/main ...
config /etc/postgresql/9.4/main
data /var/lib/postgresql/9.4/main
locale en_US.UTF-8
FATAL: could not create shared memory segment: Function not implemented
DETAIL: Failed system call was shmget(key=1, size=56, 03600).
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.4/main"
Error: initdb failed
I have the same error of @pavelbulanov (in italian):
Creating new cluster 9.3/main ...
config /etc/postgresql/9.3/main
data /var/lib/postgresql/9.3/main
locale it_IT.UTF-8
FATALE: creazione del segmento di memoria condivisa fallita: Funzione non implementata
DETTAGLI: La chiamata di sistema fallita era shmget(key=1, size=48, 03600).
processo figlio uscito con codice di uscita 1
initdb: rimozione dei contenuti della directory dati "/var/lib/postgresql/9.3/main"
Error: initdb failed
Still unable to install postgres with build 14393.10:
Setting up postgresql-common (154ubuntu1) ...
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql-9.3 (9.3.13-0ubuntu0.14.04) ...
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
I can think of at least a couple of reasons I don't want Postgres running on Windows and one involves just not wanting the service constantly running in the background when it can be turned on/off by starting/stopping Bash; having to actually open up the services applet to shut it off/turn it on is kind of inconvenient when I'm only using it for the purpose of development. Two, I read that developers were talking about ending support for the Windows port on a mailing list because it's difficult to maintain.
Until this is fixed, I'm sticking with my virtual machine.
I think that, for me, it's just a matter of convenience. Right now, I unpause my VM and go. If I wanted to start using Bash I'd have to start the Postgres service and then start Bash because I would prefer not to have the service running in the background. Call me paranoid.
I have Ubuntu 14.04 and Windows 10 on the same machine, and frankly my stack is waaaayyyyy slower in Windows 10 with the server code running in the shell and postgres installed on Windows.
I'm not sure yet what could be the cause of this:
- windows psql install being generally slower than its unix counterpart
- extra network layers caused by the fact that I can't connect to psql through a unix socket
- something else entirely (maybe the shell integration layers themselves)
But I sure as hell would like to compare, because the difference is extremely noticeable.
@dbo-odoo, it's unlikely related with postgres, unfortunately - it more looks like overall slowdown in some kind of operations inside bash
if possible, try doing kind of hack for your app to not use db (use static stubs instead) and measure
for me, starting rails server (which doesn't do any postgresql queries) takes like 5-7 secs, comparing to 1-2 secs inside Ubuntu virtual machine (on the same hardware and with lack of resources for VM)
@dbo-odoo -- curious, can you quantify "extremely noticeable"? For you, is that like 20% slower? 100x slower?
@pavelbulanov yeah that's not something I'm gonna be able to do easily, but if I do have time i'll test it
@aseering I'd say along the lines of 2-4x slower (as a gross estimation)
If I do some benchmark I'll post them here.
I'm also experiencing significantly slower start up times for rails server. The report below shows benchmark results for bash on Windows, and apparently File IO performance can be over 6 times slower than on Ubuntu!
http://www.techrepublic.com/article/windows-10-how-well-does-it-run-ubuntu-bash/
@alexssung yep, I believe @russalex said that the file i/o is the main bottleneck in his //build/ conference presentation
I experienced the same issue, trying to install PostgreSQL 9.5 for my django. There was no error reported when installing, but something went wrong when creating database superuser and templates.
@FqPc, do you know if i/o slowdown is relevant to bash working with both file systems, VolFs and Windows f/s via mnt?
@pavelbulanov the best place to ask would probably be in a new thread and ping russalex in it
Happy to answer this one here.
The file system performance hit happens on both VolFs and DrvFs. VolFs may actually be slightly faster in some situations simply due to the amount of caching we do there, but in most cases the perf will be very similar between the two.
Throwing a quick shout out to @SvenGroot's excellent file system blog post here. It does help explain a lot.
@russalex thanks for checking in!
I just re-read the article in blog. It explains how it works, but I didn't find any specific hint on what can cause slowdown in both scenarios. Can you give any clue? And, obviously, any thought on whether this could (and would) be fixed. Maybe creation of 3rd simplified (limited) but fast file system driver for cases like compilation or interpretation of massive code projects with thousands of files.
On the slowdown, is it caused by "just-in-time" creation of inodes based on NTFS Extended Attributes? If this would be the case, using DrvFs should be faster as I understand it doesn't query EA for files (besides not using cache, though). Mapping various types of descriptors (Windows file objects to Linux objects and descriptors) shouldn't take long, I believe.
I can go into a bit more detail but we will quickly get out of my depth and I'll need to pull in a dev working on the problem.
At it's core, this perf delta is more about the differences in philosophies between how Linux and Windows interact with their file systems. I am not going to call one better than the other, it's simply that they behave in very different priorities / implementations (example would be path resolution). With our goal of binary compatibility, both VolFs and DrvFs must look like a Linux file system to Ubuntu and apps. Over the years apps have come to expect specific file system behavior, or have optimized around "cheap" calls. This is disrupted with WSL where calls that were cheap before can be expensive now. Since there is no modification to the app's binaries this can cause some slowdown.
The good news is that we're looking at it. We have been talking with various teams around MSFT to see what types of improvements we can make. Still too early to make any promises or guarantees, but I will say that this is something we know needs to be addressed (one of the few times I'll say we don't need a User Voice here, already on the priority list).
I got a external windows install of postgres working, could never make the installation within WSL work. Now the rake db:seed
fails silently and does not write any data. No one on a OSX device has this issue. I did have to install postgres so pg_dump
was available for db:migrate
, but I could not run it from the WSL bash shell directly.
@khrome83 Be fair. WSL was released as a beta, as you saw then you checked the box. It implements only about 70% (iirc) of the Linux syscalls, some of which are not complete, since they do not implement all arguments and modes. Moreover, things like Unix sockets and socket options are only partially implemented. The project has only been public for about 4 months, and again, it comes with a bunch of warnings that it is beta software.
The fact that some software works on OS X is barely interesting, since OS X already has a POSIX-related syscall API, and many many *nix tools have been ported to it and recompiled.
But remember, they are recompiled. WSL is running binaries that are compiled for Linux. When you compile a program, it compiles against binary Linux libraries.
The difference is pretty simple: It's like saying "Oh, I can play a game on the XBox 360 and on the PS3". Sure you can, but what you're doing is slagging off a developer who is writing an emulator that runs the game's binaries on PC.
If MS wanted to port Postgres directly to Windows 10, it would work great because they would have engineers sitting there rewriting the parts of the system that do not make sense on Windows, which is very different in a lot of ways (Windows has much better implementation of asynchronous IPC using something called ALPC, which is something like what kdbus was supposed to be before it was abandoned, except not garbage).
@khrome83: I have PG working on the Windows side, and have my Rails app talking to it from WSL. I don't have any helpful links right now, but it is possible.
Install postgresql on windows (prefferably 9.3) - https://www.postgresql.org/download/windows/
set password to postgres
then run in bash 'psql -p 5432 -h localhost -U postgres'
It should be working.
Same problem with 9.3 (latest Windows 10 build updated).
im aloso stuck at this error,
i need to get my postgresql server running...
@jwsloan which build are you using?
@eugen-don I'm running the latest.
I've got pg running in windows, and host: localhost
in my database.yml file in my project in WSL.
@jwsloan Any tips how to run rails on windows with postgres?
@alekkowalczyk Let me know what issues you're running into, and I'll certainly try to help. I've been considering starting a repo that has scripts to get you from out-of-the-box wsl to running Rails/nodejs/pheonix/etc... Updating it with new releases until the world is perfect and that repo is no longer needed. :)
no comments in 26 days... just wanted to add my +1 on this issue.
Everyone here is working around this issue by running postgresql for Windows as a Windows service instead of pgsql for Linux running in bash for windows?
Thanks!
So I am able to connect via bash using the command @aoslm suggested. But any connection I try to make through node seems unable to find it (or atleast by the name localhost or any variant of it). Anyone gotten a node/postgres project running out of WSL?
π
+1
Hello! Is @gadkrumholz's summary correct? There is no way to run postgres with Windows on Ubuntu on Bash (Im assuming thats what everyone means when the say WSL)??
I have tried with Postgres v- 9.6 and got the exact same problem as listed in OP.
I got RVM to work on 'WSL' in order to run a rails app (too many dependency problems to work on Windows).
I initially was directed to install and run Postgres to solve this problem:
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-11-18 10:56:14] INFO WEBrick 1.3.1
[2016-11-18 10:56:14] INFO ruby 2.0.0 (2015-02-25) [x86_64-linux]
[2016-11-18 10:56:14] INFO WEBrick::HTTPServer#start: pid=12020 port=3000
2016-11-18 11:06:16 -0500 severity=DEBUG, 2016-11-18 11:06:16 -0500 severity=DEBUG, 2016-11-18 11:06:16 -0500 severity=INFO, Started GET "/" for 127.0.0.1 at 2016-11-18 11:06:16 -05002016-11-18 11:06:21 -0500 severity=FATAL, PG::ConnectionBad (could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
):
appsignal (0.10.6) lib/appsignal/rack/listener.rb:13:in `call'
Rendered /usr/local/rvm/gems/ruby-2.0.0-p643@employee/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (2.7ms)
Rendered /usr/local/rvm/gems/ruby-2.0.0-p643@employee/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (4.6ms)
Rendered /usr/local/rvm/gems/ruby-2.0.0-p643@employee/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4.0ms)
Rendered /usr/local/rvm/gems/ruby-2.0.0-p643@employee/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (380.0ms)
Will the solution of running Postgres on WIndows with the app on WSL work well enough for that?
I actually came across a problem when downloading Postgres on Windows, it simply would not connect/open...
Keeps saying "Failed to connect to the pgAdmin application server. Click here to try again."
I will uninstall and try again. Maybe I missed something.
I am very new to this, I would greatly appreciate any resources or guides that will help. Thanks!
So I made a small guide I've yet to publish to the internet for my students using WSL, I remember some people had issues with the createuser --interactive
piece - I believe you need to attach a -h localhost
and -p 5432
to that command to get it to work.
I can confirm that I use psql and WSL as daily drivers for development and it works fine.
Heres my excerpt on psql:
1. Go to http://www.enterprisedb.com/products-services-training/pgdownload#windows
2. Download version 9.3.15 - Or if you're feeling dangerous, perhaps a more recent one.
3. Install it, and set password to postgres.
4. Sanity check before going further - open up your bash terminal and enter:
psql -p 5432 -h localhost -U postgres
5. If you get a psql (9.3.x) message - we're on a good path.
6. Open up pgAdmin III, its management tool.
7. Right click on the "PostgreSQL 9.3 (localhost:5432)" and click connect (will prompt for password).
8. Now with that selected, go to "Tools", "Server Configuration", "pg_hba.conf", and change the two checked boxes (the ones with database: all) methods to trust.
9. Now, go to your .bashrc file in terminal, using nano add this to the bottom of the file:
export PGHOST=localhost
10. Now you should be able to type psql in bash. It shouldn't let you login due to not having a user in the psql database. To solve this type:
createuser --interactive yourBashUsernameHere -h localhost -p 5432
11. It will prompt you to ask if you are a superuser, you want to say yes to this.
12. But even this isn't enough! Even though we solved psql's default behavior of looking for a user with your bash username, there is a separate issue that it needs a default database for this user as well! To solve this:
createdb yourBashUsernameHere
13. Now, hopefully, when you enter psql into the bash terminal you will get in!
@aoslm Thanks for the workaround! @leafoflegend Thank you for the detailed guide! Unfortunately this did not work for me :/
I got the same 'could not connect to server' issue at step 10 when I typed 'psql'
When I entered the createuser line I got:
root@MSISHADOW:~# createuser --interactive MSISHADOW -h localhost -p 5432
Shall the new role be a superuser? (y/n) Y
Please answer "y" or "n".
Shall the new role be a superuser? (y/n) y
createuser: could not connect to database postgres: FATAL: role "root" does not exist
root@MSISHADOW:~# createdb MSISHADOW
createdb: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
root@MSISHADOW:~# psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I went ahead and pasted the results of everything after that as well.
This seems like it might just work though! Perhaps I have to exit and then re-open bash or something? Did I enter the right BashUsername? Should it be MSISHADOW or root@MSISHADOW or....???
I will try again in the morning.
Thanks again for your idea though!!
@Elirudite - the name must be the user's name so on your instance - root
.
@leafoflegend Right! Thanks! Got it figured out by just doing the following
I matched the username and password that was in my app's config/database.yml
file with a 'Login Role' as indicated in the PGadmin tool on the Windows side (or just create a new one with all the permissions ticked off then edit the database.yml file)
This is a pretty cool solution as I now might be able to add data from the GUI on Windows to the app, despite it running through WSL, so that I dont have to mess with the 'scary' Bash line ;)
@leafoflegend interesting workaround but does not actually solve the issue in this thread. I may use it in the short term though...
@skylarmb It's what we have for the moment! Obviously not a solution to a root problem. And as @Elirudite said, I do enjoy having a GUI interface in Windows as well - it almost seems to make more sense for the user then relying on strictly CLI. Atleast - until Windows can run Ubuntu GUI apps without problems!
Those clusterdb errors 'function not implemented'. One need to start ipc-daemon, cygserver and then only run the comand 'pipeline-init -D ../data'?
Curious if anyone has found a work-around for this with Django/psycopg2?
Still unable to install postgres with build 14393.447:
pg_createcluster is not working.
$ LANG=C sudo pg_createcluster 9.3 main --start
Creating new cluster 9.3/main ...
config /etc/postgresql/9.3/main
data /var/lib/postgresql/9.3/main
locale C
FATAL: could not create shared memory segment: Function not implemented
DETAIL: Failed system call was shmget(key=1, size=48, 03600).
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.3/main"
@bontakun-mk2 14393 probably doesn't have the necessary fixes. Most of the people on here are using 14971.
@fpqc thank you for information.
I tried build 14971.1000. But still not working.
I wait function implement.
@nickjevershed I just did it. Install the Windows MSI package and then postgresql-client and libpq-dev on WSL. That did the trick. WSL will work as a client and the server is the Windows MSI package.
@chocoelho I can confirm that I can do a sanity check with psql -p 5432 -h localhost -U postgres
.
Having postgresql-client, postgresql-client-common (not sure if this is need just had it installed so I could use psql
), and libpq-dev installed did the trick to interface between the Windows instance of Postgres and Bash commands.
I can also confirm that this works with Rails as well. You will need to explicitly state that your host (localhost), username & password. Will this be a stable platform I have yet to see.
Rails version: 5.0.0.1
Ruby version: 2.3.1 (x86_64-linux)
Could someone clarify what the solution is ? I'm still having trouble. Thx!
- Install Postgresql for Windows (the actual .exe not Linux Bash)
- Create User & Password for Postgresql (I use
postgres
&password
for my local development) - Install
postgresql-client-common
,postgresql-client
, andlibpq-dev
(In Bash) - Run a sanity check in Bash to verify that things are working
psql -p 5432 -h localhost -U postgres
- If you get a psql prompt you're good to go, now you can do what you need to do (my particular situation was to get Rails running)
- If you have errors well then you may just need to peck away at things and double check that your Postgres server is running in Windows
I created an idea on uservoice, so everyone can upvote this: https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/17440639-installing-postgres-fails
You probably don't want to run Postgres inside BashOnWindows anyways because of IO performance.
It's just plain simpler to run https://github.com/garethflowers/postgresql-portable on Windows side and connect via TCP on linux side
@colinrubbert This worked great for me, thanks.
Very minor edit - I think you meant "postgresql-client" not "postgres-client"
thanks @olinbg I will fix it. Must've just been speed typing π
Came to this issue, found the workaround, works great π
With build 15007 postgres works. The shared memory works.
What doesn't seem to work is the UNIX socket.
It starts and you can connect to it using TCP. To log in you first need to edit pg_hba.conf and enable 'trust' for 127.0.0.1
This bug isn't assigned to anyone, but can be closed per the above comment.
https://blogs.msdn.microsoft.com/commandline/2017/01/09/bash-in-windows-insider-build-15002-many-fixes-but-a-couple-of-bugs/
Along with support for the following shared-memory syscalls which are widely used by a number of Linux tools including PostgreSQL.
shmctl
shmget
shmdt
shmat
Is there a separate issue for the UNIX socket not working?
@arjennienhuis - Thanks for the validation and the post. Can you provide more specifics with what is not working with UNIX sockets? Targeted repro steps are very useful.
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo apt install postgresql-9.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpq5 libsensors4 libxslt1.1 postgresql-client-9.5 postgresql-client-common postgresql-common
postgresql-contrib-9.5 ssl-cert sysstat
Suggested packages:
lm-sensors locales-all postgresql-doc-9.5 libdbd-pg-perl openssl-blacklist isag
The following NEW packages will be installed:
libpq5 libsensors4 libxslt1.1 postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common
postgresql-contrib-9.5 ssl-cert sysstat
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,978 kB of archives.
After this operation, 20.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpq5 amd64 9.5.4-0ubuntu0.16.04 [77.8 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsensors4 amd64 1:3.4.0-2 [28.4 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxslt1.1 amd64 1.1.28-2.1 [145 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 postgresql-client-common all 173 [28.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-client-9.5 amd64 9.5.4-0ubuntu0.16.04 [860 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 ssl-cert all 1.0.37 [16.9 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 postgresql-common all 173 [153 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-9.5 amd64 9.5.4-0ubuntu0.16.04 [2,980 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-contrib-9.5 amd64 9.5.4-0ubuntu0.16.04 [446 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 sysstat amd64 11.2.0-1ubuntu0.1 [243 kB]
Fetched 4,978 kB in 1s (3,139 kB/s)
Selecting previously unselected package libpq5:amd64.
(Reading database ... 25453 files and directories currently installed.)
Selecting previously unselected package libsensors4:amd64...........................................................]
Selecting previously unselected package libxslt1.1:amd64............................................................]
Selecting previously unselected package postgresql-client-common....................................................]
Selecting previously unselected package postgresql-client-9.5.......................................................]
Selecting previously unselected package ssl-cert....................................................................]
Selecting previously unselected package postgresql-common...........................................................]
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'.......................]
Selecting previously unselected package postgresql-9.5.####.........................................................]
Selecting previously unselected package postgresql-contrib-9.5.##...................................................]
Selecting previously unselected package sysstat.######################..............................................]
Processing triggers for libc-bin (2.23-0ubuntu3) ...########################........................................]
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu8) ...
Processing triggers for ureadahead (0.100.0-19) ...
update-alternatives: using /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1Adding user postgres to group ssl-cert###############################################################...............]
Creating config file /etc/postgresql-common/createcluster.conf with new version
Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Creating new cluster 9.5/main ...
config /etc/postgresql/9.5/main
data /var/lib/postgresql/9.5/main
locale C
socket /var/run/postgresql
port 5432
update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Progress: [ 96%] [###############################################################################################...]
Creating config file /etc/default/sysstat with new version
Processing triggers for libc-bin (2.23-0ubuntu3) ...###############################################################.]
Processing triggers for systemd (229-4ubuntu8) ...
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.5 main 5432 down postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo lcluster 9.5 main start
The PostgreSQL server failed to start. Please check the log output:
2017-01-17 21:00:49 STD [2474-1] LOG: database system was shut down at 2017-01-17 20:59:36 STD
2017-01-17 21:00:49 STD [2474-2] LOG: MultiXact member wraparound protections are now enabled
2017-01-17 21:00:49 STD [2478-1] LOG: autovacuum launcher started
2017-01-17 21:00:49 STD [2473-1] LOG: database system is ready to accept connections
2017-01-17 21:00:50 STD [2480-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:50 STD [2483-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:51 STD [2486-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:51 STD [2489-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:52 STD [2492-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:52 STD [2495-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:53 STD [2498-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:54 STD [2501-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:54 STD [2504-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:55 STD [2507-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:55 STD [2510-1] [unknown]@[unknown] LOG: incomplete startup packet
2017-01-17 21:00:56 STD [2513-1] [unknown]@[unknown] LOG: incomplete startup packet
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ psql
psql: could not get socket error status: Invalid argument
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo sed -i s/md5$/trust/ /etc/postgresql/9.5/main/pg_hba.conf
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ sudo pg_ctlcluster 9.5 main reload
arjen@DESKTOP-PVQK426:/mnt/c/Users/Arjen$ psql --host 127.0.0.1 --user postgres
psql (9.5.4)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=#
Which is insecure because it disables all password checking
$ strace psql
...
socket(PF_LOCAL, SOCK_STREAM, 0) = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/postgresql/.s.PGSQL.5432"}, 110) = 0
getsockopt(4, SOL_SOCKET, SO_ERROR, 0x7fffca92ae5c, 0x7fffca92ae70) = -1 EINVAL (Invalid argument)
...
and in Linux:
socket(PF_LOCAL, SOCK_STREAM, 0) = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/postgresql/.s.PGSQL.5432"}, 110) = 0
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
The source says:
/*
* Write ready, since we've made it here, so the connection
* has been made ... or has failed.
*/
/*
* Now check (using getsockopt) that there is not an error
* state waiting for us on the socket.
*/
if (getsockopt(conn->sock, SOL_SOCKET, SO_ERROR,
(char *) &optval, &optlen) == -1)
@arjennienhuis - Thanks for collecting the trace and dissecting it out. Makes the analysis very easy. Good news is that the support for SO_ERROR
for unix socket was recently added (thanks @benhillis), but the fix is only available in our dev branch. It is making it's way to the release branch.
#1354 mentioned that. Thanks!
This doesn't work with 15014. Any idea when the fix will be released?
Support for SO_ERROR
for unix sockets came in 15019. Can you try with that build?
Same issue here with PostgreSQL 9.3.15
.
I'm still "Initializing updates"... π
everything seems to work on 15025
postgres@localhost:~$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "C". The default database encoding has accordingly been set to "SQL_ASCII". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /usr/local/pgsql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 20 selecting default shared_buffers ... 400kB selecting default time zone ... UTC creating configuration files ... ok running bootstrap script ... 2021-08-08 10:34:47.950 UTC [31924] FATAL: could not create shared memory segment: Operation not permitted 2021-08-08 10:34:47.950 UTC [31924] DETAIL: Failed system call was shmget(key=1081392, size=56, 03600). child process exited with exit code 1 initdb: removing contents of data directory "/usr/local/pgsql/data"