unable to run redis-server as a service on centos - service

On a centos 7 I installed redis using the regular wget, make and make install commands.
While I am able to do a command
$redis-server redis.conf
and it works nicely.
But if I try
systemctl start redis-server
or
sudo service redis-server start/restart
it says
Failed to issue method call: Unit redis-server.service failed to load: No such file or directory.
How can I fix this. I need to run redis-server as a service.

You can try:
sudo systemctl enable redis-server
sudo service redis-server start
You can check that redis or redis-server right. May be You need to restart Your System after sudo systemctl enable redis-server

It would be better to install Redis via an RPM (package) rather than just performing a wget of the sources and building them. You might find a suitable version in the "extra packages for Enterprise Linux" EPEL collection. Just add the appropriate repositories to your Yum configuration and use yum commands to update your package indexes and query them to see if you have the Redis server version you're interested in. Here's a guide on How to install redis server on CentOS 7 / RHEL 7 using EPEL
Another option would be to build your own RPM using a .spec file. Rather than trying to write your own from scratch you might try something like remicollet/remirepo's redis.spec as a starting point (for version 3.0.7) or search around for other RPMs or .spec files. However the big deal is that you need the redis.service and redis.init configuration files that are used to describe how to run a Redis server to the systemd system.

Related

Install MongoDB on Manjaro

I'm facing difficulties installing the MongoDB community server on Manjaro Linux.
There isn't official documentation on how to install it on Arch-based systems and Pacman can't find it in the AUR repos.
Has anyone ever tried to install it?
Here is what I did to install.
As the package is not available in the official Arch repositories and can't be installed using pacman, you need to follow a few steps to install it.
First, you need to get the URL for the repo of prebuilt binaries from AUR. It can be found here and by the time of writing this it was https://aur.archlinux.org/mongodb-bin.git
Simply clone the repo in your home directory or anywhere else. Do git clone https://aur.archlinux.org/mongodb-bin.git, then head to the cloned directory, cd mongodb-bin.
Now, all you need to do is to run makepkg -si command to make the package. the -s flag will handle the dependencies for you and the -i flag will install the package.
After makepkg finishes its execution, don't forget to start mongodb.service. Run systemctl start mongodb and if needed enable it with systemctl enable mongodb.
Type mongo in the terminal and if the Mongo Shell runs you are all set.
Later edit (8.2.2021): This package is now available in AUR.
It is available in AUR, so you can view it with pamac with -a flag,
eg.
pamac search -a mongodb-bin
pamac info -a mongodb-bin
And, then build and install with (this can be done after manually cloning too) -
pamac build mongodb-bin
Note that there's also a package named mongodb, but mongodb-bin is a newer release (you can check the version numbers by search or info arguments)
I've been using mongodb via docker for a couple of years.
In my experience, it's easier than installing the regular way. (assuming you already have docker installed)
1. Ensure you have docker installed
If you don't already have it, you can install via pacman/pamac, because it's in the official Arch/Manjaro package repositories. The easiest way is to run the following command:
sudo pacman -S docker
2. Run a single docker command
sudo docker run -d -p 27017:27017 -v ~/mongodb_data:/data/db mongo
This command will run mongodb on a port 27017, and place its data files into a folder ~/mongodb_data.
If you're running this command for the first time, it will also download all the required files.
Now you're successfully running a local instance of mongodb, and you can connect it with your favorite db management tool or from your code.

How does one change Postgres' service name when installing on Centos

I am installing Postgres on CentOS 7 boxes, and that part itself is fine. The issue that someone brought up is that they would like for my install script to try and not depend on the service name being postgresql-10, and instead just use postgres or postgresql. Either one would be fine. Well I noticed that there is a flag --servicename that can be used, but I am unsure where to use it in the process. I have tried a few times but it doesn't seem to work.
Note that this is how I am installing postgres
yum -y install $LINK
yum -y install postgresql10
yum -y install postgresql10-server
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10
the $LINK up there is just the path to pull from the Postgres website. Again, the ideal situation would be for me to specify the service name such that I can standardize that and limit script changes when Postgres versions change.
Note that I found out about the --servicename flag in this, link but I am not completely sure how to apply that to the installation above. It does appear that the link is more for installing on windows, but I would assume we could do the same thing in a Linux installation. Any suggestions here would be welcome.
The link that you found is about EnterpriseDB's installer for Windows, and the service mentioned is a Windows service. That won't help you on CentOS.
The name of the systemd service file is hard-wired into the RPM, but there is nothing that prevents you from creating your own service file in /etc/systemd/system and using that one instead. Then you can choose whatever name you prefer. You can just copy the service file from the RPM as a starting point.
Renaming the file or creating one in /usr/systemd/system is not a good idea, because that will mess with RPMs.
postgresql-10 is a good name for the service, however. If you choose postgres or something else that doesn't contain the version, what will you do once you want to install v11?
To answer your question: There is no way to configure the name of the service when installing it via RPM.

Running 'monit restart all' gives invalid action

error: invalid action action= restart monit
Server Info
Ubuntu 16.04.4 LTS
monit:
Installed: 1:5.16-2ubuntu0.1
This issue is for these monit commands
$ monit restart tomcat
$ monit stop tomcat
$ monit start tomcat
$ monit monitor tomcat
$ monit unmonitor tomcat
Reason:
Status changed to 'Confirmed' because the bug affects multiple users.
Changed in monit (Ubuntu):
status: New → Confirmed
for the time being, you need to revert the monit package to 1:5.16-2, try manually in a server with
sudo apt-get install monit=1:5.16-2
If your servers are automatically provisioned with some third party tool (chef, puppet, bash scripts, etc) then you would need to update them accordingly.
Source: https://bugs.launchpad.net/ubuntu/+source/monit/+bug/1786910
NOTE
In case you're facing this issue again even after downgrading Monit version, please blacklist it from unattended-upgrades service. It runs daily to fetch latest security updates for relative packages.
To blacklist monit, open "/etc/apt/apt.conf.d/50unattended-upgrades" and under "Unattended-Upgrade::Package-Blacklist" block, add "monit".
#TomDavies suggested a better solution than blacklisting, see the comments.
Do remember it to remove from blacklist once the issue is solved.
You would need to run the above command again to revert back to older patch.
This is an extension to answer given by Ninad.
If you are using Chef to automatically configure your servers, then the following code change will help you install the previous version of monit in all your servers running Ubuntu 16.04
if 'ubuntu' == node['platform'] && '16.04' == node['platform_version']
Chef::Log.info "******** Installing monit version '1:5.16-2' ********"
execute 'apt-get -y install monit=1:5.16-2 --allow-downgrades'
else
Chef::Log.info "******** Installing latest monit ********"
package 'monit'
end
Make sure to revert this once the bug is fixed.

Running Tomcat with PostgreSql using Dockerfile

I want to run a Tomcat with PostgreSql database within the same Dockerfile.
I have the following Dockerfile
FROM tomcat:8-jre7
MAINTAINER "Sonam <mymail#gmail.com>"
RUN apt-get -y update
Add simplewebapp.war /usr/local/tomcat/webapps/
RUN apt-get update && apt-get -y upgrade
FROM postgres
When I run the docker image, I can't access the Tomcat like I could if I comment out the postgres. How do I get Postgres running and Tomcat too?
thanks
You can only take one image as your base, just the same as you can only have one OS installed.
If you need to have two applications installed, then you need to build your own container - either starting from one and running the sequence of commands in the Dockerfile you need to install the other app, or just start from a base OS image, and install both.
Alternatively - why do you need them in the same container? Something like --link might do what you want, more effectively. Just run two containers, and link them.

Cannot get postgresql-9.3-postgis-2.1 on Ubuntu 14.04.1 Docker container

I tried to install postgresql-9.3-postgis-2.1 or postgresql-9.1-postgis-2.1 for a cloned app, but I can only get postgresql-9.4-postgis-2.1 on my Ubuntu docker image which is build from python:2.7 image.
I looked into the image and found it's on a Ubuntu 14.04.1 image. I tries to install postgis on my Xubuntu 14.04.2 VM, everything is OK.
How could I get the installation works OK?
Dockerfile is pretty easy:
FROM python:2.7
RUN mkdir /workspace
RUN mkdir /data
WORKDIR /workspace
RUN apt-get update
RUN apt-get install postgresql postgresql-common postgresql-9.3-postgis-2.1
Error code is very normal too:
E: Unable to locate package postgresql-9.3-postgis-2.1
E: Couldn't find any package by regex 'postgresql-9.3-postgis-2.1'
Please provide more information, like the dockerfile and the errors you get.
From your comment it appears you load the python libraries before the postgresql libraries. I assume that your python app needs postgresql access and that it uses one of the python wrappers around the postgresql C libraries.
If that is the case then install the postgresql libraries before installing the python libraries, and do not forget to add the -dev libraries.
What I do in such a case is to make a minimal docker image, start a root shell in the container and do the install manually, take notes and use them to update the docker file. Alternatively you can run
$ docker exec -t -i bash -i
to get a shell in the container and try out what needs to be done.
Thanks for everyone who tried to help me! Though I finally fix this myself, there is nothing wrong with the Dockerfile which is pretty simple, but the image I chose is not a typical Ubuntu image, the docker office use buildpack-deps:jessie instead of ubuntu:14.04 image:
https://github.com/docker-library/python/blob/master/2.7/Dockerfile
It caused different behavior in docker and Ubuntu VM.
Finally, I build a Python image from Ubuntu:12.04 and fixed this issue.