I want to find out the installation location of Postgresql and need to make some changes in postgresql.conf and pg_hba.conf files and restart Postgresql.
Is there any way to identify the installation directory which can be applied to Windows/Unix/Linux ? Any help or suggestion will be really appreciated.
Ask PostgreSQL:
SHOW config_file;
SHOW hba_file;
or:
SELECT current_setting('config_file');
SELECT current_setting('hba_file');
This, of course, requires PostgreSQL to be running, listening on TCP/IP, and on the default port. It also requires you to be able to authenticate. You would need to prompt the user for the port (default to 5432) and credentials.
There is no generic way to determine the PostgreSQL data directory location without asking a running PostgreSQL instance, because:
There might be more than one running PostgreSQL instance
PostgreSQL on Mac OS X might've been installed via Homebrew (Mac OS X), Postgres.app (Mac OS X), system package management (Linux), ports (BSD), the EnterpriseDB installer, various 3rd party rollup distributions, the .zip binaries, or from source.
PostgreSQL might be started and run from launchd (Mac OS X), as a Windows service (Windows), from systemd/upstart/init (Linux/BSD), manually by the user with pg_ctl, etc. A data directory can be specified on the startup command line.
So the whole idea that you can figure out "the" location of the PostgreSQL datadir is bogus.
If you're writing software that relies on PostgreSQL, consider bundling your own copy with the .zip binaries, starting it with pg_ctl and running it on a non-default port so it doesn't interfere with any PostgreSQL install the user may've put on their system themselves.
You can define custom environment variable like POSTGRES_HOME and use it similar to JAVA_HOME
POSTGRES_HOME = /usr/local/pgsql
pg_hba.conf path = POSTGRES_HOME/data/pg_hba.conf
Related
I need to install Weblogic 12.2.1.3 server on Windows without Administrator rights.
I followed the official guide and used java -jar fmw_12.2.1.3.0_wls.jar but it failed with the following error:
2019-07-23 17:02:05,062 SEVERE [1] com.oracle.cie.nextgen.launcher.Utils - Invalid Central Inventory location "C:\PROGRA~1\Oracle\product\12.2.0.1\oraInventory" (path contains invalid character(s)).
I think it failed because I do not have write permission for the mentioned directory. So I did some research on the internet for the solution.
What I have tried:
use -invPtrLoc option: Ignoring option "-invPtrLoc" (not applicable on Windows).
set INST_LOC=c:\Users\abc\dev\applications\oracle: no result
set inventory_loc=c:\Users\abc\dev\applications\oracle: no result
Do you have any idea what is the proper way to configure the installer to use different path for Oracle Inventory location?
ps: I am not allowed to execute random exe files on my computer so exe install packages are not options for me.
First, use a path without special characters like space. Even if you succeed in installing weblogic you will experience some difficulties when running servers without admin rights. Server start can be longer, patch list will not be available in the console and patching the product can be impossible. Maybe you can use a Windows VM with which you can have admin rights.
I want to deploy a a project to ec2. It was modify in Intellij which used MAVEN. It work perfect in Intellij. Below is the configuration of Intellij.
I have tried command line like java, javac. These kind of comment lines are all failed. I am wondering there must some way to convert Intellij configuration to command lines. I was relying too much on IDE. XD. Now I am regreted.
EC2 is the amazon cloud service for instances. If you aren't very experienced with it - the easiest you can do is to hire a machine with your fav operating system - for example Windows and use remote desktop to log in it and just do your normal IDE setup and run your app. You will have your app running on your instance and it will be working, even it is done the hard way. I will get downvotes for that, but it will work as a Swiss watch.
It depends from the kind of EC2 instance you're using.
For me would be simpler if it was a Linux instance.
I'll connect via ssh and git clone my project there from my bitbucket/github repository.
Then I'll use Maven, and there are many different options to run your project with Maven.
As suggested in the comments you could use the exec plugin.
But even in this way you'll have a list of problems to overcame.
For example your linux instance does not came with an preinstalled Java Runtime.
You have to install at least Java and Maven (choose ubuntu distro, so you can do easily with a package manager like apt-get).
Or, for example, another not easy task is connect via ssh to a Linux instance.
AWS generates a key.pem file that you have to use in order to successfully connect to your instance.
ssh -i .ssh/your-key-file.pem username#your-ec2-instance-address
And again, AWS does not tell you the name of the default user you must use to connect to your EC2 instance (if you choose ubuntu distro the username is ubuntu).
And again, when you save your-key-file.pem in your computer it must have the right permission
-rw-------# 1 freedev staff 1692 Apr 21 09:46 /Users/freedev/.ssh/your-key-file.pem
or your ssh client wont read it.
...looking back it was really a long way make a deploy on a EC2 instance.
I have solved it by myself.
Use mvn package to generated jar file for maven project.
nohup java xx.jar debug.xml & use this to run jar in shell. By using this command line, when exit (abort remote connection), the process / command will not get killed.
Command line jcmd is used to check running process pid.
I installed postgreSQL binaries in windows 7 32bit operating system; I can start the server from cmd but I cant run it as a windows service.
This is the error that I'm getting when I try to start the service manually:
"The postgreSQL service on local computer started and then stopped. some services stop automatically if they are not in use by other servces or programs"
All I need to do is; after booting to windows when I double clicked my java application I need to run my app smoothly without any database errors. I cannot do this because postgreSQL is not running as a windows service.
I found this in windows event viewer:
The description for Event ID 0 from source PostgreSQL cannot be found.
Either the component that raises this event is not installed on your local computer or the installation is corrupted.
You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
postgres cannot access the server configuration file
"C:/Windows/system32/pgsql/data/postgresql.conf": No such file or directory
I googled about it but I was not able to find an answer.
Problem was solved
path to the data directory was wrong in windows service file.
So I delete the service file from this method:
1)Run Regedit or Regedt32.
2)Go to the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"
3)Look for the postgreSQL service that you want delete and delete it.
4)reboot the computer.
After that open the cmd (Run as administrator) Go to the postgreSQL bin directory and run this command to create a new windows service:
pg_ctl.exe register -N "PostgreSQL" -U "NT AUTHORITY\NetworkService" -D "C:/Program Files/postgresql/pgsql/bin/pgsql/data" -w
This worked for me. Hope this will help.
This is a note for a normal user. If using an official installer it should has a build-in service,
Win+R and type services.msc
Search Postgres service based on the version installed,
e.g., "postgresql-x64-13 - PostgreSQL Server 13"
Click stop, start, or restart the service option
postgres cannot access the server configuration file
"C:/Windows/system32/pgsql/data/postgresql.conf": No such file or
directory
This looks like your working directory is C:\Windows\system32 and you are running postgres there and it looks for data/postgresql.conf.
Try changing the working directory or specifying -D C:\path\to\my\data.
I am doing some Java development on Windows 7 x64 running inside VMWare Fusion 3.x (OSX). I have installed JDK6 (update 26), set JAVA_HOME to the path (no trailing slash), and restarted my command prompt.
I can successfully launch the program. During startup it runs the calibration and then fails with this error:
"Could not create directory\VMWare-host\Shared Folders\ .nbprofiler" (no space after that slash but the markup was hiding the period)
I can click to continue, but when I'm in the program I cannot do CPU or Memory profiling. I throws up a similar error box:
"Error retrieving saved calibration data for target JVM: Could not create...(same as earlier)"
Once upon a time I had this working by passing the --userdir flag and -J-Dnbprofiler.home during startup, but that trick isn't working anymore.
(The complete command was:
jvisualvm --userdir c:\Users\myname -J-Dnbprofiler.home=c:\Users\myname
)
How can I force jvisualvm to save its calibration data on a "real" drive instead of the vmware network drive and get this working?
.nbprofiler directory is derived from user.home system property. I am not sure what you did to Windows installation, but your user.home points to directory\VMWare-host\Shared Folders. So one solution is to fix the Windows installation, so that Java recognize c:\Users\myname as your user home directory. If that fails for some reason you can use nbprofiler.home property to override it, as you correctly wrote. However you should point it to the nonexistent directory, so you should start VisualVM with the following commandline:
jvisualvm -J-Dnbprofiler.home=c:\Users\myname\nbprofiler --userdir c:\Users\myname\visualvm_userdir
One last note, even if the profiler part is not working, you should be able to use sampling in the 'Sampler' tab.
Try disable Sharing for the VM.
It works for me with Windows 7 x86 in Fusion with Sharing disabled (and Sharing is the mechanism providing the folder you cannot write to).
I found the following command works for me.
visualvm -J-Duser.home=%HOME%
Also, I needed to add -Duser.home=%HOME% to my app startup command.
I had defined nbprofile.home and userdir, but I was still getting an error when the Profiler was running against my app: Profiler Agent Error: Could not create directory\vmware-host\Shared Folders.nbprofiler.
I discovered that the Profiler was using user.home defined by my app rather than the one with visualvm. Both seem to be needed.
There is a strange problem with Netbeans. I'm trying to create new project with remote resources but when I enter all FTP and project information, Netbeans says
No files available for download. Try to check Passive mode in the
remote configuration
Although I tried the passive mode, it isn't the problem. There are many folders and files and I can see them via FTP client or I can create the project with same method on another Netbeans which is running another computer.
Both of them has Netbeans 7.0, both of them running Windows 7 and both of them using same internet connection!
There are no firewall or similar protection by the way.
For Netbeans 7.3, with Windows 7, using JDK 7
Open CMD as Administrator and run the following:
netsh advfirewall set global StatefulFTP disable
To open CMD as Administrator in Windows 7:
Select Start
In the "Search programs and files" box
Enter "CMD"
Find the result above and right click on it
Select "Run as Administrator" from the context menu
I found this after some digging via Mansiemans shared link. Some of the commands on that thread, did not work, so I am sharing the one that did work.
Initial Directory: "/"
Port: "21"
Set Passive mode on
You don't need to uninstall Java or re-install NetBeans. Just change the Java version used by Netbeans.
Edit file: <netbeans dir>\etc\netbeans.conf
Change this line: netbeans_jdkhome="C:\Program Files\Java\jre6"
I did not uninstall any thing.
I got jdk 1.6 folder from another computer and copied it to my computer in java installation directory.
Then I edited the \etc\netbeans.conf.
Changed this line: netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0"
jre6 was not working.
I did this in passive mode.
Uninstall java 7 and java se 7 development and install the last java 6 version http://www.java.com/en/download/inc/windows_new_xpi.jsp
upload directory in connector was automatically named as the project, making the dir on server that the connector will test: ftp://mysite.foo/mysite/mysite instead of ftp://mysite.foo/mysite/
clearing "upload directory" field worked for me
This page has a suggestion that worked for me. Apparently, Windows 7 / Vista firewall blocks certain FTP operations. When I turn off my Vista firewall, Netbeans does its thing.
If passive mode fails to get files then connect by Turning off your Firewall. In my case it worked. Then you can create a Rule in Firewall to allow netbeans.
This could be because your user account on the FTP server is configured to change to an initial directory upon connection.
Example: The Netbeans path is showing ftp://example.com/www/example.com (combining your provided host, initial directory and upload directory settings). However, your FTP user account is configured to initially connect to /www as the FTP root. Despite what Netbeans is telling you, you are actually connecting to ftp://example.com/www/www/example.com because, upon connection, the FTP server has changed the directory to www for your user account.
In which case, even though Netbeans is showing the correct path in the project wizard and in the console, you may not actually be connecting to the path in your Netbeans settings.
You can usually check if this is the case easily if you have a hosting account control panel with an FTP settings page. Your host may, however, not allow you to change the FTP root for security reasons (or perhaps you just shouldn't).
If you cannot change the FTP user root, or would prefer not to, then (in the e.g. above) you will have to make sure the Netbeans FTP path is ftp://example.com/example.com missing out the "www" directory (even though that is actually part of the correct path) because the FTP server will automatically change to this as the FTP root.
The above approach fixed this problem for me.
Set the initial directory chmod to 777.