Monday, September 17, 2012

Installation of VNC Server on CentOS 5.x

 I honestly thought I documented this already, but I searched the blog and was unable to locate it.

This covers installation and quick configuration of VNC on a server, in the event that Desktop access is needed on a remote server. In some cases, the CLI is not enough, and I've found this very useful.

On to the entry:

1. Login as root (or su)

2. Install required packages:
yum  -y install vnc-server

3. Secure the VNC server:
vncpasswd
Set mypassword
cd ~/.vnc
ls

the passwd folder should be listed

4. Configure the server:
nano /etc/sysconfig/vncservers
add to end of file:
VNCSERVERS="3:myusername"
VNCSERVERARGS [3] = "-geometry 1024x768"

5. Start the VNC service and configure service to autostart on boot:
service vncserver start
chkconfig vncserver on


6. Further configuration:
cd ~/.vnc
nano xstartup

add under the line "# Add the foll..."
(while true ; do xterm ; done) &
remove comments(#) from
#unset SESSION_MANAGER
#exec /etc/x11/xinit/xinitrc
7. Restart the vnc service
Service vncserver restart

8. Configure firewall to allow VNC server traffic
system-config-securitylevel-tui
add 5903:tcp to exceptions list

9. Open VNC client from remote peer and connect to VNC Server:
server: 192.168.x.x:3
username myusername
password: mypassword (as set in Step 3)


finito
-noveck

Sunday, September 9, 2012

LinuxCon2012!

Just got back from Linux Foundation's LinuxCon2012 (Aug 29-31) in San Diego.

Some great sessions and the slides were made public. It was a powerful reminder of the immense possibilities of open source and who are some of the companies running Linux in their enterprise.

See Linux Foundation's site for some of the brilliant presentations. One of my personal favourites was the fact that SpaceX's shuttle is running on linux.

 Lots of great ideas in hand, stay tuned for some fresh projects!

-noveck

Monday, August 6, 2012

Identifying and Repairing MySQL (MYISAM) Table fragmentation

I had to perform some server maintenance recently, so I decided to re-run the handy mysql tuner tool, as mentioned in my Database Tuning entry.

Lo and behold, a couple tables were identified as fragmented, even though I have a weekly optimization script that checks and repairs any fragmentation.

Just in case there was some sort of anomaly that would bite me in the butt, I decided to run a check to identify the fragmented tables and manually repair those specifically. I found this post by Sean Hull on the DatabaseJournal very helpful!

To quote the author:
"MySQL tables, including MyISAM and InnoDB, two of the most common types, experience fragmentation as data is inserted and deleted randomly. Fragmentation can leave large holes in your table, blocks which must be read when scanning the table. Optimizing your table can therefore make full table scans and range scans more efficient."


The process:

0. Login as root on the Mysql server
mysql -u root -p ************

1. Identify fragmented tablesTake note of the tables, or perhaps select into an outfile if you so desire. This may come in handy if you want to script or automate the identification and repair of the fragmented tables.

select table_schema, table_name, data_free, engine
from information_schema.tables where table_schema
not in ('information_schema', 'mysql') and data_free > 0;


2. Repair the table fragmentation
This could be scripted, but was manually executed as I only had about 4 fragmented tables.
optimize table tablename1;

3. Rerun Step 1 to ensure the fragmentation has been resolved.
 
-noveck

Tuesday, July 31, 2012

Mounting an ISO to an installed VM on VMWare ESXi


I had a little maintenance item to do which involved mounting an ISO to a working VM. Even when the ISO was attached from the VM settings, it somehow was not booting from the device, apparently ESXi sets the first boot device to the HDD by default once a OS is loaded and it will never boot from the CD/ISO. In this case I was using Linux gparted, but for the Windows guys it can be a Windows Server Rescue or something.
This is how I got it to work:
1. Set boot delay to 3000 milliseconds.
                 -Right Click VM -> Edit settings
                 - Options Tab, edit Boot options -> Power on Boot Delay parameter (I used 3000ms or 3 seconds)

2. Mount the ISO from the Datastore / Client DVD
                 - Right Click VM -> Edit settings
                 - Options Tab, CD/DVD Drive x, browse to uploaded ISO or Client Device.

3. Start the VM, at the boot menu hit ESC

4. Select CD/DVD boot option

5. Use your ISO media / Application.

6. When completed reset the Boot Delay parameter to 0.

-noveck

Monday, July 30, 2012

Installing gparted on CentOS 5.x

Okay, so a situation arose where I need to use gparted to do a quick resize on a production server, and this package is not part of the base repository.

It is in the EPEL repo, so that will need to be installed first (if not already done).

Anyhow, it's really simple, so read on...

Assumptions: Base installation of CentOS 5.x

0. Login as root or su

1. Install additional repos

Navigate to temporary directory

cd /temp
download EPEL repo

wget
http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Note: The above URL is sporadic. Please use this alternative if the original does not work. - http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Install the repo
rpm -Uvh epel-release-5-4.noarch.rpm

2. Install the gparted package and dependencies.

yum install gparted --enablerepo=epel disablerepo=rpmforge

*note the rpmforge repo must be disabled before installing (where applicable)

3. Run the application from terminal
gparted

More information can be found here: http://gparted.sourceforge.net/


-noveck

Monday, June 25, 2012

MYSQL ERROR 2003 (HY000): Can't connect to MySQL server on 'xx.xx.xx.xx' (111)

So I was thrown this error recently, while setting up a testing mysql environment and attempting to access it from a remote host. Usually it's the simple things that are overlooked, so here's how to resolve the error:
ERROR 2003 (HY000): Can't connect to MySQL server on 'xx.xx.xx.xx' (111)

The first thing we can check is to see if the user from the remote host is allowed.

1. Login as root on mysql server
mysql -u root -p

2. Select database and show users.
select * from mysql.user\G

**A vertical list will be displayed. Look at the first two fields for each entry. If the user is only allowed to connect from localhost, this may be the problem.
Example:

Host: localhost
User: mydbuser

A user will have to be defined with the same parameters as mydbuser for the remote host (or hosts)
Here's where your documentation will come in handy (or you can hope the old query exists in the mysql buffer!)

3. Allow remote hosts to connect
grant select,insert,update,delete,create,drop,index,alter on mydbname.* to mydbuser@'192.168.1.%' identified by 'mydbpassword' ;

flush privileges;

Note: if you only want to allow a certain host, specify the IP instead of the wildcard.


The second issue that may cause this error is a MySQL configuration.

1. Open MySQL config file
nano /etc/my.cnf

2. Ensure that the following are commented out.

#skip-external-locking
#skip-networking
#bind-address = xx.xx.xx.xx

Save and exit

3. Restart mysql service
service mysqld start

The third issue that may contribute to this error may be the security configuration rejecting incoming requests on the server.

1. Login as root on db server

2. Add rule to iptables
/sbin/iptables -A INPUT -i eth0 -s 192.168.1.0/24 -p tcp --destination-port 3306 -j ACCEPT

** this grants access to the entire subnet, use a specific IP where applicable.

service iptables save

3. Restart iptables service
service iptables restart


Test from remote host by using the following:
mysql -h 192.168.my.dbip -u mydbuser -p


-noveck



Monday, June 18, 2012

Moodle Issues: Backup and restore / course import fails

It was one of those strange situations that popped up after a disaster recovery scenario.

The database server suffered hardware failure, but that was quickly resolved and some tests performed on the database -
MYISAMCHK
and
MYSQLCHECK

Both tests indicated no issues.

Soon after I started getting reports of the course imports or (backup/restores) failing, and troubleshooting took a couple hours. There were a lot of leads on the moodle forums but this is the solution to my particular issue. I strongly recommend turning debugging on from the moodle interface, simply to get as much description on the error as possible.
Debugging revealed a cryptic message: Warning: fopen******* [function.fopen]: failed to open stream: No such file or directory in ******/backuplib.php on line ***followed by a bunch of fwrite problems.

PROBLEM MESSAGE: An error occurred while backing up course start

Solution:

0. Login as admin to the moodle interface.


1. Open the mysqladmin tool  (this can also be done from the MYSQL Server)
2. Truncate the following tables:
  • mdl_backup_courses
  • mdl_backup_files
  • mdl_backup_ids
TRUNCATE TABLE tablename;

3.  Run a mysqlcheck with the check and repair flags just in case.

In my case, this solved the problem. The important point to note, is that the debugging may lead you in the correct direction, so DO NOT USE THIS SOLUTION if you are not certain your problem is identical!


Cheers,
-noveck