我的安装环境
CentOS 8
PHP 7.4
MySQL8.0
NGINX 1.18
有时候我们在使用composer安装Magento 2的时候遇到的安装错误问题,Installing search configuration…
In SearchConfig.php line 81:
Could not validate a connection to Elasticsearch. No alive nodes found in your cluster
setup:install [–backend-frontname BACKEND-FRONTNAME] [–enable-debug-logging ENABLE-DEBUG-LOGGING] [–enable-syslog-logging ENABLE-SYSLOG-LOGGING] [–remote-storage-driver REMOTE-STORAGE-DRIVER] [–remote-storage-prefix REMOTE-STORAGE-PREFIX] [–remote-storage-bucket REMOTE-STORAGE-BUCKET] [–remote-storage-region REMOTE-STORAGE-REGION] [–remote-storage-key REMOTE-STORAGE-KEY] [–remote-storage-secret REMOTE-STORAGE-SECRET] [–consumers-wait-for-messages CONSUMERS-WAIT-FOR-MESSAGES] [–amqp-host AMQP-HOST] [–amqp-port AMQP-PORT] [–amqp-user AMQP-USER] [–amqp-password AMQP-PASSWORD] [–amqp-virtualhost AMQP-VIRTUALHOST] [–amqp-ssl AMQP-SSL] [–amqp-ssl-options AMQP-SSL-OPTIONS] [–key KEY] [–db-host DB-HOST] [–db-name DB-NAME] [–db-user DB-USER] [–db-engine DB-ENGINE] [–db-password DB-PASSWORD] [–db-prefix DB-PREFIX] [–db-model DB-MODEL] [–db-init-statements DB-INIT-STATEMENTS] [-s|–skip-db-validation] [–http-cache-hosts HTTP-CACHE-HOSTS] [–db-ssl-key DB-SSL-KEY] [–db-ssl-cert DB-SSL-CERT] [–db-ssl-ca DB-SSL-CA] [–db-ssl-verify] [–session-save SESSION-SAVE] [–session-save-redis-host SESSION-SAVE-REDIS-HOST] [–session-save-redis-port SESSION-SAVE-REDIS-PORT] [–session-save-redis-password SESSION-SAVE-REDIS-PASSWORD] [–session-save-redis-timeout SESSION-SAVE-REDIS-TIMEOUT] [–session-save-redis-persistent-id SESSION-SAVE-REDIS-PERSISTENT-ID] [–session-save-redis-db SESSION-SAVE-REDIS-DB] [–session-save-redis-compression-threshold SESSION-SAVE-REDIS-COMPRESSION-THRESHOLD] [–session-save-redis-compression-lib SESSION-SAVE-REDIS-COMPRESSION-LIB] [–session-save-redis-log-level SESSION-SAVE-REDIS-LOG-LEVEL] [–session-save-redis-max-concurrency SESSION-SAVE-REDIS-MAX-CONCURRENCY] [–session-save-redis-break-after-frontend SESSION-SAVE-REDIS-BREAK-AFTER-FRONTEND] [–session-save-redis-break-after-adminhtml SESSION-SAVE-REDIS-BREAK-AFTER-ADMINHTML] [–session-save-redis-first-lifetime SESSION-SAVE-REDIS-FIRST-LIFETIME] [–session-save-redis-bot-first-lifetime SESSION-SAVE-REDIS-BOT-FIRST-LIFETIME] [–session-save-redis-bot-lifetime SESSION-SAVE-REDIS-BOT-LIFETIME] [–session-save-redis-disable-locking SESSION-SAVE-REDIS-DISABLE-LOCKING] [–session-save-redis-min-lifetime SESSION-SAVE-REDIS-MIN-LIFETIME] [–session-save-redis-max-lifetime SESSION-SAVE-REDIS-MAX-LIFETIME] [–session-save-redis-sentinel-master SESSION-SAVE-REDIS-SENTINEL-MASTER] [–session-save-redis-sentinel-servers SESSION-SAVE-REDIS-SENTINEL-SERVERS] [–session-save-redis-sentinel-verify-master SESSION-SAVE-REDIS-SENTINEL-VERIFY-MASTER] [–session-save-redis-sentinel-connect-retries SESSION-SAVE-REDIS-SENTINEL-CONNECT-RETRIES] [–cache-backend CACHE-BACKEND] [–cache-backend-redis-server CACHE-BACKEND-REDIS-SERVER] [–cache-backend-redis-db CACHE-BACKEND-REDIS-DB] [–cache-backend-redis-port CACHE-BACKEND-REDIS-PORT] [–cache-backend-redis-password CACHE-BACKEND-REDIS-PASSWORD] [–cache-backend-redis-compress-data CACHE-BACKEND-REDIS-COMPRESS-DATA] [–cache-backend-redis-compression-lib CACHE-BACKEND-REDIS-COMPRESSION-LIB] [–cache-id-prefix CACHE-ID-PREFIX] [–allow-parallel-generation] [–page-cache PAGE-CACHE] [–page-cache-redis-server PAGE-CACHE-REDIS-SERVER] [–page-cache-redis-db PAGE-CACHE-REDIS-DB] [–page-cache-redis-port PAGE-CACHE-REDIS-PORT] [–page-cache-redis-password PAGE-CACHE-REDIS-PASSWORD] [–page-cache-redis-compress-data PAGE-CACHE-REDIS-COMPRESS-DATA] [–page-cache-redis-compression-lib PAGE-CACHE-REDIS-COMPRESSION-LIB] [–page-cache-id-prefix PAGE-CACHE-ID-PREFIX] [–lock-provider LOCK-PROVIDER] [–lock-db-prefix LOCK-DB-PREFIX] [–lock-zookeeper-host LOCK-ZOOKEEPER-HOST] [–lock-zookeeper-path LOCK-ZOOKEEPER-PATH] [–lock-file-path LOCK-FILE-PATH] [–document-root-is-pub DOCUMENT-ROOT-IS-PUB] [–base-url BASE-URL] [–language LANGUAGE] [–timezone TIMEZONE] [–currency CURRENCY] [–use-rewrites USE-REWRITES] [–use-secure USE-SECURE] [–base-url-secure BASE-URL-SECURE] [–use-secure-admin USE-SECURE-ADMIN] [–admin-use-security-key ADMIN-USE-SECURITY-KEY] [–admin-user [ADMIN-USER]] [–admin-password [ADMIN-PASSWORD]] [–admin-email [ADMIN-EMAIL]] [–admin-firstname [ADMIN-FIRSTNAME]] [–admin-lastname [ADMIN-LASTNAME]] [–search-engine SEARCH-ENGINE] [–elasticsearch-host ELASTICSEARCH-HOST] [–elasticsearch-port ELASTICSEARCH-PORT] [–elasticsearch-enable-auth ELASTICSEARCH-ENABLE-AUTH] [–elasticsearch-username ELASTICSEARCH-USERNAME] [–elasticsearch-password ELASTICSEARCH-PASSWORD] [–elasticsearch-index-prefix ELASTICSEARCH-INDEX-PREFIX] [–elasticsearch-timeout ELASTICSEARCH-TIMEOUT] [–cleanup-database] [–sales-order-increment-prefix SALES-ORDER-INCREMENT-PREFIX] [–use-sample-data] [–enable-modules [ENABLE-MODULES]] [–disable-modules [DISABLE-MODULES]] [–convert-old-scripts [CONVERT-OLD-SCRIPTS]] [-i|–interactive] [–safe-mode [SAFE-MODE]] [–data-restore [DATA-RESTORE]] [–dry-run [DRY-RUN]] [–magento-init-params MAGENTO-INIT-PARAMS]
遇到这样的问题是应为在magento 2.4以后需要安装Elasticsearch
解决办法安装Elasticsearch
我安装是Elasticsearch
7
1.Java是在任何系统上安装Elasticsearch的主要需求。执行如下命令检查Java的安装版本。
1 | dnf install java-11-openjdk |
1 2 3 4 5 | java -version openjdk version "11.0.8" 2020-07-14 LTS OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing) |
2.配置Yum Repository
1 | sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch |
接下来,为Elasticsearch创建一个yum存储库配置文件。编辑/etc/yum.repos.d/elasticsearch.repo
文件在您最喜爱的文本编辑器:
1 | sudo vi /etc/yum.repos.d/elasticsearch.repo |
1 2 3 4 5 6 7 8 | [Elasticsearch-7] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md |
3.安装Elasticsearch
1 | sudo dnf install elasticsearch |
4.设置以下值以自定义Elasticsearch环境
1 | vim /etc/elasticsearch/elasticsearch.yml |
1 2 3 4 5 6 7 8 9 10 11 | # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # #network.host: 192.168.0.1 //<- **** uncomment this line then replace it with : network.host: localhost # # Set a custom port for HTTP: # #http.port: 9200 # # For more information, consult the network module documentation. |
5.我们开始Elasticsearch
1 2 | sudo systemctl start elasticsearch sudo systemctl enable elasticsearch |
1 | sudo systemctl status elasticsearch |
输出
1 2 3 4 5 6 7 8 9 10 11 12 13 | ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2020-10-21 05:28:25 UTC; 12min ago Docs: https://www.elastic.co Main PID: 99609 (java) Tasks: 61 (limit: 75413) Memory: 1.2G CGroup: /system.slice/elasticsearch.service ├─99609 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -X> └─99818 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller Oct 21 05:28:09 centos8 systemd[1]: Starting Elasticsearch... Oct 21 05:28:25 centos8 systemd[1]: Started Elasticsearch. |
6.测试Elasticsearch
1 | curl -X GET "localhost:9200/?pretty" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | { "name" : "centos8", "cluster_name" : "TecAdmin-ES-Cluster", "cluster_uuid" : "a0OZk1c1TEmPTlA24uT4zQ", "version" : { "number" : "7.9.2", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e", "build_date" : "2020-09-23T00:45:33.626720Z", "build_snapshot" : false, "lucene_version" : "8.6.2", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } |
好了安装成功后再次安装Magento 2.4就好了。