You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.1-linux-x86_64.tar.gz
tar tar -xvf elasticsearch-7.15.1-linux-x86_64.tar.gz
elasticsearch 홈페이지에서 파일을 다운받은 뒤, 압축을 해제해 줍니다.
이 예시에서는 7.15.1 버전을 사용하고 있으며, 다른 버전을 사용해도 무방합니다.
useradd 명령어로 elastic이라는 계정을 생성한 뒤, chown 명령어로 압축 해제한 폴더 및 파일의 소유권을 해당 계정으로 변경해줍니다.
3. Port 설정
elasticsearch-7.15.1/config/elasticsearch.yml
http.port: 30001
Elasticsearch에 접속할 포트를 위 파일(elasticsearch.yml)에서 설정할 수 있습니다.
파일의 맨 밑에 위와 같이 추가하거나, 중간에 주석 처리되어있는 http.port: 9200 의 주석을 해제한 뒤, 원하는 포트로 변경해줍니다.
포트 번호는 방화벽 등에 의해 차단되지 않은, 접근 가능한 포트 번호 로 설정해 주셔야 합니다.
Python
pipinstallelasticsearch==7.15.1
pip 명령어를 통해 위에서 설치한 elasticsearch를 파이썬에서 사용할 수 있도록 패키지를 설치해 줍니다.
위에서 다운받은 elasticsearch 버전과 동일하게 맞춰주기 위해 7.15.1 버전을 지정하였습니다.
* 다운받은 elasticsearch의 버전과 pip로 설치한 elasticsearch 패키지의 버전이 다른 경우, 사용 중 오류가 발생할 수 있으므로 동일한 버전으로 설치해주세요.
실행
su elastic
nohup ./elasticsearch-7.15.1/bin/elasticsearch &
su elastic 명령어를 통해 elastic 계정으로 전환한 뒤, elasticsearch파일을 실행해줍니다.
처음에는 에러가 발생하는지 확인하기 위해 nohup과 & 없이 실행하는 것을 추천합니다.
ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f43c2b79580>:Failed to establish a new connection: [Errno 111] Connection refused) caused by:NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f43c2b79580>:Failed to establish a new connection: [Errno 111] Connection refused)
위 오류는 Elasticsearch에 접속하려고 할 때 일어날 수 있는 오류입니다.
Elsaticsearch 연결할 수 없는 상태로, 아래 사항들을 확인해보면 좋습니다.
config 파일 내의 포트 번호 설정 여부
config 파일 내의 http.port: [포트 번호] 가 지정되어 있는지 확인해주세요.
client 생성 시 Port번호와 config 내의 포트 번호 일치 여부
client = Elasticsearch("http://localhost:[포트 번호]") 의 포트 번호가 config 파일 내의 포트 번호 가 일치하는지 확인해주세요.
지정한 Port의 접속 가능 여부
위 두 가지를 모두 확인했다면, 접속하고자 하는 포트 번호가 방화벽 등에 의해 차단되지 않는, 접속 가능한 포트인지 확인 해주세요.
Elasticsearch 실행 여부
Elasticsearch가 실행 중이지 않은 경우에도 이 오류가 발생할 수 있습니다. ps -ef | grep elasticsearch를 실행하여 java, controller 프로세스가 실행 중인지 확인해줍니다.
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.elasticsearch.bootstrap.Elasticsearch (file:/opt/ml/elasticsearch-7.15.1/lib/elasticsearch-7.15.1.jar)
WARNING: Please consider reporting this to the maintainers of org.elasticsearch.bootstrap.Elasticsearch
WARNING: System::setSecurityManager will be removed in a future release
[2023-01-04T08:57:25,455][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [7ffb304d581e] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:171) ~[elasticsearch-7.15.1.jar:7.15.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:158) ~[elasticsearch-7.15.1.jar:7.15.1]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75) ~[elasticsearch-
(생략)
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170)
(생략)
For complete error details, refer to the log at /opt/ml/elasticsearch-7.15.1/logs/elasticsearch.log
2023-01-04 08:57:27,240579 UTC [11414] INFO Main.cc@111 Parent process died - ML controller exiting
위 오류는 터미널에서 elasticsearch를 실행할 때 일어날 수 있는 오류입니다.
강조한 부분에서 알 수 있듯, elasticsearch는 root 권한으로 실행할 수 없는데, root로 실행하려고 해서 생기는 오류입니다.
su elastic 으로 elastic 계정으로 전환한 뒤, elasticsearch를 다시 실행하면 정상적으로 실행됩니다.
The text was updated successfully, but these errors were encountered:
설치
Elasticsearch
1. 다운로드
elasticsearch 홈페이지에서 파일을 다운받은 뒤, 압축을 해제해 줍니다.
이 예시에서는 7.15.1 버전을 사용하고 있으며, 다른 버전을 사용해도 무방합니다.
2. 계정 생성 및 소유권 변경
useradd 명령어로 elastic이라는 계정을 생성한 뒤, chown 명령어로 압축 해제한 폴더 및 파일의 소유권을 해당 계정으로 변경해줍니다.
3. Port 설정
Elasticsearch에 접속할 포트를 위 파일(elasticsearch.yml)에서 설정할 수 있습니다.
파일의 맨 밑에 위와 같이 추가하거나, 중간에 주석 처리되어있는
http.port: 9200
의 주석을 해제한 뒤, 원하는 포트로 변경해줍니다.포트 번호는 방화벽 등에 의해 차단되지 않은,
접근 가능한 포트 번호
로 설정해 주셔야 합니다.Python
pip 명령어를 통해 위에서 설치한 elasticsearch를 파이썬에서 사용할 수 있도록 패키지를 설치해 줍니다.
위에서
다운받은 elasticsearch 버전과 동일하게
맞춰주기 위해7.15.1
버전을 지정하였습니다.실행
su elastic nohup ./elasticsearch-7.15.1/bin/elasticsearch &
su elastic 명령어를 통해 elastic 계정으로 전환한 뒤, elasticsearch파일을 실행해줍니다.
처음에는 에러가 발생하는지 확인하기 위해 nohup과 & 없이 실행하는 것을 추천합니다.
elasticsearch가 정상적으로 접근 가능한지 확인하기 위해 위 코드를 실행해 줍니다.
Output
잘 동작하는 것을 확인할 수 있습니다.
Troubleshooting
Connection refused
위 오류는 Elasticsearch에 접속하려고 할 때 일어날 수 있는 오류입니다.
Elsaticsearch 연결할 수 없는 상태로, 아래 사항들을 확인해보면 좋습니다.
http.port: [포트 번호]
가 지정되어 있는지 확인해주세요.client = Elasticsearch("http://localhost:[포트 번호]")
의 포트 번호가config 파일 내의 포트 번호
가 일치하는지 확인해주세요.접속 가능한 포트인지 확인
해주세요.ps -ef | grep elasticsearch
를 실행하여java, controller
프로세스가 실행 중인지 확인해줍니다.can not run elasticsearch as root
위 오류는 터미널에서 elasticsearch를 실행할 때 일어날 수 있는 오류입니다.
강조한 부분에서 알 수 있듯, elasticsearch는 root 권한으로 실행할 수 없는데, root로 실행하려고 해서 생기는 오류입니다.
su elastic
으로 elastic 계정으로 전환한 뒤, elasticsearch를 다시 실행하면 정상적으로 실행됩니다.The text was updated successfully, but these errors were encountered: