Redis "Fatal error, can't open config file 'restart'" after a crash - redis

So after restarting my httpd redis crashed (due to the number of sudden requests sent via httpd and written on redis) and now when I try to restart redis on my centos 6.5 server I get the following error:
[root#host /]# /usr/sbin/redis-server restart
[1705] 17 Apr 00:30:49 # Fatal error, can't open config file 'restart'
I have also tried to login to redis using redis-cli and I get an error stating the connection to the server failed.
What options do I have to safely restart the server?

From the /src directory where you downloaded and unzipped your redis source, run the following. This is for RHEL based systems.
make install
# (OR)
sudo cp src/redis-server /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/

Related

Why won't my systemd REDIS service start in RHEL 7.9?

So I'm not sure how to even figure out what's happening. Running redis-server version 6.2.5 on RHEL 7.9. I can start REDIS with the user I want to run it as from the command line. But when I try to start it as a systemd service with the REDIS.service file:
[Unit]
Description=REDIS Service
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
User=myuser
Group=myuser
WorkingDirectory=/app/redis
ExecStart=/bin/redis-server /app/redis/primary.conf
Restart=on-failure
[Install]
WantedBy=multi-user.target
It fails. The journalctl entry shows:
Aug 27 08:57:18 computerName redis-server[119338]: 119338:C 27 Aug 2021
08:57:18.981 # Fatal error, can't open config file
'/app/redis/primary.conf': Permission denied
The redis directory and all of it's files are owned by the user I'm telling to run the service. I even went to the extent of putting 777 on the directory and files. Thanks for any help you can give me!
Eric
This server was a mess. There was previous install of redis on the server, the rpm database was corrupt, there were old services that weren't running but were still there. I had to do a lot of cleanup and perform a clean install and it started working.

Redis installed on FreeBSD via pkg or ports can not run

I had installed redis on FreeBSD via pkg yesterday.And also add redis_enable="YES"in my /etc/rc.conf.
When I run service redis start,It displays Starting redis,but when run service redis status,displays redis is not running.
After run redis-server,It runs,but use redis-cli cannot connect the server.
When run redis-cli or redis-cli ping,it will jammed with no error.
The redis log file also has no error.
I cannot find the solution with google or others。How should I do to use redis?
The same with installed redis via ports
The followings are the base information about my company:
FreeBSD version: 10.3-RELEASE-p18
Pkg version: 1.10.1
Redis version: 3.29
I would suggest to update, reinstall by doing this:
# pkg update
then:
# pkg upgrade -y
To reinstall redis:
# pkg remove -y redis
To install it again:
# pkg install -y redis
At this point you should see this in the terminal:
===> CONFIGURATION NOTE:
To setup "redis" you need to edit the configuration file:
/usr/local/etc/redis.conf
To run redis from startup, add redis_enable="YES"
in your /etc/rc.conf.
To ensure redis is enabled on startup use sysrc
# sysrc redis_enable="YES"
Not this time try to starting calling the script directly:
# /usr/local/etc/rc.d/redis start
You could use sockstat to check if is up and listenin:
# sockstat -4l
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
redis redis-serv 9553 4 tcp4 127.0.0.1:6379 *:*
After this, redis-cli, or telnet 0 6379 should be working:
# telnet 0 6379
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
If that still not working, maybe ktrace can help to find more details:
To trace a PID:
$ ktrace -p 9553
To stop tracing:
# ktrace -C
use kdump to display kernel trace data
# kdump -f my-ktrace.out | less
The first thing to do on BSD when a command "hungs" is to press ^T (ie ctrl-t). Can you do that and paste the output?

Error with rabbit-mq server

I am trying to setup OpenStack on Ubuntu 12.04 using devstack. Now, the error I am getting is:
Setting up rabbitmq-server (2.7.1-0ubuntu4) ...
Starting rabbitmq-server: FAILED - check /var/log/rabbitmq/startup_{log, _err}
rabbitmq-server.
invoke-rc.d: initscript rabbitmq-server, action "start" failed.
dpkg: error processing rabbitmq-server (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
rabbitmq-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
++ err_trap
++ local r=100
++ set +o xtrace
stack.sh failed
Any idea why am I getting this error?
I had this issue twice, when either hostname or ip address in the hosts file didn't match.
Therefore, check that you provide the correct ip address and hostname in the /etc/hosts file
Run sudo cat /etc/hostname to see your hostname
Output:
yoursite
Run sudo nano /etc/hosts
File contains:
127.0.0.1 yoursite
As you see from cat /etc/hostname, hostname is the same as in the /etc/hosts:
Run sudo rabbitmq-server start to start the rabbitmq-server
Try deleting the folder /var/lib/rabbitmq and re-running ./stack.sh
If that doesn't work either, run the following after stach.sh fails:
chown -R rabbitmq:rabbitmq /var/lib/rabbitmq
chown -R rabbitmq:rabbitmq /var/log/rabbitmq
service rabbitmq-server restart
and check the status of rabbitmq using "rabbitmqctl status"
Similar thing happen to me. Rabbit depends on being able to resolve a hostname, run this:
echo "127.0.0.1 $(hostname -s)" | sudo tee -a /etc/hosts
This way works for me.
First go to
sudo vim /etc/hosts
and set
127.0.0.1 <hostname>
then open firewall
sudo rabbitmq-plugins enable rabbitmq_management
sudo service rabbitmq-server restart
For a clean environment, this will not happen. You must run devstack for several times, and one of them failed but you didn't get it cleaned.
run command pf -ef | grep rabbitmq, kill all rabbitmq processes. then it would be fine to run ./stack.sh
it is highly recommended to run ./unstack.sh && ./clean.sh before ./stack.sh
Just to be sure, take a look to your local network
ip add
If there's no lo network, then you should enable it:
ifconfig lo up
Then restart the server again and let's see if it works again now
systemctl start rabbitmq-server
I had the same problem though my /etc/hosts and DNS were OK. I suspect that SystemV init script was started too early when the network was not ready yet. I rewrote the startup script to systemd on CentOS 7.8 and it seems to work well now.
[Unit]
Description=RabbitMQ
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
RuntimeDirectory=rabbitmq
PrivateTmp=true
Restart=on-failure
RestartSec=10
WorkingDirectory=/opt/data/rabbitmq/
User=rabbitmq
Group=rabbitmq
ExecStart=/opt/app/rabbitmq/default/sbin/rabbitmq-server
ExecStop=/opt/app/rabbitmq/default/sbin/rabbitmqctl stop
ExecStop=/bin/sh -c "while ps -p $MAINPID >/dev/null 2>&1; do sleep 1; done"
StandardOutput=journal
StandardError=inherit
[Install]
WantedBy=multi-user.target

Activemq will not start on my Ubuntu VM

I'm trying to run activemq on my ubuntu virtual machine but have constantly been running into issues getting it to start up. I've tried downloading the binary and source with no luck. Currently I have downloaded the source, run "mvn clean install -Dmaven.test.skip=true" and mvn reported successful installation. I then hunted around in my .m2 folder found apache-activemq-5.5.1-bin.tar.gz and extracted it to my home/USERNAME dir and attempted to run "bash bin/activemq start" only to receive the following error.
INFO: Loading '/etc/default/activemq'
INFO: Using java '/usr/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties
and log4j.properties
to get details
bin/activemq: line 370: /usr/bin/java -Xms256M -Xmx256M -Dorg.apache.activemq.UseDedicatedTaskRunner=true
-Djava.util.logging.config.file=logging.properties
-Dcom.sun.management.jmxremote
-Dactivemq.classpath="/home/jacob/activeMq1/apache-activemq-5.5.1/conf;"
-Dactivemq.home="/home/jacob/activeMq1/apache-activemq-5.5.1"
-Dactivemq.base="/home/jacob/activeMq1/apache-activemq-5.5.1"
-jar "/home/jacob/activeMq1/apache-activemq-5.5.1/bin/run.jar" start >/dev/null 2>&1 &
RET="$?"; APID="$!";
echo $APID > /home/jacob/activeMq1/apache-activemq-5.5.1/data/activemq.pid;
echo "INFO: pidfile created : '/home/jacob/activeMq1/apache-activemq-5.5.1/data/activemq.pid' (pid '$APID')";
exit $RET: No such file or directory
Has any one run into this type of error before?
Looks like I'm answering one of my questions again, but maybe this will help someone in the future.
steps.
I ended up getting activemq to work by creating a configuration file via running the command "./bin/activemq setup newConfig" (exclude the quotes)
I then replaced the current config file "activemq" which was located at etc/default/. (I made a backup of the original activemq file before overwriting it with newConfig).
Run "./bin/activemq start" which will create a PID file.
After the file is created re-run "./bin/activemq start" to finally start up the broker.
You can then test the install by navigating to "http://localhost:8161/admin/" or by doing a "netstat -an | grep 61616" if you kept the default ports etc.
I install activemq 5.13 on Debian, download and unzip in /opt, then I go to /opt/apache-activemq-5.13.1/run "./bin/activemq start", then appear this error:
xx#debian:/opt/apache-activemq-5.13.1$ ./bin/activemq start
INFO: Loading '/etc/default/activemq'
INFO: Using java '/usr/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
./bin/activemq: 330: ./bin/activemq: "/usr/bin/java" -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/apache-activemq-5.13.1//conf/login.config -Djava.awt.headless=true -Djava.io.tmpdir="/opt/apache-activemq-5.13.1//tmp" -Dactivemq.classpath="/opt/apache-activemq-5.13.1//conf:/opt/apache-activemq-5.13.1//../lib/:" -Dactivemq.home="/opt/apache-activemq-5.13.1/" -Dactivemq.base="/opt/apache-activemq-5.13.1/" -Dactivemq.conf="/opt/apache-activemq-5.13.1//conf" -Dactivemq.data="/opt/apache-activemq-5.13.1//data" -jar "/opt/apache-activemq-5.13.1//bin/activemq.jar" start >/dev/null 2>&1 &
RET="$?"; APID="$!";
echo $APID > /opt/apache-activemq-5.13.1//data/activemq.pid;
echo "INFO: pidfile created : '/opt/apache-activemq-5.13.1//data/activemq.pid' (pid '$APID')";exit $RET: not found
What I did is to check the Debian version using "uname -a":
Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux
I found my debian is 64 bit system. so I run
./bin/linux-x86-64/activemq start
It shows:
Starting ActiveMQ Broker...
Then I can access the site:http://localhost:8161/admin/ with username "admin" and password "admin"
with Ubuntu 14.04, I had to create a link in /etc/activemq/instances-enabled
sudo ln -s ../instances-available/main/
similar to apache2 setup
then started the server with /etc/init.d/activemq start
sudo is necessary.
bin$ sudo ./activemq start
bin$ sudo ./activemq status
INFO: Loading '/opt/runtime/apache-activemq-5.11.1/bin/env' INFO: Using java '/usr/bin/java' ActiveMQ is running (pid '29887')

How to auto start web services when starting an Amazon EC2 instance?

How do I set the httpd and mysqld services to start automatically upon booting an amazon-ec2 instance?
Currently I have to start them manually by connecting to the instance via ssh and running sudo service httpd start and sudo service mysqld start.
Rather than starting over with a new AMI, you could just issue the following commands on an Amazon Linux EC2 instance...
sudo chkconfig mysqld on
sudo chkconfig httpd on
You can check the settings before & after enabling these services to start on boot using the following commands...
sudo chkconfig --list mysqld
sudo chkconfig --list httpd
See all services using just...
sudo chkconfig --list
NOTE: If you are having any trouble with chkconfig being in root's path, you can try specifying the full path like this...
sudo /sbin/chkconfig mysqld on
sudo /sbin/chkconfig httpd on
It is different between Amazon Linux 1 and Amazon Linux 2.
Amazon Linux 1
In AmazonLinux1, use chkconfig command.
$ sudo chkconfig mysqld on
$ sudo chkconfig httpd on
Amazon Linux2
In AmazonLinux2, systemd was introduced. So, chkconfig is legacy command. You should use systemctl. It is a control command for systemd.
$ sudo systemctl enable mysqld
$ sudo systemctl enable httpd
You can confirm it is enabled or not using by is-enabled command.
$ sudo systemctl is-enabled mysqld
enabled
chkconfig command request will be forwarded to systemctl.
$ chkconfig mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.
If you using Amazon Linux 2 AMI you need to follow these steps:
In AMI2 they are using systemctl for managing services check if it is installed on your machine
2.systemctl list-units --type=service by this command check if tomcat.service is listed
sudo systemctl enable tomcat.service To eanable tomcat start on boot up
systemctl is-enabled tomcat.service To check if tomcat enabled to start on boot up linux system
After that you can reboot your linux system and tomcat will be started.
For more about systemctl Click Here
One of my client wants to do this task and I have successfully done by using following way.
Following commands starts the services automatic when instance started.
Auto start apache/httpd
1) systemctl enable httpd
Auto start redis service
2) systemctl enable redis
I have set SELINUX set to disabled in
3) /etc/sysconfig/selinux
For mysql services
sudo chkconfig mysqld on
sudo chkconfig httpd on
I faced the similar problem, here is the solution i am suggesting,
you need to create a file under /etc/init.d directory, e.g with name tomcat, and change the JAVA_HOME and CATALINA_HOME parameters as per your system installation.
Once you do setup this file then run the below command:
sudo chkconfig <file-name> on
where is the file you have created in /etc/init.d it is tomcat in my case.
[ec2-user#ip-<myip> init.d]$ cat tomcat
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/opt/apache-tomcat-7.0.96
export $JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/opt/apache-tomcat-7.0.96
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
chmod 755 tomcat
chkconfig --add tomcat
chkconfig --level 234 tomcat on
chkconfig --list tomcat
service tomcat start
ReactJS on Amazon Linux2 process:
Installing ReactJS on EC2 and running the app at boot:
Once you connect to EC2 instance install NodeJS. Follow this tutorial:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
Install httpd server using this tutorial: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html
I used Git Clone to clone the ReactJS app on to /home/ec2-user.
Install Yarn using the command “npm install yarn -g”
Execute the following commands in the cloned project: “Yarn” and then “Yarn build”
Now Copy the build folder using : cp -a /build/. /var/www/html/
Now go to the /var/www/html/ here create a .htaccess file using vi and include the following content: “Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]”
Save the file with :wq
Now in /etc/httpd/conf/httpd.conf search for Directory with “/var/www/html” attribute and change “AllowOverride None” to “AllowOverride All”. Now open the browser and enter http://ec2-ip or http://ec2-url you will see the default page
Enter the command “systemctl enable httpd” and then “systemctl start httpd” on AmazonLinux2. Now you can access the app on boot rather than running the app again and again.
You are complete.
The best way on Amazon Linux 2 is to use the following bash script on creation. This will install the updates, start Apache2, make it listed as a service so that it automatically restarts upon reboot, and the creation of an index.html and health.html sample files. Configuring a health page is important for application loadbalancers and for autoscaling groups.
#!/bin/bash
yum update -y
yum install httpd -y httpd-tools mod_ssl
service httpd start
chkconfig httpd on
systemctl start httpd
systemctl enable httpd
echo "Hello, World, from your Webserver on Amazon Linux" > /var/www/html/index.html
echo "Healthy" > /var/www/html/health.html
Cheers!
Either use any of the preexisting LAMP AMI, it will have both of them running as service already.
One example is BitNami, you will find several other when you fire an ec2 instance.