redis-sentinel: config rewrite vs. ansible - redis

I try to write an ansible role for redis/sentinel and am stuck at one point:
Since sentinel writes create config rewrites, the config always changes which triggers always changes
A way out could be to to configure sentinel to write the CONFIG REWRITE in another file and include that one in the main redis.conf
Is this possible somehow ? Or are there any other methods to not have the changes in the main redis.conf

Related

Handle multiple domains without restarting HTTP server

Let's assume I have multiple domains pointing to one server.
I know that I can have multiple virtual hosts in Apache for example, but every time I want to add a new website I have to change the configuration and restart the server.
I am looking for hosting multiple domain names without having to create a config file each time.
Why ? because after creating a config file, I have then to restart the HTTP server which means that each domain I add will block all the other domains for a period of time.
Basically I want a config or program that points dynamically each domain to a sub-folder of my main source code without having to create a config file or restarting the HTTP server.
Please let me know if this is doable with the current HTTP servers or if not point me to some resources that will help me do this programatically.
With most standard web servers you simply cannot do this without a restart or at least reload of the service (so it picks up the new configs).
Of course you could build your own solution, based on your requirements.
You can reload the server without restart it, a reload keep the active connections up, so you can load the changes in your configuration without restarting the server.
Command for nginx: nginx -s reload
I suggest to use nginx -t && nginx -s reload in order to check the configuration before reloading
Command for Apache: apachectl -k graceful, systemctl reload httpd.service, service apache2 reload, service httpd reload (it depends on your environment)

Redis loads old data, shall start clean

I want to use Redis as memory only. But when I start it, it loads the content of my test run (that used just the default config, i.e. without config file).
How can I prevent it to load that stuff? (Beside deleting these files. I want to ensure by configuration that I don't mistakenly load data.)
My current configuration:
# Redis configuration
# - memory only
# - limited to 1 GB
loglevel warning
databases 4
maxclients 50
maxmemory 1GB
maxmemory-policy noeviction
# milliseconds
lua-time-limit 100
# microseconds
slowlog-log-slower-than 10000
slowlog-max-len 1000
# subscribe __keyevent#0__:expired
notify-keyspace-events Ex
# is this needed?
appendonly no
You should:
Use a .conf file
Remove the .rdb file (once) prior to starting redis-server
Comment out your save entries; see this comment in the default .conf : Note: you can disable saving at all commenting all the "save" lines.
If you want to check the runtime config, you can let redis rewrite your .conf file.
See: CONFIG REWRITE
Diff your previous config to the rewritten one, so you can see what you're missing.
To see the actual config on a running redis-server instance, use CONFIG GETExample from redis-cli:
127.0.0.1:14130> config get *save*
You can also set some config options online, see CONFIG SET
If you want to daemonize your test server, use install_server.sh. This script has had a major overhaul in 2.8.8. I recommend you do this (if possible/permissions), since it sets up a nice structure with the .conf where it should be, according to your OS's standards. Also, you can configure the daemon to start automatically after a server reboot.
Hope this helps, TW

How to use environment variables in apache vhost

I have a environment variable called DISTANT_APP_ADDR:
$ echo $DISTANT_APP_ADDR
$ 172.17.0.102
I want to use this variable in my vhost, so I've added in the /etc/apache2/envvars file :
export DISTANT_APP_ADDR=${DISTANT_APP_ADDR}
In my vhost :
FastCgiExternalServer /var/www/cgi-bin/php5.external -host ${DISTANT_APP_ADDR}:9000
But when I restart apache, I've the error :
$ service apache2 restart
$ FastCgiExternalServer /var/www/cgi-bin/php5.external: failed to resolve "" to exactly one IP address
By replacing ${DISTANT_APP_ADDR} in the envvars file with the real value it's working.
I've also to to put a PassEnv DISTANT_APP_ADDR in my vhost file, but the result is the same.
How can I pass my env vars to my vhost file ?
export DISTANT_APP_ADDR=${DISTANT_APP_ADDR}
is nonsense. It does nothing if DISTANT_APP_ADDR is already set, and if it isn't set -- how does it know what to set?
You don't WANT the start script pulling your environment variable either. Suppose you, or someone else, does an apachectl restart one time, and you've forgotten you changed your env variable for some reason, 30 minutes ago. This is an administrator's nightmare - your web app "suddenly" stops working, but there's no change to any config file. It will be very very difficult to find out what went wrong.
So, by all means, set the DISTANT_APP_ADDR to something constant. Or use the SetEnv directive in httpd.conf or in some vhost config file. But never make a server service dependent on the environment the user happened to have when he started the service. (And when your system boots up, and apache gets started, the startup code doesn't know you're setting the variable in your .profile anyway).
If you really really want to shoot yourself in your foot, add
echo "DISTANT_APP_ADDR='$DISTANT_APP_ADDR'" > /tmp/apachefile
to the end of your .profile, and include that file into your envvars file.

Apache - virtualhosts and global apache config

I have an apache server configured with multiple NameVirtualHosts running on the same IP. This all works fine.
However, because of the "include conf.d/*" directive, apache also picks up config for cacti and phpmyadmin, which add in aliases for /cacti and /phpmyadmin, and those aliases appear to be valid for all virtualhosts. That is to say, I can go to http://firstvirtualhost/cacti and also http://secondvirtualhost/cacti, and I get the same page.
In my case, the default namevirtualhost is publicly visible, and I do not want tools like phpmyadmin or cacti to be visible under that URL
In fact, I don't want any random package to be able to make itself visible across all virtualhosts simply by creating a file for itself in conf.d.
You have to delete the line include conf.d from the global Apache configuration file, and optionally add it to your own private virtual host configuration file.

Apache 2.2 on XP: How configuration files are managed? Where should they be located?

New to Apache, and suffering...
Seems to be true:
the default configuration is in Apache directory Apache2.2/conf/httpd.conf
Unsure of that:
it can be elsewhere
to create some separation between test/production, it seems that the best option is
to store all test files, including configuration and logs, in the same directory, with subdirectories conf, log, htdocs, and all production files in another directory using a similar structure.
if my upper directory is d:mywww, then the server needs to be started with the associated configuration file, e.g. httpd -f "d:mywww/conf/httpd.conf"
What will happen to the default configuration file if the -f option is used. Will it be ignored?
If instead of the -f option, you use httpd -d "d:mywww/htdocs" to indicate the directory to serve, but not any configuration file, will the default config file be used and the one under d:mywww/conf ignored?
Can someone confirm or deny?
Is there a well known site with a good introduction on setting up Apache, if possible on Windows. I found the Apache documentation a little bit difficult, and Apache Definitive Guide not clear about this kind of questions.
I was new to Apache 2 months ago, and still suffering. Since you got no replies from pros yet, I'll chip in my 2 cents: (all for Ubuntu 10.10)
httpd.conf is used for your personal configurations, so I'd say that it is not the default configuration file as you specify. The default would be, in my case at least, in /etc/apache2/apache2.conf
you can have a bunch of other conf files. In my case, I can place any file with an extension .conf inside /etc/apache2/conf.d/ and it will be picked up by Apache on restart.
Don't know about the rest. Hope it helps you