Wednesday, December 26, 2018

Tech Notes:- log file at /var/log/ansible.log is not writeable and we cannot create it, aborting

This is one of the errors that we encounter after installing ansible and trying to run our first playbook as a non-root user. To fix this all that we need to do is to create a group called ansible , add the user who is executing the playbook to the ansible group, then touch the file /var/log/asnible.log with root as the owner and ansible as the group.Permission should be 775 which is read write and execute for  owner and group and read and execute for others.

# sudo touch /var/log/ansible.log

#sudo groupadd ansible

# sudo chown root:ansible /var/log/ansible.log

# sudo chmod 775 /var/log/ansible.log

# sudo usermod sudeep -aG ansible

You need to signout and sign in before executing the playbook.


Sunday, December 16, 2018

Tech Notes:- Mysql Replication Error 'Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file''

I kept my slave mysql db down for a week and then when I switched on the slave db server and checked the replication status, I started seeing this error.



Last_IO_Errno: 1236

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'



The most probable reason for this error is that the binary log required for the replication by slave servers no longer exists on the master database server. This could have happened because someone might have manually deleted the binary files on the MySQL master either by removing the files from the file system or using the purge binary logs command.

Another reason could be that a variable has been set in the conf file to expire the logs. In my case, it was this one and the variable was set to 2 days

expire_logs_days=2

Let's have a detailed look at SHOW SLAVE STATUS and SHOW BINARY LOGS on master

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 172.25.1.20
                  Master_User: slave
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000023
          Read_Master_Log_Pos: 94955731
               Relay_Log_File: mysqld-relay-bin.000007
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000023
             Slave_IO_Running: No
            Slave_SQL_Running: Yes


mysql> SHOW BINARY LOGS;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000029 |      1315 |
+------------------+-----------+
1 row in set (0.21 sec)

So reading it all to gether, slave is looking for the master log file mysql-bin.000023 at position 94955731. But the master is at  mysql-bin.000029  and I dont have the file mysql-bin.000023. So this basically means that the mysql slave stopped replcation while at mysql-bin.000023.

How do we solve this?

The simplest way as well as the advisable approach is to dump the mysql from the master, restore it to slave and then restart the replication. But that may take time if the database is huge and there is no way to take the dump without impacting production performance.

If its a test system and you are ok with losing some data in replication, the best bet would be to set the position of the slave to the start of the new available master file.  

STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000029', MASTER_LOG_POS=4;
START SLAVE;

You may need to skip some positions sometimes. If you have patience and time, the best option is to examine the events in the log and point to the position accordingly. You can do it using the command below

sudo mysqlbinlog /var/lib/mysql/mysql-bin.000029 | more







Sunday, November 25, 2018

Tech Notes :- Ansible Ad hoc Command Examples



Ansible ad-hoc commands are useful when you want to run something quickly on multiple machines. Here I am providing some examples of different situations that might help. Let's assume that our inventory name is 'servers'  and  we the names of all servers in this file



Checking the status of all servers in our inventory file 'servers'
# ansible  'servers' -m ping

For checking the uptime of all servers
# ansible 'servers'  -a 'uptime'

Create a user sudeep and set the password on all servers in the inventory file servers
# ansible 'servers' -m user -a "name=sudeep password=redhat"

Updating  Linux server with latest updates
# ansible 'servers' -m package -a 'name=* state=latest'

Installing a specific package in all servers in the inventory
# ansible 'servers'  -m package -a "name=httpd state=present"

Reboot the servers and wait for it to come back
# ansible 'servers' -b -B 1 -P 0 -m shell -a "sleep 5 && reboot"

Remove a text from a file
# ansible 'servers'  -m lineinfile -a "dest=/etc/somefile.txt regexp='texttoberemoved' state=absent"

Checking entries in a file
# ansible 'servers' -m command -a 'grep listen  /etc/nginx/conf.d/nginx.conf'

Replacing strings in a file on multiple servers
# ansible 'servers' -m replace -a 'path=/etc/nginx.conf.d/nginx.conf regexp="192.168.1.20" replace=192.168.1.100'

Commenting a line in a file based on finding a pattern in that line.For example comment the line containing the word backup in a cron job
ansible 'servers' -m replace -a 'path=/etc/cron.d/backup_schedule regexp="(.*backup.*)" replace="#\1"'

Check the hypervisor on remote machines
# ansible 'servers' -m setup -a "filter=ansible_virtualization_*"

List remote files
# ansible 'servers' -m command -a 'ls -l  /var/www/html'

Copy files
# ansible 'servers' -m copy -a 'src=/home/sudeep/test.php dest=/var/www/html/test.php owner=sudeep group=sudeep'

List all variables a partiucular host can see
# ansible -m debug -a 'var=hostvars[inventory_hostname]' foo.com

Schedule a reboot
# ansible 'foo.com  -a  '/sbin/shutdown -r +5'

Checking the remote git version on multiple servers
# ansible 'servers' -m command -a "git status  args: chdir=/var/www/html/sudeep"

List all tasks in a playbook
# ansible-playbook --list-tasks playbooks/app-server.yml

Get an excerpt from a file
# ansible 'servers' -a 'grep -A 2 port /etc/supervisord.conf'

Remove a port from firewall where the firewall is configured using firewalld
# ansible 'server' -m command -a "firewall-cmd --remove-port='8080/tcp' --zone=internal --permanent "

Reload firewalld
#ansible 'server' -m command -a  'systemctl reload firewalld'

List all opened ports in public zone
#ansible 'server' -m command -a 'firewall-cmd --list-ports  --zone=public'

List all services in public zone
#ansible 'server' -m command -a 'firewall-cmd --list-services  --zone=public'

List all sources in public zone
#ansible 'server' -m command -a 'firewall-cmd --list-sources  --zone=public'

Adding a server to proxysql with a default_hostgroup of 80, writing the changes to disk and loading it to runtime.
ansible 'myserver.example.com' -m proxysql_backend_servers -a 'hostgroup_id=80 hostname=172.16.1.55 load_to_runtime=True login_host=proxysql.example.com login_password=Password123 login_port=6032 login_user=proxysql-admin save_to_disk=True state=present status=ONLINE comment="My new mysql database server"'


We can send the output of the ansible command(or any command) both to a file as well as stdout.See the example below
ansible 'servers' -m command -a "git status  args: chdir=/var/www/html/sudeep" 2>&1 | tee ~/outfile

Sunday, October 14, 2018

Tech Notes :- Vagrant up error (193) with virtualbox on windows

I always use vagrant to bring up the required Virtual Machines with virtual box.Unfortunately, this time vagrant up was throwing below error.

There was an error running VBoxManage. This is usually a permission
problem or installation problem with VirtualBox itself, and not Vagrant.
Please note the error message below (if any), resolve the issue, and
try Vagrant again.

 (193)

Tried different options to solve this, but nothing worked. As a last option, I searched for any corrupt  VBoxManage.exe and there you go, there was another 0-byte copy in c:\windows\system32. I just deleted that file and then vagrant up worked as usual.


Sunday, May 20, 2018

Note About Schooling In Melbourne For Those Who Are Planning To Move

 

   One of the important factors that every parent needs to consider before making a decision on moving to Melbourne or for that matter anywhere in Australia is children's education. I wish this write up helps you in this regard.

First of all, there are certain important documents that we need to get  before travelling to Australia

1. Birth Certificate-.Make sure that your child has a birth certificate. If not apply immediately and get it before moving to Australia.

2. Immunisation records-if you don't have it in a legible format, please get in touch with the hospital/Doctor and get a report with the signature/seal of the Doctor/Hospital. Make sure that your child's immunization records are up to date. There are certain vaccines like Meningococcal which is a mandatory vaccine in Australia but is not routinely administered to children in India,  Don't bother about those, you can get those vaccines administered from Australia for free.

    Once you are in Australia, call the local city council for your area and check with them regarding the immunization schedule. They will definitely have one near you. Take your kid to the venue on the scheduled date. Make sure that you carry the immunization records from your country. Submit it to them and request them to update the Australian Immunization Register(AIR). They may review the immunization records and advise you about any mandatory vaccines here in Australia which is missing in your child's records. They will administer it for free. You may also consult your local GP for immunization and updations. Updation to AIR may take a few days and you may be able to check your child's Immunisation History Statement in below website or using  Medicare online account through myGov.



    Now that you have the records ready, the second important thing that you can do before you travel is to research on good schools for your kids. I am not elaborating on the types of schools, their advantage/disadvantage etc. since those details are available widely on the internet. 

    Basically, you have two choices, either your kid can go to a private school or a Govt school. If you are planning for a private school, you may have to pay school fees. There is no fee involved in Government schools. However, an important thing to consider is that the Government schools are zoned, which means you may have to live within a certain area around the school in order to attend a particular Government school. Here are the resources which might help to decide on the schools and their zone.


   Although there is no fee for Government schools, you may need to budget for stationery, uniform as well as fees for camping and sports. Stationary will be covered under $200, uniform under $300 and camping - generally two times a year will cost you under $400 each time. Apart from that, you may need to spend on sports and games, mainly travel charges in case your kids' school team is going to other schools to play against them This will be around $6 each time.

   In Australia, the academic year starts by end of January. Although it is a good idea to reach here by mid-January and settle down by then, as per rules here, kids need to be admitted to Government schools anytime during the year.

   The Government school may ask for proof of address to make sure that you are living in the zone designated for the school. For me, the school did not ask for proof.

   Victoria school schedules are available in below website. Generally, there are 4 terms with breaks in between.


  Before and after school care is another concern especially if both parents are working. Most of the Government schools have some arrangements for it. For example in my kid's school, the before and after school care is managed by Camp Australia. They start at 7AM in the morning and will take care of your kids until school time and after the school to 6:30 PM.


  You may have other options based on the area. For example, here I have a family day care which starts as early as 6:30AM and they are there until 8PM to take care of kids. They take the school going kids to school on time and collect the kids from school once the school time is over.

  The expense for before and after school care or child care, in general, depends on your income and certain criteria laid out by Centrelink. But if you are unemployed at least for the initial period, your out of pocket expense for childcare might be very less.

Here schooling is stress-free and your kid will definitely enjoy schooling here !!! All the Best!!!




Tech Notes :- Making Google Drive Available As A Windows Drive


It is always a  convenience to have your Google Drive available as a drive in your Windows Explorer. Here are the steps to configure your Google Drive in windows and then having it as a drive in your windows explorer

Download Google drive software(Backup and Sync) for Windows from below link

https://www.google.com/drive/download/

Install it and configure the folder to be Synced say E:\Google Drive

Once you select the folder to be synced, the contents of the folder will be synced with google drive

Now download a software called Visual Subt from below link or any trusted link

https://download.cnet.com/Visual-Subst/3055-2248_4-10598834.html?tag=pdl-redir


Launch Visual Subst and then map the folder that you have selected for syncing(say E:\Google Drive) with Google Drive.

Now you should be able to see an additional drive in My Computer which is the local folder synced with Google Drive. It's that simple!

Thursday, January 25, 2018

Converting an expired US License To Victorian License

     I was holding an expired license from Florida when I arrived in Melbourne-Victoria last year.I was thinking of going through all the tests to get a Victorian license when I found in one of the internet forums that we can get a US license converted even if it is expired. The only thing is it should not be expired for more than 5 years. Mine had few more days left to reach the 5-year mark.

      I immediately went to one of the VicRoads customer service centers. You will have an officer waiting at the entrance to help you with tokens for each service. Please let the officer know that you are for license conversion. He/she will give you a token number. Please reach out to the counter based on your token number. They will give you an application for license conversion and an appointment. My appointment was 10 days after. You need to pay a fee of AUD 18.20.

       On the appointment date, please make sure that you are there at VicRoads customer care center 10 minutes before your appointment.Also please have your US license, completed application for license conversion, and identity documents as listed. I had my bank statement which clearly showed the Victorian address and my passport.Just let the customer care officer at the entrance know that you are there for license conversion appointment. This time you don't need a token.They will ask you to take seat in front of the officers. One of the officer will call your name and purpose.You can head to the officer. They will inspect your US license, verify it online and then request you to pay the victorian license fee.You can find the fee details here. I paid the fee for a 10-year license to avoid the renewals frequently.Afterwards, I had a quick eye test, they just asked me to read a couple of lines from a board and then they took my photo and gave me a temporary document to drive until I receive my full license at my home address.It took maybe around 20 minutes to complete the process. Later my full card license reached my home in a week. That's it !. You are fully licensed to drive on Victorian roads.

        But I would better suggest you go through VicRoads youtube videos and VicRoads drivers manual which is called Road to Solo Driving Handbook before you drive in Victoria. You can download a pdf copy of this book here Here is a link that you can follow to get details on overseas license conversion process https://billing.vicroads.vic.gov.au/bookings/overseas
Related Posts Plugin for WordPress, Blogger...