Make config parameters persistent after HANA restart - hana

Each time our HANA DB goes down and comes back up, there are some two parameters that we normally run manually after it is started. I want to write a shell script to automate the execution of these queries when the database restarts.
Any ideas? Here are the two parameters.
ALTER SYSTEM ALTER CONFIGURATION ('global.ini','SYSTEM')
SET('persistence','use_helper_threads_for_flush')='true' WITH RECONFIGURE;
ALTER SYSTEM ALTER CONFIGURATION ('global.ini','SYSTEM')
SET ('persistence','use_helper_threads_for_flush')='false' WITH RECONFIGURE;

This is a bug described in SAP Note 2655468 covering three persistence parameters, and particularly use_helper_threads_for_flush, they have no effect after HANA restart. This is not a normal behavior, since parameters applied with a ALTER SYSTEM ALTER CONFIGURATION WITH RECONFIGURE are active immediately and shouldn't be re-applied.
The workaround here is to re-set the parameter each time HANA restarts or upgrade your HANA release >= 032.00 (SPS03) or higher.
Possible way of automating this is through hdbsql. For example, create new Upstart job (/etc/init) on your HANA server and put these commands in it:
cd /hana/shared/<SID>/hdbclient
su - hdbadm
hdbsql -n localhost -i 00 -u AUSERADMIN -p APassword01
hdbsql -u AUSERADMIN -p APassword01 "ALTER SYSTEM ALTER CONFIGURATION ('global.ini','SYSTEM') SET('persistence','use_helper_threads_for_flush')='true' WITH RECONFIGURE"
hdbsql -u AUSERADMIN -p APassword01 "ALTER SYSTEM ALTER CONFIGURATION ('global.ini','SYSTEM') SET('persistence','use_helper_threads_for_flush')='false' WITH RECONFIGURE"
However, I do not recommend doing this and better stick to upgrade.
Note, that this parameter is internal and shouldn't be used outside of scope of note 2655238

Related

SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security conf

We have enabled 'XPCmdShellEnabled' on the database serve and we used command shell script in one of the SP which executes on daily job.
(Our Command shell script basically create the directory, create the file and dump the tem table data to csv file).
Issue: From past few days the daily job filing with the below error, before that it was working fine and nobody changed any configurations on server.
SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell' search for 'xp_cmdshell' in SQL Server Books Online.
(We have enabled 'XPCmdShellEnabled' = true on 'Surface Area Configuration'.
I have tried again by executing below query, and tried SP.
sp_configure 'show advanced options', '1'
RECONFIGURE
sp_configure 'xp_cmdshell', '1'
RECONFIGURE
But no luck..
Please let me know if anybody aware/faced of this similar type of issue and found solution.
Thanks.

initialize google cloud sql from Docker file

I have a MySQL instance hosted in Google Cloud SQL, and I have a container which uses this database, I tried to initialize the database schema from the docker file using the following command:
FROM anapsix/alpine-java
ADD ./mysql/init.sql /docker-entrypoint-initdb.d
init.sql
SET sql_mode = '';
CREATE DATABASE IF NOT EXISTS `locations_schema`;
USE `locations_schema`;
CREATE TABLE `locations` (
`id` int(11) NOT NULL,
`value` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
But unfortunately this is not working, is there any way I can achieve the init of a DB?
I think that you are getting confused implementing your solution.
If you have a unique Google Cloud MySQL instance used by your containers why are you trying to initialize the database schema each time a container is created from the new custom image? Isn't better to initialize it just connecting to it once manually?
However docker-entrypoint-initdb.d is used to initialize local MySQL instances, not an instance running in a different machine. Notice that you will need at least to specify the address of the instance, a user and a password to let the container to connect to it. In order to do so there are different ways and you can find several guide, but I don't think that this is what you need to implement.
However If you are trying to init a MySQL instance running in the Docker container here you can find an awesome explanation how to do it, but I think you have to change the image you are starting from since I don't think that it contains MySQL.
You can use a script to do the initialize the DB without needing to pass the root password, provided MySQL is persisting data outside of the container and you specify a volume on the docker run command. You will need to specify environment variables specific to your environment. The script file needs to be added to the container via a Dockerfile. The Basic MySQL command line:
Set -e
Set -x
Then start the MySQL daemon
Mysql_pid=$!
You can add an echo for “..” to show until the MySQL admin has started, if you want.
mysql -e "GRANT ALL ON *.* TO root#'%' IDENTIFIED BY '' WITH GRANT OPTION"
Then shutdown your MySQL daemon
wait $mysql_pid -- wait for it to stop
The Docker documentation, https://docs.docker.com/samples/library/mysql/ offers more DB start options, including starting from an application in a docker container. You can also combine MySQL and docker commands for other database functions, like create schema, or creating multiple databases.

How to run command on Zabbix agents?

I want to run a command on Zabbix agents:
Some simple unix commands, to obtain our reporting data.
When there is some processing required on the agent side.
There seem to be a variety approaches being talked about. So how to execute such commands on a Zabbix agent?
Run commands from the server directly from a new item.
First, set: EnableRemoteCommands=1 in the agent conf file (for all of your agents). To enable this feature.
Create a new item. A field on the "new item" page says 'key'. Enter:
system.run[command]
As the 'key' string. Where command is the command you want to be downloaded and run on the agent. Here is an example:
system.run[sysctl dev.cpu.0.temperature | cut -d ' ' -f 2 | tr -d C]
Perhaps you need to run something substantially more complex that is too long to fit in there? Then you will need to make a custom script. Put your custom scripts on a local webserver, or somewhere on the web.
Then you might set the item's key to:
system.run[ command -v script && script || wget script_url -O /path/to/script && script]
To fetch and download the missing script to the agent the first time it's executed. However that is a rather crude hack. Not very elegant.
A better way is to go to "Administration" --> "Scripts" in the menu. From there, you can create a new script to use in an item which may be configured to run on any of your agents.
Make a special custom item to re-run your script periodically (like a cron job). The job of the special script item is to update the agent with a collection of your other needed custom scripts.
Of course you could just write all of your custom scripts directly into zabbix's MYSQL database. And it is very tempting to do that. But be aware that then they'd be lost and vulnerable if your zabbix database ever gets fried or corrupted / lost. Zabbix databases always have a habit of growing large, unwieldy and out-of-control. So don't do that. Storing them separately somewhere else and under version control (git or subversion).
Once that's all sorted, we can finally go ahead and create further custom items to run your custom scripts. Again using:
system.run[script]
as the item's key just as before. Where 'script' is the command (plus any arguments), to execute your custom script locally on the agent.
Define the user parameter at the client (where zabbix agent is
located) at /etc/zabbix/zabbix_agentd.conf
The key should be
unique. I am using lsof as an example: UserParameter=open_file,lsof | wc -l
Restart the agent: service zabbix-agent restart
Test if the key is working using zabbix_get utility. To do that from the zabbix server, invoke the following: /usr/local/bin/zabbix_get -s <HOST/IP of the zabbix agent> -k open_file (It should return a number in this case)
Create an item with the key at the zabbix server at the template
level (the return type should be correctly defined, otherwise zabbix
will not accept it):
Type: Zabbix Agent (Active)
Key: open_file
Type of Information: Numeric (unsigned)
Data Type: decimal
You may create a graph using the item to monitor the value at
regular interval.
Here is the official documentation.

specify server in sql script

I am writing a sql script for sql server 2008 where I place a use statement at the beginning that specifies the database the script should be run against:
use [my_database]
As I have different environments where the same database exists, eg dev, qa, prod, is there any way I can specify in the script the environment the script is for, either by server name or ip address or by any other mechanism.
You can put the SQL Management Studio in SQLCMD mode and specify the server with the :CONNECT myserver statement.
You can switch on command mode by clicking on the option in the pic below
Your script would then look something like this
:CONNECT devserver
use [my_database]
SELECT * FROM my_table
You can even make the query window switch servers during execution
:CONNECT devserver
use [my_database]
SELECT * FROM my_table
GO
:CONNECT uatserver
use [my_database]
SELECT * FROM my_table
To connect with a specific user and password you can specify this as follows
:CONNECT devserver -U myUser -P myPassword
use [my_database]
SELECT * FROM my_table
There are actually a number of options you can specify which are well documented on msdn.
That's a CONNECTION setting, not a parameter within the script.
You can run the same script in different environments via batch file or powershell script if desired, or you could set up linked servers, but you can't just say
USE SomeOtherServer
There are security and networking implications as well.
Assuming you will run all of these scripts on a particular server - e.g. the Dev server - then you merely need to create a Linked Server to each of the other servers.
Then, for example, you could run an identically named stored procedure on each of these servers thusly:
EXEC MyDatabase.dbo.mysp_DoSomething --Dev Server; no server prefix needed since that's where we are
EXEC QA.MyDatabase.dbo.mysp_DoSomething --QA Server
EXEC Prod.MyDatabase.dbo.mysp_DoSomething --Prod server
etc.

Extract mysql Database from CommandLine

I am using wamp server but something happend to it and now there is no way to make it come back to life. I only have access to mysql command line, and i have some important databases there.
How can i export the database using commandline?
please help.
mysqldump -h localhost --routines -u root -p dbname
If the mysql server is not behaving normally, you might have some corrupted tables. It happens usually after an unscheduled restart. mysqldump won't be able to export corrupted tables.
If the mysql server is running, try connecting to it using phpmyadmin and use the built in tools to fix and check the tables
if the mysql server fails to start, check the log files and use the mysql command line tools to fix the issues
myisamchk --silent --force --fast --update-state /var/lib/mysql/dbname/*.MYI
(http://www.thegeekstuff.com/2008/09/how-to-repair-corrupted-mysql-tables-using-myisamchk/)
First try to connect to Mysql server using the command line
mysql -uUsername -p and press enter.This will prompt for password.Enter the mysql server password.
Then use the mysqlcheck command to repair the server in case corruption has occured
COmmand for mysql-check : mysqlcheck --repair --use-frm --all-databases
I think you can just copy the folders of the database to create a backup of MySQL databases.
Used to work.