Category Archives: Uncategorized

Extending Zpool to Increase Size of Partition in Solaris 10

Hi, the needs for the storage has been rapidly growing from time to time especially when you are in the enterprise environment. From my experience, there are always be a request for increasing the size of a partition but i have not recall gotten the request for reducing the size.  Let say i want to increase the size of my non-global zone partition.What most important thing that we have to remember is whether the non-global zone was attached to its dedicated pool or sharing with the pool with its global pool. Is it any available space that i can extend the space without adding new lun? or there is no any available space that i can extend the space unless adding new lun to the pool.I want to share here how to increase the size of partition of zones by adding new disk to the existing pool.

  1. Is it any available space that i can extend the space without adding new lun?

Growing a ZFS pool

http://blog.ociru.net/2013/09/25/let-your-zfs-extend

http://www.c0t0d0s0.org/archives/6224-You-dont-need-zfs-resize-…-and-a-workaround-when-you-need-one-;.html

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

/etc/init.d/mysql stop

mysqld_safe --skip-grant-tables &

mysql -u root

use mysql;
update user set password=PASSWORD("NEW_PASSWORD") where User='root';
flush privileges;
quit;

/etc/init.d/mysql stop
/etc/init.d/mysql start

mysql -u root -p
 
Reference:-
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) (2014). Available at: http://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y

 

New Oracle ASM Disks Mapping in RHEL

cd /root/asm/

###start of infomation collection script named collect_info.sh
#!/bin/ksh

currentdatetime=$(date +”%T”.”%Y%m%d”)

echo “”
echo “############################################”
echo “# #”
echo “# LINUX – ASM Disk – Backup Informations #”
echo “# #”
echo “############################################”
echo “”

echo ” ##### Collecting informations ##### ”
ls -l /dev/disk/by-id/ > diskbyidbef.$currentdatetime
ls -l /dev/disk/by-id/ | grep -i scsi- > diskbywwnidbef.$currentdatetime
multipath -ll > mpathidbef.$currentdatetime

echo ” ##### Backup configurations file ##### ”
cp -p /etc/udev/rules.d/99-oracle-asmdevices.rules /etc/udev/rules.d/99-oracle-asmdevices.rules.$currentdatetime
echo “Backup 99-oracle-asmdevices.rules to /etc/udev/rules.d/99-oracle-asmdevices.rules.$currentdatetime …”
cp -p /etc/multipath.conf /etc/multipath.conf.$currentdatetime
echo “Backup multipath.conf to /etc/multipath.conf.$currentdatetime …”
echo ” ##### Verify file existence ##### ”
ls -l /etc/udev/rules.d/99-oracle-asmdevices.rules.$currentdatetime
ls -l /etc/multipath.conf /etc/multipath.conf.$currentdatetime
########end of script for collect_info.sh

########start of device scanning script named device_scan.sh
#!/bin/ksh

currentdatetime=$(date +”%T”.”%Y%m%d”)

echo “”
echo “############################################”
echo “# #”
echo “# LINUX – ASM Disk – Device Scanning #”
echo “# #”
echo “############################################”
echo “”

echo ” ##### Collecting informations ##### ”
for i in `cat fc `; do echo “- – -” > /sys/class/scsi_host/$i/scan; echo $i; done

echo ” ##### Gather informations after scanning ##### ”
ls -l /dev/disk/by-id/ > /root/asm/diskbyidaft.$currentdatetime
echo “Save current informations to /root/asm/diskbyidaft.$currentdatetime…”
ls -l /dev/disk/by-id/ | grep -i scsi- > /root/asm/diskbywwnidaft.$currentdatetime
echo “Save current informations to /root/asm/diskbywwnidaft.$currentdatetime…”
multipath -ll > /root/asm/mpathidaft.$currentdatetime
echo “Save multipath informations after scanning to /root/asm/mpathidaft.$currentdatetime…”
#######end of device scanning script named device_scan.sh

#shows newly added disks wwn no
diff diskbywwnidbef.$currentdatetime diskbywwnidaft.$currentdatetime

vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL==”dm-*”, PROGRAM=”scsi_id –page=0x83 –whitelisted –device=/dev/%k”, RESULT==”new wwn”, SYMLINK+=”oracleasm/disks/new_asm_disk_data”, OWNER:=”oracle”, GROUP:=”dba”, MODE=”0660″

#reload udev rules
udevadm control –reload-rules
udevadm trigger

List the Mapped disks
# ls -l /dev/oracleasm/disks

Easy Way to Connect MySql using JDBC

Hi, i will show you how to connect mysql using jdbc in easy way. For those who does not know what jdbc means, it is actually stand for Java Data Base Connector. There are several things you need to prepare before connecting the mysql server. In this tutorial, i was using WAMP server which is pre-installed with mysql just to demonstrate the connection to the mysql from java programming.

Okay, the requirements for this tutorials are:-

1)  Java IDE (eclipse MARS). You can download here (new version eclipse Neon )

2) WAMP server (assume the package installed is v3.0.6).  You can download here.

3) MySQL connector (i am using 5.1.40 connector). You can download here.

4) Set of Java program (will be shown below).

===================================================

1.1) Install eclipse and open it, create new package and new class name.

===================================================

2.1) After the WAMP server is successfully installed and run, you can see the green “W”  icon on the taskbar(on the most left position):-

We can open the phpmyadmin page by left click on the icon:-

The default username for phpmyadmin is ‘root’ and left blank for password:-

After login, we can see the dashboard panel for our database:-

As highlighted in above image, we can straight away create the database by clicking new and put a name for the database for example here my database name is ‘test1’.

Please be remind to always keep refresh for any changes made.

===================================================

3.1) To loading mysql connector into eclipse IDE, we have to configure the build path of the package, and load external connector jar as shown here:-

a) First right click on the package and choose Build Path > Configure Build Path.

b) After that, Add External JARs:-

c) Choose all the JARs files in the mysql connector folder and ok.:-

===================================================

4.1) Assuming all the requirements has been installed and running properly, you have to write the code which require the connection class to be used and driver manager method.

Below is the example to establish the connection to the mysql:-

public static Connection getConnection() {
String driver = “com.mysql.jdbc.Driver”;
String url = “jdbc:mysql://localhost:3306/test1”;
String username = “root”; //leave blank if none
String password = “”; //leave blank if none

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
return DriverManager.getConnection(url, username, password);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}

Below is the sample code for creating table:-

public static Connection writeTable() throws SQLException{
Connection conn2 = getConnection();

String createString=
“CREATE TABLE table8″+
“(ID integer NOT NULL,”+
“LASTNAME varchar(32) NOT NULL,”+
“FIRSTNAME varchar (32) NOT NULL,”+
“Telephone varchar (16) NOT NULL,”+
“PRIMARY KEY (ID))”;
System.out.println(“the db suppose to be written”);

Statement stmt=null;
try{
stmt=conn2.createStatement();
stmt.executeUpdate(createString);
System.out.println(“the db suppose to be written now”);
}
catch(SQLException e){
e.getErrorCode();
System.out.println(“the db have an error:”+e.getSQLState());
}
finally {
if (stmt!=null){stmt.close();}}
return conn2;
}

After you compile and run the code, below result will be appeared:-

After create table, you have to refresh your table by clicking refresh button as below example:-

 

You can check the table created in phpmyadmin page:-

 

And  below code is for inserting data into the table:-

public static Connection populateTable() throws SQLException{
Connection conn2 = getConnection();
Statement stmt=null;
String query = “INSERT INTO `table7`”+”values(125,’Mark’,’Walbergue’,0123456789)”;
try{
stmt=conn2.createStatement();
stmt.executeUpdate(query);}
catch(SQLException e){e.printStackTrace();}
finally{if(stmt!=null){stmt.close();}}
return conn2;

}

 

Keep refresh the table, the data inserted can be viewed as below:-

And below here is the example for viewing the table that we just created:-

private static void viewTable() throws SQLException{
// TODO Auto-generated method stub
Connection conn2 = getConnection();
Statement stmt=null;
String query =
” Select * FROM table8″;
try{
stmt=conn2.createStatement();
ResultSet rs=stmt.executeQuery(query);
while(rs.next()){
int ID=rs.getInt(“ID”);
String lastName=rs.getString(“LASTNAME”);
String firstName=rs.getString(“FIRSTNAME”);
int phone=rs.getInt(“Telephone”);
System.out.println(ID+”\t”+lastName+”\t”+firstName+”\t”+phone+”\t”);
}}
catch(SQLException e){e.printStackTrace();}
finally{if (stmt!=null){stmt.close();}}
}

The result will be shown in the console as below example:-

Main method for this class is shown as below:-

public static void main(String args[]) throws SQLException {

try {

writeTable();
viewTable();
populateTable();
} catch(Exception e) {
System.out.println(e.getMessage());
}

Thats all the examples for establishing connection to the mysql, creating and viewing table and inserting data to table. Hope it can give you an idea how it is works and thanks for viewing this tutorial.

See you again..!

[ERROR] Plugin ‘InnoDB’ init function returned error.

I was getting below mysql error log:-

[Note] Plugin 'FEDERATED' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Using Linux native AIO
InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
InnoDB: Completed initialization of buffer pool
InnoDB: Fatal error: cannot allocate memory for the buffer pool
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting
[Note] /usr/libexec/mysqld: Shutdown complete

I found out there are two solutions which are:-

1)Set innodb_log_file_size equal to the actual size of the existing InnoDB log files. To see what size of innoDB log allocated, login mysql and enter following cmd:-

SHOW GLOBAL VARIABLES LIKE 'innodb_log_file_size';

Expected result example:- 5242880

After that, insert that value in my.cnf:- vi /etc/my.cnf

 innodb_log_file_size =5242880

2)Rename or move both the ./ib_logfile0 and ./ib_logfile1 files, and then start the MySQL server.This normally will be located at /var/lib/mysql. After start mysql, it create new innoDB log file and restore possible half-written data from the file of .ibd.

The expexted mysql log example:-

InnoDB: Database physically writes the file full: wait...
161216  9:58:54  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
161216  9:58:54 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
161216  9:58:54  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
161216  9:58:54  InnoDB: Waiting for the background threads to start
161216  9:58:55 InnoDB: 5.5.50 started; log sequence number 1589772
161216  9:58:55 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
161216  9:58:55 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
161216  9:58:55 [Note] Server socket created on IP: '0.0.0.0'.
161216  9:58:55 [Note] Event Scheduler: Loaded 0 events
161216  9:58:55 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.50'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL) by Remi

References:- JUSTIN KULESZA (2011). MySQL: Failed Registration of InnoDB as a Storage Engine. Available at: https://spin.atomicobject.com/2011/05/09/mysql-failed-registration-of-innodb-as-a-storage-engine/.

RolandoMySQLDBA (2014). MySQL my.cnf: innodb_log_file_size is missing. Available at: http://dba.stackexchange.com/questions/75688/mysql-my-cnf-innodb-log-file-size-is-missing/158325#158325

Changing the Number or Size of InnoDB Redo Log Files. Available at: http://dev.mysql.com/doc/refman/5.7/en/innodb-data-log-reconfiguration.html

Solaris 10: Adding new disk and mirroring it to existing disk

Salam, i would like to share how to add new disk and mirroring it to existing disk.  Here i will show adding it by using vmware and it will demonstrate real situation. At the end of this, i also demonstrate how to detach the disk in case of replacing disk.

zpool_status_after_before_add_disk

Figure 1: zpool status shows current single disk which is c0d0s0

 

vm_edit_settings

Figure 2: In order to make changes, we have to edit virtual machine settings.

 

add_hw_wizard

Figure 3: Choose hard disk

 

add_hw_wizard_ide

Figure 4: Select disk type, in this case we will use IDE.

 

add_hw_wizard_finish

Figure 5: Please rename the vmdk formatted file if you want to and finish the wizard.

 

newly_added_disk

Figure 6: Click ok to close the settings dialog box.

 

echo_format_after_add_new_disk

Figure 7: Image above shows the newly added disk that system has been detected.  The command is echo | format

 

 

prtvtoc_current_slice_table

Figure 8: Display current vtoc table for existing slice. prtvtoc /dev/rdsk/c0d0s0

 

copy_current_vtoc_table_to_new_slice_table

Figure 9: Copy current vtoc table to new slice vtoc table. prtvtoc /dev/rdsk/c0d0s0 | fmthard -s – /dev/rdsk/c0d1s0

 

zpool_attach_f_rpool_c0d0s0_c0d1s0

Figure 10: Atatch newly added disk to current disk as a mirrored disk. zpool attach -f rpool c0d0s0 c0d1s0

 

zpool_status_after_attach_resilvering1

Figure 10: View the status for the zpool. It shows new disk has been attached and mirrored to current pool. zpool status

 

zpool_status_after_attach

Figure 11: The status for mirroring is still resilvering and it takes time before we can make any changes.

 

zpool_status_after_attach_resilvered

Figure 12: Resilvering the disk has completed.

 

zpool_detach

Figure 13: To replace one of the disk, we have to detach first from its mirror. The command we can use is zpool detach rpool c0d1s0

 

zpool_status_after_before_add_disk

Figure 14: After detach the disk to be replaced, please verify it zpool status and supposedly it will shows as above, just one disk.

 

 

httpd: could not open error log file /etc/httpd/logs/error_log

Hi, here i want to share how to troubleshoot for the above error in the redhat server.

When you trying to start the apache service, you have got below error:-

Starting httpd: [date]
(2)No such file or directory: httpd: could not open error log file /etc/httpd/logs/error_log.
Unable to open logs……………………..[FAILED]

  1. First of all,  re check the logs location that has been set in the conf file located by default at /etc/httpd/conf/httpd.conf

Please take note the clause of “ErrorLog logs/error_log”

and you found  ”    ServerRoot “/etc/httpd”      ”

so the full path will be  “/etc/httpd/logs/error_log” for the generated log.

2.  List out the content of “/etc/httpd/logs” by running following command and you will find no error logs in it, that’s why it could not find the file. If the files exists, please make sure the symlink which is point out to -> /var/log/httpd is not broken.

ls -ld /etc/httpd/logs

the output will be:-

lrwxrwxrwx 1 root root date /etc/httpd/logs -> ../../var/log/httpd

3. In the output above, the source directory for symbolic link /etc/httpd/logs is /var/log/httpd.

So, this kind of above mentioned error normally happen when the source file is missing and will be marked as red in color when you list out the content.

Create the error and access log file in the source directory by issuing below command:-

touch error_log access_log

4. Once the log file created, then you can start the apache service by using below command:-

/etc/init.d/httpd start

and verify it by using :-

/etc/init.d/httpd status

and you should get the below output:-

httpd (pid  xxxx) is running…

Thanks for viewing.

Timeout error occurred trying to start MySQL Daemon

Hi, have you been faced the above mentioned error when you trying to start the mysql service? Well here are some solutions that can be taken to resolve the issue.

Error:-

[[email protected]]# /etc/init.d/mysqld start
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]

  1. Check the mysql log for the best practice of troubleshooting. Here is some example taken out from the mysql log:-

[[email protected]]# tail /var/log/mysqld.log

160824 12:47:11 mysqld ended

160824 12:49:36 mysqld started
160824 12:49:36 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to 4294967295
160824 12:49:36 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to 4294967295
160824 12:49:36 InnoDB: Started; log sequence number 0 43655
160824 12:49:36 [ERROR] /usr/libexec/mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’ (Errcode: 13)
160824 12:49:36 [ERROR] Can’t start server: can’t create PID file: Permission denied
160824 12:49:36 mysqld ended

2. Do the checking on ERROR in the above log which is:-

[ERROR] /usr/libexec/mysqld: Can’t create/write to file ‘/var/run/mysqld/mysqld.pid’

[ERROR] Can’t start server: can’t create PID file: Permission denied

3. It was clearly mention about the permission denied when it was trying to create the pid file on /var/run/mysqld/.  So, we can list out the permission for the directory of /var/run/mysqld by running the below command:-

ls -ld /var/run/mysqld

and you got below result:

drwx—–T 5 root root 4096 Aug 24 12:45 /var/run/mysqld

4. Change the directory permission to 755 so the system can create the pid file in that directory. The command will be:-

chmod 755 /var/run

5. Verify the permission by running again below command:-

ls -ld /var/run/mysqld

and you should be getting below result:-

drwxr-xr-x 2 mysql mysql 4096 Aug 24 12:59 /var/run/mysqld

6. Start the mysql service:-

[[email protected]]# /etc/init.d/mysqld start
Starting MySQL: [ OK ]
[[email protected]]# /etc/init.d/mysqld status
mysqld (pid 19633) is running…

and done, you are able to start the mysql service. Thanks for viewing!

Replace failed disk on Solaris 8

Hi, here i want to share how to replace failed disk on solaris 8 that are using veritas file system.

The commands that should be run as below:-

1) vxdisk list (to view all online disks)

2) cfgadm -al ( to grab all information about the connected hardware devices)

3) devfsadm (to install the drivers into the OS)

4) vxdctl enable (to bring up the disks online onto veritas filesystem)

Will share with you the screenshot once i got the chance to do so. However, i already tried above mentioned steps that really helped me a lot on disk replacement. Thank you.