msfdb init后postgresql无法启动

rt:
win10 wsl下apt安装的msf,安装完成后可以启动postgresql

root@DESKTOP-AEQBL7Q:/home/aresx# service postgresql start
[ ok ] Starting PostgreSQL 11 database server: main.
root@DESKTOP-AEQBL7Q:/home/aresx# service metasploit start
metasploit: unrecognized service
root@DESKTOP-AEQBL7Q:/home/aresx# service postgresql status
11/main (port 5432): online

然后执行msfdb init

root@DESKTOP-AEQBL7Q:/home/aresx# msfdb init
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
[+] Starting database
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
[+] Creating database user 'msf'
[+] Creating databases 'msf'
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because
another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
createdb: database creation failed: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
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"?
[+] Creating databases 'msf_test'
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"?
[+] Creating configuration file '/usr/share/metasploit-framework/config/database.yml'
[+] Creating initial database schema
rake aborted!
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?
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/postgresql_adapter.rb:651:in `initialize'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/postgresql_adapter.rb:651:in `new'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/postgresql_adapter.rb:651:in `connect'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/postgresql_adapter.rb:242:in `initialize'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/postgresql_adapter.rb:44:in `new'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:438:in `new_connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:348:in `checkout'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:262:in `connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
handling.rb:113:in `retrieve_connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_
handling.rb:87:in `connection'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.r
b:941:in `initialize'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.r
b:823:in `new'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.r
b:823:in `up'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.r
b:801:in `migrate'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/tasks/datab
ase_tasks.rb:139:in `migrate'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/railties/da
tabases.rake:44:in `block (2 levels) in <top (required)>'
/usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

再执行service postgresql start就报错

root@DESKTOP-AEQBL7Q:/home/aresx# service postgresql start
[....] Starting PostgreSQL 11 database server: main[....] Error: /usr/lib/postgresql/11/bin/pg_ctl /usr/lib/postg
resql/11/bin/pg_ctl start -D /var/lib/postgresql/11/main -l /var/log/postgresql/postgresql-11-main.log -s -o -c c
onfig_file="/etc/postgresql/11/main/postgresql.conf" exited with status 1: 2019-03-23 13:27:29.357 DST [11560] LO
G: listening on IPv4 address "127.0.0.1", port 5432 2019-03-23 13:27:29.362 DST [11560] LOG: listening on Unix so
cket "/var/run/postgresql/.s.PGSQL.5432" 2019-03-23 13:27:29.411 DST [11561] LOG: database system was interrupted
; last known up at 2019-03-23 13:22:19 DST 2019-03-23 13:27:29.411 DST [11561] PANIC: could not flush dirty data:
 Function not implemented 2019-03-23 13:27:29.415 DST [11560] LOG: startup process (PID 11561) was terminated by
signal 6: Aborted 2019-03-23 13:27:29.416 DST [11560] LOG: aborting startup due to startup process failure 2019-0
3-23 13:27:29.422 DST [11560] LOG: database system is shut down pg_ctl: could not start server Examine the log ou
[FAIL ... failed!
 failed!

绝望.jpg

apt 卸载 postsqlgre 和 msf ,试试:

msf官方给的源安msf:

或者docker?

感觉不是最好的解决方案==


服务器资源由ZeptoVM赞助

Partners Wiki Discord