목표: vm centos7에 postgresql-14 / sonarqube Community 9.2.4 설치
0. vm 복제 및 서버 준비
1. 사전 서버설정
https://docs.sonarqube.org/latest/requirements/requirements/
# sysctl -a //시스템 변수 확인
# sysctl -w vm.max_map_count=524288
# sysctl -w fs.file-max=131072
# ulimit -n 131072
# ulimit -u 8192
2. 설치
가. postgresql
# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# yum install -y postgresql14-server postgresql14-contrib
# /usr/pgsql-14/bin/postgresql-14-setup initdb
//postgres 계정 생성됨
# sudo systemctl enable postgresql-14
# sudo systemctl start postgresql-14
# su - postgres
$ psql
postgres=# create user sonarqube with password 'sonarqube';
postgres=# create database sonarqube owner sonarqube;
postgres=# ALTER ROLE sonarqube WITH createdb;
postgres=# GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonarqube;
postgres=# \q
$ vim /var/lib/pgsql/14/data/postgresql.conf
//주석해제 및 수정
listen_addresses = '*'
port = 5432
$ vim /var/lib/pgsql/14/data/pg_hba.conf
//맨 아래 추가
> host all sonarqube 0.0.0.0/0 md5
# systemctl restart postgresql-14
나. sonarqube
# adduser sonarqube
# su - sonarqube
$ wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.2.4.50792.zip
$ unzip sonarqube-9.2.4.50792.zip
$ cd sonarqube-9.2.4.50792/conf
$ vim sonar.properties
//주석제거 및 수정
sonar.jdbc.username=sonarqube
sonar.jdbc.password=sonarqube
sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube
$ cd ../bin/linux-x86-64
$ ./sonar.sh start
실행하고 로그를 확인했더니 아래와 같이 에러가 발생하였다
//es.log
2022.01.05 15:30:00 ERROR app[][o.s.a.p.EsManagedProcess] Failed to check status
org.elasticsearch.ElasticsearchException: java.util.concurrent.ExecutionException: java.net.ConnectException: 연결이 거부됨
at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2695)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:2171)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:2137)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:2105)
at org.elasticsearch.client.ClusterClient.health(ClusterClient.java:151)
at org.sonar.application.es.EsConnectorImpl.getClusterHealthStatus(EsConnectorImpl.java:64)
at org.sonar.application.process.EsManagedProcess.checkStatus(EsManagedProcess.java:97)
at org.sonar.application.process.EsManagedProcess.checkOperational(EsManagedProcess.java:82)
at org.sonar.application.process.EsManagedProcess.isOperational(EsManagedProcess.java:67)
at org.sonar.application.process.ManagedProcessHandler.refreshState(ManagedProcessHandler.java:220)
at org.sonar.application.process.ManagedProcessHandler$EventWatcher.run(ManagedProcessHandler.java:285)
Caused by: java.util.concurrent.ExecutionException: java.net.ConnectException: 연결이 거부됨
at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:257)
at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:244)
at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:75)
at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2692)
... 10 common frames omitted
Caused by: java.net.ConnectException: 연결이 거부됨
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
at java.base/java.lang.Thread.run(Thread.java:829)
ERROR: [2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch.
bootstrap check failure [1] of [2]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
bootstrap check failure [2] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
1번에서 사전 설정한 내용과 겹치지만.. 우선 에러가 나니 root계정에서 설정 값을 변경해보았다.
1. /etc/security/limits.conf
vi /etc/security/limits.conf
//아래 내용 추가
root soft nofile 65536
root hard nofile 65536
sonarqube soft nofile 65536
sonarqube hard nofile 65536
# End of file
2. 변수 값 변경(elastic 이 돌기 위한 설정 값으로 변경)
sysctl -w vm.max_map_count=262144
위와 같이 수정을 하고나니 같은 에러는 안나는데, 다른 에러가 난다.
용량이 없나보다.
//web.log
Caused by: java.nio.file.FileSystemException: /home/sonarqube/sonarqube-9.2.4.50792/lib/extensions/sonar-scala-plugin-1.8.3.2219.jar -> /home/sonarqube/sonarqube-9.2.4.50792/data/web/deploy/plugins/sonarscala/sonar-scala-plugin-1.8.3.2219.jar: 장치에 남은 공간이 없음
아니 8기가 배정에 벌써 6기가를 다 써버렸다니.. 충격과 공포다.. 아무래도 다시 세팅해야 할 것 같다..
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.4G 0 2.4G 0% /dev
tmpfs 2.4G 28K 2.4G 1% /dev/shm
tmpfs 2.4G 9.2M 2.4G 1% /run
tmpfs 2.4G 0 2.4G 0% /sys/fs/cgroup
/dev/mapper/centos-root 6.2G 6.2G 18M 100% /
/dev/sda1 1014M 226M 789M 23% /boot
tmpfs 480M 8.0K 480M 1% /run/user/42
tmpfs 480M 0 480M 0% /run/user/0
..후기..
다음 날 32기가로 다시 세팅해서.. 결국 보았다. ui를!!
참고
https://www.fosslinux.com/24429/how-to-install-and-configure-sonarqube-on-centos-7.htm