How to auto start elasticsearch in Centos 6.5? - linux

I have installed elasticsearh on a server based on Cent OS 6.5. To start it:
# cd /usr/share/elasticsearch/elasticsearch-1.5.2]
# ./bin/elasticsearch &
But when I close the terminal, the process is killed. How can I set it to automatically start as a service?

Try using the "nohup" command with elastic search.
$ nohup ./bin/elasticsearch
Now what the nohup does? In the following example, it starts the program abcd in the background in such a way that the subsequent logout does not stop it.
$ nohup abcd &
$ exit
Hope that helped.

As #DerStoffel said, you have to start elasticsearch as a service (sudo service elasticsearch start). This is highly recommended in production settings. Also add the service to start in case of reboot (sudo /sbin/chkconfig --add elasticsearch)

It depends the distribution of linux you use:
Debian/Ubuntu
sudo update-rc.d elasticsearch defaults 95 10
sudo /etc/init.d/elasticsearch start
https://www.elastic.co/guide/en/elasticsearch/reference/1.6/setup-service.html#_debian_ubuntu
RPM based distributions like Centos
sudo /sbin/chkconfig --add elasticsearch
sudo service elasticsearch start
https://www.elastic.co/guide/en/elasticsearch/reference/1.6/setup-service.html#_rpm_based_distributions

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo /bin/systemctl start elasticsearch.service

Related

Setting up Apache on Arch Linux

I can't get apache to run on Arch Linux.
I tried ‍‍‍pacman -S apache => systemctl start httpd => systemctl enable httpd but it didn't work.
help me.
update the system db : sudo pacman -Syu
install apache web server : sudo pacman -S apache
enable apache service : sudo systemctl enable httpd and sudo systemctl restart httpd
get the status of Apache service : sudo systemctl status httpd
Archlinux Wiki has a good material about how to set up Apache on Archlinux, you could check it first:
https://wiki.archlinux.org/title/Apache_HTTP_Server

Do I have to start Elastic search?

If Elastic Search is always running on port:9200, do I have to start it each time I use it?
I am using Linux, MAC and Windows, in a nut shell I run command "bin/elastic" or another variation based on OS commands and it usually "starts" Elastic Search.
I just want to know why its always running on port:9200 and if I need too start Elastic each time I boot up a Operation System.
you download elasticsearch.zip and unzip it and run with "bin/elasticsearch"
you can download deb (for Debian or Ubuntu Linux) or rpm (for redhat or centos) version and install it as service for example in centos:
sudo wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.0.rpm
sudo rpm -ivh elasticsearch-6.0.0.rpm
sudo systemctl start elasticsearch.service
sudo systemctl enable elasticsearch.service // for running after boot
if you want to change the default port of elastic you must edit the elasticsearch.yml file. you can find this file in the manual running in config/elasticsearch.yml and in installation as service in centos in the /etc/elasticsearch/elasticsearch.yml
you can uncomment this line:
#http.port: 9200
and change port for example:
http.port: 9900

GITLAB installation Challenge on CentOS

I installed GITLAB in CentOS 7.4 in cloud environment, I enabled http, hhtps, ssh ports
When I Open the system, I am getting “Apache HTTP server” welcome page not the GIT LAB page, how to fix this?
Your environment maybe came with httpd installed, GitLab by default uses nginx.
You can stop and disable httpd, then restart GitLab
$ sudo systemctl status httpd
$ sudo systemctl stop httpd
$ sudo systemctl disable httpd
$ sudo gitlab-ctl restart

Teamviewer linux without permanently running daemon

Teamviewer Linux has the annoying property of installing a permanently running daemon. This not only consumes resources but also presents a security risk. You can disable the daemon startup, however then the teamviewer client does not work anymore.
The best way is to enable the daemon before running the teamviewer script and disable it again after the teamviewer client has closed.
The following shell script handles things automatically:
#!/bin/sh
echo starting teamviewer daemon
sudo teamviewer --daemon enable
teamviewer &
wait $!
echo teamviewer finished
sudo teamviewer --daemon disable
echo stopped and disabled teamviewer daemon
On ubuntu 18.04, here how I solve this
Stop autostart demon
$sudo systemctl disabled teamviewerd.service
create script /opt/tm.sh
#!/bin/bash
pkexec --user root systemctl start teamviewerd.service;
/opt/teamviewer/tv_bin/script/teamviewer;
pkexec --user root systemctl stop teamviewerd.service;
Set bash script executable
chmod u+x /top/tm.sh
Update de /usr/share/applications/com.teamviewer.TeamViewer.desktop
Exec=/opt/tm.sh
It work perfecly for my needs. I only need to connect to other computer never to mine, so root deamon always running is not needed.
Let's see how it live with update from ppa of Teamviewer
The solution Fedora 30+ is:
# systemctl disable teamviewerd.service
# systemctl stop teamviewerd.service
But don't forget to start the service again in order to get a TeamViewer ID.
# systemctl start teamviewerd.service
The tar package allows to run the TV client without installation and without root privileges.

How do I install chkconfig on Ubuntu?

I am running Ubuntu 13.10, and I'm pretty new to Linux. I tried:
$ sudo apt-get install chkconfig
Package chkconfig is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'chkconfig' has no installation candidate
I manually downloaded the package and unzipped it. The resulting folder has a file called:
chkconfig.install
But how do I run this? I tried this, but it didn't work.
$ sudo chkconfig.install
The command chkconfig is no longer available in Ubuntu.The equivalent command to chkconfig is update-rc.d.This command nearly supports all the new versions of ubuntu.
The similar commands are
update-rc.d <service> defaults
update-rc.d <service> start 20 3 4 5
update-rc.d -f <service> remove
In Ubuntu /etc/init.d has been replaced by /usr/lib/systemd. Scripts can still be started and stoped by 'service'. But the primary command is now 'systemctl'.
The chkconfig command was left behind, and now you do this with systemctl.
So instead of:
chkconfig enable apache2
You should look for the service name, and then enable it
systemctl status apache2
systemctl enable apache2.service
Systemd has become more friendly about figuring out if you have a systemd script, or an /etc/init.d script, and doing the right thing.
sysv-rc-conf is an alternate option for Ubuntu.
sudo apt-get install sysv-rc-conf
sysv-rc-conf --list xxxx
alias chkconfig=sysv-rc-conf
chkconfig --list
syntax
sysv-rc-conf command line usage:
sysv-rc-conf --list [service name]
sysv-rc-conf [--level <runlevels>] <service name> <on|off>
Chkconfig is no longer available in Ubuntu.
Chkconfig is a script. You can download it from here.
Install this package in Ubuntu:
apt install sysv-rc-conf
its a substitute for chkconfig cmd.
After install run this cmd:
sysv-rc-conf --list
It'll show all services in all the runlevels. You can also run this:
sysv-rc-conf --level (runlevel number ex:1 2 3 4 5 6 )
Now you can choose which service should be active in boot time.
The following command do the same on Ubuntu:
systemctl list-dependencies
But how do I run this? I tried typing: sudo chkconfig.install which doesn't work.
I'm not sure where you got this package or what it contains; A url of download would be helpful.
Without being able to look at the contents of chkconfig.install; I'm surprised to find a unix tool like chkconfig to be bundled in a zip archive, maybe it is still yet to be uncompressed, a tar.gz? but maybe it is a shell script?
I should suggest editing it and seeing what you are executing.
sh chkconfig.install or ./chkconfig.install ; which might work....but my suggestion would be to learn to use update-rc.d as the other answers have suggested but do not speak directly to the question...which is pretty hard to answer without being able to look at the data yourself.
As mentioned by #jerry you can add services with the below command.
update-rc.d <service> defaults
update-rc.d <service> start 20 3 4 5
update-rc.d -f <service> remove
To validate them check the above commands you can check /etc/rc*.d/ directory where service start with "k" means it will not execute during the boot and service start with "S" will start during the boot.
# for runlevel symlinks:
ls /etc/rc*.d/
In the below screenshot you can see apache2 starting in runlevel2(S02apache2) and stopping in runlevel1(K01apache2)
You can also check the service status with the below command where "+" means service is in running state "-" is in stopped.
service --status-all
OR
install sysv-rc-conf utility.
apt-get install sysv-rc-conf
example
sysv-rc-conf --level 2345 apach22 on
man sysv-rc-conf

Resources