Giter VIP home page Giter VIP logo

Comments (13)

kou avatar kou commented on May 31, 2024 1

速くなってよかったです!
精度もあがっているはずなのでそれも体感してください!

from redmine_full_text_search.

kou avatar kou commented on May 31, 2024

OSを教えてもらえますか?
また、PostgreSQLのインストール方法も教えてもらえますか?

from redmine_full_text_search.

kou avatar kou commented on May 31, 2024

あと、Redmineがredmineスキーマを使っているかどうかって確認できますか?
Redmineが使っているスキーマがredmineスキーマでない場合は、Redmineが使っているスキーマにPGroongaをインストールしてみてください。

あ、PGroongaのインストール方法も教えてください。

from redmine_full_text_search.

yassan avatar yassan commented on May 31, 2024

@kou OSは、 CentOS Linux release 7.5.1804 (Core) となります。

PostgreSQLは、公式のリポジトリを追加して、yumでインストールしています。

# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
# yum install postgresql10 postgresql10-docs postgresql10-libs \
>  postgresql10-server postgresql10-contrib postgresql10-devel \
> postgresql10-plpython postgresql10-plperl

PGroongaのインストールは、以下のとおりです。

yumで以下のようにインストール

# yum install https://packages.groonga.org/centos/groonga-release-latest.noarch.rpm
# yum install postgresql10-pgroonga

redmineスキーマのあるredmineデータベースに接続して、拡張機能追加して、権限付与

# psql -h 10.XX.XX.XX -U db_master redmine -W
ユーザー db_master のパスワード: 
psql (10.5)
"help" でヘルプを表示します。

redmine=# \conninfo 
データベース "redmine" にユーザ "db_master" として、ホスト "10.XX.XX.XX" 上のポート "5432" を介して接続しています。
redmine=# CREATE EXTENSION IF NOT EXISTS pgroonga;
CREATE EXTENSION

redmine=# GRANT USAGE ON SCHEMA pgroonga TO db_master;
GRANT

また、redmineデータベースのスキーマの状況は以下のようになっています。
image

from redmine_full_text_search.

kou avatar kou commented on May 31, 2024

Redmineを実行するべきユーザーでRedmineのディレクトリーで次のコマンドを実行したときの結果を教えてもらえますか?

% bin/rails dbconsole -e production
Enter password: (PostgreSQLへ接続するためのパスワードを入力)
redmine=# \conninfo 
redmine=# \d

from redmine_full_text_search.

kou avatar kou commented on May 31, 2024

結果は全部そのまま貼り付けて欲しいです!

from redmine_full_text_search.

yassan avatar yassan commented on May 31, 2024
# bin/rails dbconsole -e production
パスワード: 
psql (10.5)
"help" でヘルプを表示します。

redmine=# \conninfo 
データベース "redmine" にユーザ "db_master" として、ホスト "10.XX.XX.XX" 上のポート "5432" を介して接続しています。
redmine=# \d
リレーションが見つかりませんでした。

とあったので、空のpublicスキーマを参照しているのかと考え、search_path の設定を設定して再度確認

redmine=# show search_path;
 search_path 
-------------
 redmine
(1 行)

redmine=# \d
                                リレーション一覧
 スキーマ |                    名前                    |     型     |  所有者   
----------+--------------------------------------------+------------+-----------
 redmine  | attachments                                | テーブル   | postgres
 redmine  | attachments_id_seq                         | シーケンス | postgres
 redmine  | auth_sources                               | テーブル   | postgres
 redmine  | auth_sources_id_seq                        | シーケンス | postgres
 redmine  | banners                                    | テーブル   | db_master
 redmine  | banners_id_seq                             | シーケンス | db_master
 redmine  | boards                                     | テーブル   | postgres
 redmine  | boards_id_seq                              | シーケンス | postgres
 redmine  | changes                                    | テーブル   | postgres
 redmine  | changes_id_seq                             | シーケンス | postgres
 redmine  | changeset_parents                          | テーブル   | postgres
 redmine  | changesets                                 | テーブル   | postgres
 redmine  | changesets_id_seq                          | シーケンス | postgres
 redmine  | changesets_issues                          | テーブル   | postgres
 redmine  | checklist_template_categories              | テーブル   | db_master
 redmine  | checklist_template_categories_id_seq       | シーケンス | db_master
 redmine  | checklist_templates                        | テーブル   | db_master
 redmine  | checklist_templates_id_seq                 | シーケンス | db_master
 redmine  | checklists                                 | テーブル   | db_master
 redmine  | checklists_id_seq                          | シーケンス | db_master
 redmine  | code_review_assignments                    | テーブル   | postgres
 redmine  | code_review_assignments_id_seq             | シーケンス | postgres
 redmine  | code_review_project_settings               | テーブル   | postgres
 redmine  | code_review_project_settings_id_seq        | シーケンス | postgres
 redmine  | code_review_user_settings                  | テーブル   | postgres
 redmine  | code_review_user_settings_id_seq           | シーケンス | postgres
 redmine  | code_reviews                               | テーブル   | postgres
 redmine  | code_reviews_id_seq                        | シーケンス | postgres
 redmine  | comments                                   | テーブル   | postgres
 redmine  | comments_id_seq                            | シーケンス | postgres
 redmine  | custom_field_enumerations                  | テーブル   | db_master
 redmine  | custom_field_enumerations_id_seq           | シーケンス | db_master
 redmine  | custom_fields                              | テーブル   | postgres
 redmine  | custom_fields_id_seq                       | シーケンス | postgres
 redmine  | custom_fields_projects                     | テーブル   | postgres
 redmine  | custom_fields_roles                        | テーブル   | postgres
 redmine  | custom_fields_trackers                     | テーブル   | postgres
 redmine  | custom_values                              | テーブル   | postgres
 redmine  | custom_values_id_seq                       | シーケンス | postgres
 redmine  | departments                                | テーブル   | db_master
 redmine  | departments_id_seq                         | シーケンス | db_master
 redmine  | documents                                  | テーブル   | postgres
 redmine  | documents_id_seq                           | シーケンス | postgres
 redmine  | drafts                                     | テーブル   | postgres
 redmine  | drafts_id_seq                              | シーケンス | postgres
 redmine  | email_addresses                            | テーブル   | db_master
 redmine  | email_addresses_id_seq                     | シーケンス | db_master
 redmine  | enabled_modules                            | テーブル   | postgres
 redmine  | enabled_modules_id_seq                     | シーケンス | postgres
 redmine  | enumerations                               | テーブル   | postgres
 redmine  | enumerations_id_seq                        | シーケンス | postgres
 redmine  | favorite_projects                          | テーブル   | db_master
 redmine  | favorite_projects_id_seq                   | シーケンス | db_master
 redmine  | feelings                                   | テーブル   | db_master
 redmine  | feelings_id_seq                            | シーケンス | db_master
 redmine  | global_issue_templates                     | テーブル   | postgres
 redmine  | global_issue_templates_id_seq              | シーケンス | postgres
 redmine  | global_issue_templates_projects            | テーブル   | postgres
 redmine  | groups_users                               | テーブル   | postgres
 redmine  | import_in_progresses                       | テーブル   | postgres
 redmine  | import_in_progresses_id_seq                | シーケンス | postgres
 redmine  | import_items                               | テーブル   | db_master
 redmine  | import_items_id_seq                        | シーケンス | db_master
 redmine  | imports                                    | テーブル   | db_master
 redmine  | imports_id_seq                             | シーケンス | db_master
 redmine  | issue_badge_user_settings                  | テーブル   | db_master
 redmine  | issue_badge_user_settings_id_seq           | シーケンス | db_master
 redmine  | issue_categories                           | テーブル   | postgres
 redmine  | issue_categories_id_seq                    | シーケンス | postgres
 redmine  | issue_relations                            | テーブル   | postgres
 redmine  | issue_relations_id_seq                     | シーケンス | postgres
 redmine  | issue_statuses                             | テーブル   | postgres
 redmine  | issue_statuses_id_seq                      | シーケンス | postgres
 redmine  | issue_template_settings                    | テーブル   | postgres
 redmine  | issue_template_settings_id_seq             | シーケンス | postgres
 redmine  | issue_templates                            | テーブル   | postgres
 redmine  | issue_templates_id_seq                     | シーケンス | postgres
 redmine  | issues                                     | テーブル   | postgres
 redmine  | issues_id_seq                              | シーケンス | postgres
 redmine  | journal_details                            | テーブル   | postgres
 redmine  | journal_details_id_seq                     | シーケンス | postgres
 redmine  | journals                                   | テーブル   | postgres
 redmine  | journals_id_seq                            | シーケンス | postgres
 redmine  | member_roles                               | テーブル   | postgres
 redmine  | member_roles_id_seq                        | シーケンス | postgres
 redmine  | members                                    | テーブル   | postgres
 redmine  | members_id_seq                             | シーケンス | postgres
 redmine  | messages                                   | テーブル   | postgres
 redmine  | messages_id_seq                            | シーケンス | postgres
 redmine  | news                                       | テーブル   | postgres
 redmine  | news_id_seq                                | シーケンス | postgres
 redmine  | niko_faces                                 | テーブル   | postgres
 redmine  | niko_faces_id_seq                          | シーケンス | postgres
 redmine  | niko_responses                             | テーブル   | postgres
 redmine  | niko_responses_id_seq                      | シーケンス | postgres
 redmine  | open_id_authentication_associations        | テーブル   | postgres
 redmine  | open_id_authentication_associations_id_seq | シーケンス | postgres
 redmine  | open_id_authentication_nonces              | テーブル   | postgres
 redmine  | open_id_authentication_nonces_id_seq       | シーケンス | postgres
 redmine  | people_announcements                       | テーブル   | db_master
 redmine  | people_announcements_id_seq                | シーケンス | db_master
 redmine  | people_holidays                            | テーブル   | db_master
 redmine  | people_holidays_id_seq                     | シーケンス | db_master
 redmine  | people_information                         | テーブル   | db_master
 redmine  | people_information_user_id_seq             | シーケンス | db_master
 redmine  | people_work_experiences                    | テーブル   | db_master
 redmine  | people_work_experiences_id_seq             | シーケンス | db_master
 redmine  | periodictasks                              | テーブル   | db_master
 redmine  | periodictasks_id_seq                       | シーケンス | db_master
 redmine  | projects                                   | テーブル   | postgres
 redmine  | projects_default_queries                   | テーブル   | db_master
 redmine  | projects_default_queries_id_seq            | シーケンス | db_master
 redmine  | projects_id_seq                            | シーケンス | postgres
 redmine  | projects_trackers                          | テーブル   | postgres
 redmine  | pwfmt_formats                              | テーブル   | db_master
 redmine  | pwfmt_formats_id_seq                       | シーケンス | db_master
 redmine  | queries                                    | テーブル   | postgres
 redmine  | queries_id_seq                             | シーケンス | postgres
 redmine  | queries_roles                              | テーブル   | postgres
 redmine  | repositories                               | テーブル   | postgres
 redmine  | repositories_id_seq                        | シーケンス | postgres
 redmine  | roles                                      | テーブル   | postgres
 redmine  | roles_id_seq                               | シーケンス | postgres
 redmine  | roles_managed_roles                        | テーブル   | db_master
 redmine  | schema_migrations                          | テーブル   | postgres
 redmine  | settings                                   | テーブル   | postgres
 redmine  | settings_id_seq                            | シーケンス | postgres
 redmine  | taggings                                   | テーブル   | db_master
 redmine  | taggings_id_seq                            | シーケンス | db_master
 redmine  | tags                                       | テーブル   | db_master
 redmine  | tags_id_seq                                | シーケンス | db_master
 redmine  | theme_changer_user_settings                | テーブル   | postgres
 redmine  | theme_changer_user_settings_id_seq         | シーケンス | postgres
 redmine  | time_entries                               | テーブル   | postgres
 redmine  | time_entries_id_seq                        | シーケンス | postgres
 redmine  | tokens                                     | テーブル   | postgres
 redmine  | tokens_id_seq                              | シーケンス | postgres
 redmine  | trackers                                   | テーブル   | postgres
 redmine  | trackers_id_seq                            | シーケンス | postgres
 redmine  | user_issue_months                          | テーブル   | postgres
 redmine  | user_issue_months_id_seq                   | シーケンス | postgres
 redmine  | user_preferences                           | テーブル   | postgres
 redmine  | user_preferences_id_seq                    | シーケンス | postgres
 redmine  | users                                      | テーブル   | postgres
 redmine  | users_id_seq                               | シーケンス | postgres
 redmine  | versions                                   | テーブル   | postgres
 redmine  | versions_id_seq                            | シーケンス | postgres
 redmine  | view_customizes                            | テーブル   | db_master
 redmine  | view_customizes_id_seq                     | シーケンス | db_master
 redmine  | watchers                                   | テーブル   | postgres
 redmine  | watchers_id_seq                            | シーケンス | postgres
 redmine  | wiki_content_versions                      | テーブル   | postgres
 redmine  | wiki_content_versions_id_seq               | シーケンス | postgres
 redmine  | wiki_contents                              | テーブル   | postgres
 redmine  | wiki_contents_id_seq                       | シーケンス | postgres
 redmine  | wiki_extensions_comments                   | テーブル   | postgres
 redmine  | wiki_extensions_comments_id_seq            | シーケンス | postgres
 redmine  | wiki_extensions_counts                     | テーブル   | postgres
 redmine  | wiki_extensions_counts_id_seq              | シーケンス | postgres
 redmine  | wiki_extensions_menus                      | テーブル   | postgres
 redmine  | wiki_extensions_menus_id_seq               | シーケンス | postgres
 redmine  | wiki_extensions_settings                   | テーブル   | postgres
 redmine  | wiki_extensions_settings_id_seq            | シーケンス | postgres
 redmine  | wiki_extensions_tag_relations              | テーブル   | postgres
 redmine  | wiki_extensions_tag_relations_id_seq       | シーケンス | postgres
 redmine  | wiki_extensions_tags                       | テーブル   | postgres
 redmine  | wiki_extensions_tags_id_seq                | シーケンス | postgres
 redmine  | wiki_extensions_votes                      | テーブル   | postgres
 redmine  | wiki_extensions_votes_id_seq               | シーケンス | postgres
 redmine  | wiki_pages                                 | テーブル   | postgres
 redmine  | wiki_pages_id_seq                          | シーケンス | postgres
 redmine  | wiki_redirects                             | テーブル   | postgres
 redmine  | wiki_redirects_id_seq                      | シーケンス | postgres
 redmine  | wikis                                      | テーブル   | postgres
 redmine  | wikis_id_seq                               | シーケンス | postgres
 redmine  | workflows                                  | テーブル   | postgres
 redmine  | workflows_id_seq                           | シーケンス | postgres
 redmine  | wt_daily_memos                             | テーブル   | postgres
 redmine  | wt_daily_memos_id_seq                      | シーケンス | postgres
 redmine  | wt_holidays                                | テーブル   | postgres
 redmine  | wt_holidays_id_seq                         | シーケンス | postgres
 redmine  | wt_member_orders                           | テーブル   | postgres
 redmine  | wt_member_orders_id_seq                    | シーケンス | postgres
 redmine  | wt_project_orders                          | テーブル   | postgres
 redmine  | wt_project_orders_id_seq                   | シーケンス | postgres
 redmine  | wt_ticket_relays                           | テーブル   | postgres
 redmine  | wt_ticket_relays_id_seq                    | シーケンス | postgres
(187 行)

として、見えるようになったのですが、再度プラグインをインストールしたのですが、エラー文は変わらず

# bundle exec rake --trace redmine:plugins:migrate RAILS_ENV=production
** Invoke redmine:plugins:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:plugins:migrate
Migrating clipboard_image_paste (Clipboard image paste)...
Migrating full_text_search (Full Text Search plugin)...
== 20170630063557 RegisterFunctionsVector: migrating ==========================
-- execute("select pgroonga_command('plugin_register functions/vector')")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedFunction: ERROR:  function pgroonga_command(unknown) does not exist
LINE 1: select pgroonga_command('plugin_register functions/vector')
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
: select pgroonga_command('plugin_register functions/vector')
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec'
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute'
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/usr/local/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute'
 :

のままとなっていました。

\dした際に、pgroongaスキーマがなかったのですが、それが影響しているのでしょうか。

参考:config/database.yml

production:
  adapter: postgresql
  database: redmine
  schema_search_path: redmine
  host: "10.XX.XX.XX"
  username: "db_master"
  password: "XXXXXXX"
  encoding: utf8

from redmine_full_text_search.

kou avatar kou commented on May 31, 2024

空のpublicスキーマを参照しているのかと考え、search_path の設定を設定して再度確認

これは、config/database.ymlschema_search_path: redmineを追加して再度bin/rails dbconsole -e productionした、ってことであっていますか?

from redmine_full_text_search.

yassan avatar yassan commented on May 31, 2024

これは、config/database.ymlにschema_search_path: redmineを追加して再度bin/rails dbconsole -e productionした、ってことであっていますか?

いえ、一番始めに報告した時点で、 config/database.ymlschema_search_path: redmine は入っています。

また、一応、以下の通り、スキーマ一覧に pgronnga スキーマは出てきます。

redmine=# \conninfo 
データベース "redmine" にユーザ "db_master" として、ホスト "10.XX.XX.XX" 上のポート "5432" を介して接続しています。

redmine=# \dn
     スキーマ一覧
   名前   |  所有者   
----------+-----------
 pgroonga | db_master
 public   | postgres
 redmine  | postgres
(3 行)

from redmine_full_text_search.

kou avatar kou commented on May 31, 2024

なるほど、ということは、(書いていないけど)↓の前にset search_pathをしたってことであっていますか?

redmine=# show search_path;
 search_path 
-------------
 redmine
(1 行)

from redmine_full_text_search.

yassan avatar yassan commented on May 31, 2024

はい。そうです。

もうちょっと補足すると、config/database.ymlschema_search_path: redmine は初めから入った状態でした。

set search_pathしたのは、 #54 (comment) の時点で、

redmine=# \d
リレーションが見つかりませんでした。

を確認した際に、set search_pathを実行しています。

その結果、以下が出るようになったという状況です。

redmine=# \d
                                リレーション一覧
 スキーマ |                    名前                    |     型     |  所有者   
----------+--------------------------------------------+------------+-----------
 redmine  | attachments                                | テーブル   | postgres
 redmine  | attachments_id_seq                         | シーケンス | postgres
 redmine  | auth_sources                               | テーブル   | postgres
 redmine  | auth_sources_id_seq                        | シーケンス | postgres

from redmine_full_text_search.

kou avatar kou commented on May 31, 2024

なるほど。
rails dbconsoleのときにsearch_pathが設定されていないなら、おそらくredmine:plugins:migrateのときも設定されていないんだと思います。どうするといいのかしら。

スキーマを設定しなくてもいいなら設定しないといいと思うんですが、必須ですか?

あと、publicを入れないなら、CREATE EXTENSION pgroongaだけだと見えないはずです。
CREATE EXTENSION pgroonga SCHEMA redmineとか参照するスキーマにインストールしないといけません。

CREATE EXTENSION: https://www.postgresql.jp/document/10/html/sql-createextension.html

from redmine_full_text_search.

yassan avatar yassan commented on May 31, 2024

CREATE EXTENSION pgroonga SCHEMA redmineとか参照するスキーマにインストールしないといけません。

確かに、、そうですね。。。初歩的なミスでした。。

スキーマを設定しなくてもいいなら設定しないといいと思うんですが、必須ですか?

必須ではないのですが、既存環境がpublicではなく、あえて、redmineスキーマで作成してしまっていただけです。。。

動作確認が先なので、一旦、dropして、schema指定して入れ直してみました。

redmine=# drop extension pgroonga;
DROP EXTENSION
redmine=# create extension pgroonga schema redmine;
CREATE EXTENSION

するとインストール出来ました!(mecabの入れ忘れもありましたが。。。)


まとめ。

publicスキーマではなく、任意のスキーマ(例:redmine)にredmineデータバースを作成していた場合は、以下が事前に必要だった。

  • config/database.ymlschema_search_path: redmine を追加
  • redmineデータベースにて、 search_path に redmineを追加
redmine=# ALTER USER db_master SET search_path TO redmine;
  • redmineデータベースにて、redmineスキーマを指定して、pgroongaをインストール
redmine=# CREATE EXTENSION pgroonga SCHEMA redmine IF NOT EXISTS pgroonga;
CREATE EXTENSION

長々とありがとうございます!
チケット件数が24万件超えているので、検索が体感で明らかに早くなりました!

from redmine_full_text_search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.